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); } }