diff --git a/app/Console/Commands/OrderProfitCommand.php b/app/Console/Commands/OrderProfitCommand.php index 53d8301b..5377afff 100644 --- a/app/Console/Commands/OrderProfitCommand.php +++ b/app/Console/Commands/OrderProfitCommand.php @@ -42,6 +42,7 @@ class OrderProfitCommand extends Command */ public function handle() { + $service = new DistributeService(); // 售后过期天数 7 @@ -78,9 +79,11 @@ class OrderProfitCommand extends Command } // 没有待付款的提成记录 - // if (!$order->profits()->where('status', 0)->exists()) { - // $order->update(['profit_paid' => now()]); - // } + Order::where(fn($q) => $q->whereHas('profits', fn($q) => $q->where('status', 2))->orWhereDoesntHave('profits')) + // 售后期过了 + ->where('completed_at', '<', now()->subDays($saleDays)) + ->whereNull('profit_paid') + ->update(['profit_paid' => now()]); $page++;