diff --git a/src/Services/Cron.php b/src/Services/Cron.php index 827855a57..2551d2f40 100755 --- a/src/Services/Cron.php +++ b/src/Services/Cron.php @@ -963,7 +963,7 @@ final class Cron DB::beginTransaction(); - $oUser->isPayClass = $oUser->class >= $iPayClass ? true : false; +// $oUser->isPayClass = $oUser->class >= $iPayClass ? true : false; if (strtotime($oUser->class_expire) < time()) { // 时间到期 self::_class_expire($oUser); @@ -1007,14 +1007,15 @@ final class Cron ->orderBy("id", "ASC") ->first(); + // 没有待激活套餐时,跳过。否则都必然$oPlanQueue->_delete(); + if (!$oPlanPending) { + $oPlanQueue->type = "expire"; + $oPlanQueue->save(); + continue; // 没有待激活就直接桡过,而不是报错 + } + try { - // 没有待激活套餐时,跳过。否则都必然$oPlanQueue->_delete(); - if (!$oPlanPending) { -// throw new \Exception("没有待激活套餐"); - continue; // 没有待激活就直接桡过,而不是报错 - } - DB::beginTransaction(); $oProduct = Product::where("code", $oPlanPending->product_code)->first(); // * 商品表 @@ -1030,7 +1031,7 @@ final class Cron $iUserMoneyOld = $oUser->money; $iUserMoneyNew = $oUser->money + $oPlanPending->user_price; - $oUser->money = $oPlanPending->user_price; + $oUser->money = $iUserMoneyNew; $oUser->save(); (new UserMoneyLog())->add( @@ -1141,7 +1142,7 @@ final class Cron $oUser->autorenew = 0; $oUser->save(); - // todo 发站内信 + // todo 发站内信 成功失败都发 DB::commit(); continue; } @@ -1187,7 +1188,7 @@ final class Cron DB::commit(); - continue; +// continue; } catch (\Exception $e) { @@ -1230,20 +1231,13 @@ final class Cron DB::beginTransaction(); $oUser = User::where("id", $oPlanExpireQueue->user_id)->first(); - $oUser->class = $iToClass; - $oUser->class_expire = $iToExpire; - $oUser->transfer_enable = $iToEnable; - $oUser->u = 0; - $oUser->d = 0; - $oUser->transfer_today = 0; - $oUser->save(); //// activated转移到expired // $oPlanActivated = PlanActivated::where("user_id", $oPlanExpireQueue->user_id)->first(); // 必然有,没有自然报错,user唯一 - $oPlanActivated = Order::where("user_id", $oPlanExpireQueue->user_id)->where("status", "activated")->first(); - + $oPlanActivated = Order::where("user_id", $oPlanExpireQueue->user_id)->where("status", "activated")->first(); // 没有就不管,只过期用户 if ($oPlanActivated) { $oPlanActivated->status = "expired"; + $oPlanActivated->update_time = time(); $oPlanActivated->_save(); // self::plan_activatedToExpired($oPlanActivated); } @@ -1257,6 +1251,14 @@ final class Cron $text .= '已转为免费体验帐户,赠送' . $reset_traffic . 'GB体验流量,'.$reset_day.'天体验时长。'; } + $oUser->class = $iToClass; + $oUser->u = 0; + $oUser->d = 0; + $oUser->transfer_today = 0; + $oUser->transfer_enable = $iToEnable; + $oUser->class_expire = $iToExpire; + $oUser->save(); + try { Notification::notifyUser($oUser, $_ENV['appName'] . '-您的套餐已经过期', $text); } catch (GuzzleException|ClientExceptionInterface|TelegramSDKException $e) { @@ -1264,12 +1266,12 @@ final class Cron } //// end - $r = $oPlanExpireQueue->delete(); - - DB::commit(); + $oPlanExpireQueue->delete(); self::_helper_log("用户".$oUser->id."彻底过期"); + DB::commit(); + } catch (\Exception $e) { DB::rollBack();