6
0
Fork 0

order-profit:send 仅限微信分账订单

base
panliang 2023-10-23 21:44:23 +08:00
parent 11b6e0c1b8
commit 5227b83ac6
2 changed files with 7 additions and 3 deletions

View File

@ -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());

View File

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