From c8e27d0d607323b8c4c1f1f3584b99791bec6146 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Tue, 20 Sep 2022 18:09:30 +0800 Subject: [PATCH] order --- app/Console/Commands/OrderProfitCommand.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/Console/Commands/OrderProfitCommand.php b/app/Console/Commands/OrderProfitCommand.php index 0a9d5abb..9928ff09 100644 --- a/app/Console/Commands/OrderProfitCommand.php +++ b/app/Console/Commands/OrderProfitCommand.php @@ -44,6 +44,7 @@ class OrderProfitCommand extends Command { $service = new DistributeService(); + $now = now(); // 售后过期天数 7 $saleDays = app_settings('app.sale_after_expire_days'); @@ -79,16 +80,11 @@ class OrderProfitCommand extends Command } // 没有待付款的提成记录 - Order::where(fn($q) => $q->whereDoesntHave('profits', fn($q) => $q->where('status', '!=', 2))->orWhereDoesntHave('profits')) - // 订单已完成 - ->where('status', Order::STATUS_COMPLETED) - // 没有售后订单 - ->whereDoesntHave('afterSales') - // 售后期过了 - ->where('completed_at', '<', now()->subDays($saleDays)) - // 未支付提成 - ->whereNull('profit_paid') - ->update(['profit_paid' => now()]); + foreach($orders as $item) { + if (!$item->profits()->where('status', 4)->exists()) { + $item->update(['profit_paid' => $now]); + } + } $page++;