From 5227b83ac663784f6ac0dba86d226fff3905e0e9 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Mon, 23 Oct 2023 21:44:23 +0800 Subject: [PATCH] =?UTF-8?q?order-profit:send=20=E4=BB=85=E9=99=90=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=88=86=E8=B4=A6=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/OrderProfitCommand.php | 5 +++-- app/Services/DistributeService.php | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/OrderProfitCommand.php b/app/Console/Commands/OrderProfitCommand.php index a8ce84c1..0492b94a 100644 --- a/app/Console/Commands/OrderProfitCommand.php +++ b/app/Console/Commands/OrderProfitCommand.php @@ -54,6 +54,8 @@ class OrderProfitCommand extends Command ->where('completed_at', '<', now()->subDays($saleDays)) // 未支付提成 ->whereNull('profit_paid') + // 微信分账订单 + ->orderBy('wx_share->status', 'Y') ->limit(10) ->get(); @@ -61,10 +63,9 @@ class OrderProfitCommand extends Command try { DB::beginTransaction(); $service->wechatShare($order); - // 分账成功, 更新订单状态 - $order->update(['profit_paid' => $now]); DB::commit(); } catch (\Exception $e) { + logger('app/Console/Commands/OrderProfitCommand error'); DB::rollBack(); report($e); $this->error($e->getMessage()); diff --git a/app/Services/DistributeService.php b/app/Services/DistributeService.php index 90acda25..6962e5a3 100644 --- a/app/Services/DistributeService.php +++ b/app/Services/DistributeService.php @@ -251,7 +251,10 @@ class DistributeService } if ($status == 'FINISHED') { $attributes = ['share_sn' => $sn, 'status' => 'N']; - $order->update(['wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes]); + $order->update([ + 'wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes, + 'profit_paid' => now(), + ]); $this->success($list, $result); } }