From c015376907baecfafbb25a18d580c6e521806a2b Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Wed, 22 Oct 2025 09:31:54 +0800 Subject: [PATCH] no message --- src/Services/Cron.php | 50 +++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Services/Cron.php b/src/Services/Cron.php index b46f5a822..4c4eef51c 100755 --- a/src/Services/Cron.php +++ b/src/Services/Cron.php @@ -926,6 +926,11 @@ final class Cron $oUser = User::find($invoice->user_id); + if (!$oUser) { + DB::commit(); + continue; + } + $iPayAmount = $invoice->price - $invoice->money_use; if ($oOrder->product_code == "code") { // 钱包充值 @@ -1105,13 +1110,19 @@ final class Cron $oProduct = Product::where("code", $oPlanPending->product_code)->first(); // * 商品表 + $oUser = User::find($oPlanQueue->user_id); + + if (!$oUser) { + DB::commit(); + continue; + } + // 没有对应商品时 if (!$oProduct) { $oPlanPending->error_code = "fail"; $oPlanPending->error_str = "激活失败,该商品已从数据库存中移除,金额以退回至钱包。"; // 退回钱包 - $oUser = User::find($oPlanQueue->user_id); $iUserMoneyOld = $oUser->money; $iUserMoneyNew = $oUser->money + $oPlanPending->user_price; @@ -1136,8 +1147,6 @@ final class Cron //// 用户激活 $oProductContent = json_decode($oProduct->content); - - $oUser = User::find($oPlanQueue->user_id); self::_plan_to_user($oUser, $oProductContent); // 套餐赋予用户 @@ -1203,7 +1212,7 @@ final class Cron // 检查自动续订是否开启 $oUser = User::where("id", $oPlanQueue->user_id)->first(); // * 数据 - if ($oUser->autorenew != 1) { + if (!$oUser || $oUser->autorenew != 1) { continue; } @@ -1324,6 +1333,11 @@ final class Cron $oUser = User::where("id", $oPlanExpireQueue->user_id)->first(); + if (!$oUser) { + DB::commit(); + continue; + } + //// activated转移到expired // $oPlanActivated = PlanActivated::where("user_id", $oPlanExpireQueue->user_id)->first(); // 必然有,没有自然报错,user唯一 $oPlanActivated = Order::where("user_id", $oPlanExpireQueue->user_id)->where("status", "activated")->first(); // 没有就不管,只过期用户 @@ -1436,20 +1450,20 @@ final class Cron // // } -// private static function _eToArr($oError, $sTitle = false) -// { -// $arr = []; -// -// if ($sTitle) { -// $arr['title'] = $sTitle; -// } -// -// $arr['code'] = $oError->getCode(); -// $arr['file'] = $oError->getFile(); -// $arr['line'] = $oError->getLine(); -// -// return $arr; -// } + private static function _eToArr($oError, $sTitle = false) + { + $arr = []; + + if ($sTitle) { + $arr['title'] = $sTitle; + } + + $arr['code'] = $oError->getCode(); + $arr['file'] = $oError->getFile(); + $arr['line'] = $oError->getLine(); + + return $arr; + } private static function _helper_log($sMsg, $sTgMsg = false) {