no message

This commit is contained in:
hellcat 2025-10-10 16:36:26 +08:00
parent 3bc4d2e8b5
commit 8f26b72400
2 changed files with 78 additions and 66 deletions

View File

@ -44,7 +44,7 @@ final class PlanController extends BaseController
$oUserPlanRow->created_at = date("Y-m-d H:i:s", $oUserPlanRow->create_time);
if ($oUserPlanRow->error_str) {
$oUserPlanRow->status = $oUserPlanRow->error_str;
$oUserPlanRow->status = $oUserPlanRow->error_str;
}
else if ($oUserPlanRow->status == "payment_pending") {

View File

@ -415,6 +415,9 @@ final class Cron
// 作废了
public static function expirePaidUserAccount(): void
{
return false; // 作废
$paidUsers = (new User())->where('class', '>=', 2)->get();
foreach ($paidUsers as $user) {
@ -637,8 +640,12 @@ final class Cron
}
// 激活订单
// 作废
public static function processTabpOrderActivation(): void
{
return false; // 作废
$users = User::all();
foreach ($users as $user) {
@ -816,7 +823,7 @@ final class Cron
$iPayClass = $_ENV["user_payClass"];
$pending_payment_orders = (new Order())->where('status', 'payment_pending')->get(); // 这里还是无脑检索order了但是现在order表可以只保留一年内数据问题不大
//tomd($pending_payment_orders, 1);
$aUserInQueue = []; // 用户可能在5分钟之内多次下单但一次只处理一个坚固
foreach ($pending_payment_orders as $oOrder) {
@ -825,7 +832,7 @@ final class Cron
}
$aUserInQueue[] = $oOrder->user_id;
// tomd($aUserInQueue, 1);
try {
$invoice = (new Invoice())->where('order_id', $oOrder->id)->first();
@ -841,6 +848,8 @@ final class Cron
$oUser = User::find($invoice->user_id);
$iPayAmount = $invoice->price - $invoice->money_use;
if ($oOrder->product_code == "code") { // 钱包充值
$iUserMoneyOld = $oUser->money;
@ -848,6 +857,7 @@ final class Cron
$iAmount = $invoice->price;
$oUser->money = $iUserMoneyNew;
$oUser->money_total += $iPayAmount;
$oUser->save();
(new UserMoneyLog())->add(
@ -864,8 +874,9 @@ final class Cron
self::_helper_log("订单".$oOrder->id."钱包充值到账");
} else if ($oUser->class < $iPayClass) { // 当前无套餐,直接进激活队列
// $oPlanPending = new Order();
// $oPlanPending->_add($oOrder);
$oUser->money_total += $iPayAmount;
$oUser->save();
$oOrder->status = "pending";
$oOrder->_save();
@ -875,8 +886,9 @@ final class Cron
self::_helper_log("订单".$oOrder->id."进入到激活队列");
} else { // 当前有套餐进入pending表
// $oPlanPending = new PlanPending();
// $oPlanPending->_add($oOrder);
$oUser->money_total += $iPayAmount;
$oUser->save();
$oOrder->status = "pending";
$oOrder->_save();
@ -904,8 +916,6 @@ final class Cron
);
}
// $oOrder->delete();
}
DB::commit();
@ -914,8 +924,13 @@ final class Cron
DB::rollBack();
// if ($oOrder) {
// $oOrder->error_code = "error";
// $oOrder->error_str = "支付未到账,请联系管理员";
// $oOrder->_save();
// }
$sMsg = self::_helper_toJson($e->getMessage());
self::_helper_log($sMsg, self::_eToArr($e, $sMsg));
}
@ -962,7 +977,6 @@ final class Cron
DB::rollBack();
$sMsg = self::_helper_toJson($e->getMessage());
self::_helper_log($sMsg, self::_eToArr($e, $sMsg));
}
@ -1280,58 +1294,58 @@ final class Cron
}
private static function plan_activatedToExpired(&$oPlanActivated)
{
if (!$oPlanActivated) {
return false;
}
$oPlanExpired = new PlanExpired();
$oPlanExpired->_add($oPlanActivated);
return $oPlanActivated->_delete();
}
// private static function plan_activatedToExpired(&$oPlanActivated)
// {
// if (!$oPlanActivated) {
// return false;
// }
//
// $oPlanExpired = new PlanExpired();
// $oPlanExpired->_add($oPlanActivated);
//
// return $oPlanActivated->_delete();
// }
private static function plan_pendingToActivated(&$oPlanPending)
{
if (!$oPlanPending) {
return false;
}
$oPlanActivated = new PlanActivated();
$oPlanActivated->_add($oPlanPending);
return $oPlanPending->_delete();
}
// private static function plan_pendingToActivated(&$oPlanPending)
// {
// if (!$oPlanPending) {
// return false;
// }
//
// $oPlanActivated = new PlanActivated();
// $oPlanActivated->_add($oPlanPending);
//
// return $oPlanPending->_delete();
// }
public static function _helper_toJson($data)
{
return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
public static function _helper_fail(&$oPlanPending)
{
$oPlanPending->status_str = "套餐激活失败,请联系管理员。";
$oPlanPending->status = "fail";
$oPlanPending->_save();
}
// public static function _helper_fail(&$oPlanPending)
// {
//
// $oPlanPending->status_str = "套餐激活失败,请联系管理员。";
// $oPlanPending->status = "fail";
// $oPlanPending->_save();
//
// }
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)
{
@ -1343,15 +1357,15 @@ final class Cron
}
}
private static function _helper_throw($sMsg, $aTgMsg = [])
{
if ($aTgMsg) {
$oTelegramV2 = new TelegramV2();
$oTelegramV2->send(json_encode($aTgMsg));
}
throw new \Exception($sMsg);
}
// private static function _helper_throw($sMsg, $aTgMsg = [])
// {
// if ($aTgMsg) {
// $oTelegramV2 = new TelegramV2();
// $oTelegramV2->send(json_encode($aTgMsg));
// }
//
// throw new \Exception($sMsg);
// }
private static function _plan_to_user(&$oUser, $aProductContent)
{
@ -1498,7 +1512,6 @@ final class Cron
$sTgReport = $oTgSendFormat->typeA();
// var_dump($sTgReport);
(new Telegram())->send(0, $sTgReport);
// 流量报告,机器
@ -1537,7 +1550,6 @@ final class Cron
$sTgReport = $oTgSendFormat->typeA();
// var_dump($sTgReport);
(new Telegram())->send(0, $sTgReport);
}