diff --git a/app/Jobs/CheckAndChargeBalance.php b/app/Jobs/CheckAndChargeBalance.php index c011c53..1c9ae88 100644 --- a/app/Jobs/CheckAndChargeBalance.php +++ b/app/Jobs/CheckAndChargeBalance.php @@ -28,8 +28,6 @@ public function handle() $bc = new BalanceController(); - - // 查找今天未支付的订单 Balance::where('paid_at', null)->chunk(100, function ($balances) use ($bc) { foreach ($balances as $balance) { if (!$bc->checkAndCharge($balance)) { @@ -40,6 +38,9 @@ public function handle() } }); + // 删除所有未付款并且大于两天的订单 + Balance::where('paid_at', null)->where('created_at', '<', now()->subDays(2))->delete(); + // Balance::chunk(100, function ($balances) use ($bc) { // foreach ($balances as $balance) {