From bc6b4d5b1125a8384a45a3565b6520446a4b1b05 Mon Sep 17 00:00:00 2001 From: weizong song Date: Tue, 2 Dec 2025 23:33:32 +0800 Subject: [PATCH] up --- app/Console/Commands/FixOrderItemsPaidAt.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/FixOrderItemsPaidAt.php b/app/Console/Commands/FixOrderItemsPaidAt.php index c9484a4..6273eba 100644 --- a/app/Console/Commands/FixOrderItemsPaidAt.php +++ b/app/Console/Commands/FixOrderItemsPaidAt.php @@ -55,6 +55,8 @@ class FixOrderItemsPaidAt extends Command $serviceDateStr = $serviceDate->format('Y-m-d'); $serviceDateEnd = $serviceDateStr . ' 23:59:59'; + // 计算 service_date 所在月份的月底最后一秒 + $monthEnd = $serviceDate->copy()->endOfMonth()->format('Y-m-d 23:59:59'); $isDryRun = $this->option('dry-run'); if ($isDryRun) { @@ -64,6 +66,7 @@ class FixOrderItemsPaidAt extends Command $this->info("开始" . ($isDryRun ? "预览" : "修复") . " {$serviceDateStr} 的订单项..."); $this->info("目标时间点:{$serviceDateEnd}"); + $this->info("余额计算时间点:{$monthEnd}(当月月底最后一秒)"); // 查询需要修复的记录 // 条件:paid_at 的日期晚于 service_date,且不在同一月份 @@ -114,8 +117,8 @@ class FixOrderItemsPaidAt extends Command continue; } - // 计算在 service_date 时的客户余额 - $balanceAtTime = $this->calculateCustomerBalanceAtTime($customerId, $serviceDateStr, $item->id); + // 计算在 service_date 所在月份月底最后一秒时的客户余额 + $balanceAtTime = $this->calculateCustomerBalanceAtTime($customerId, $monthEnd, $item->id); // 判断是否满足修复条件 if ($balanceAtTime >= $item->total) {