where('status', Order::STATUS_COMPLETED) // 没有售后订单 ->whereDoesntHave('afterSales') // 售后期过了 ->where('completed_at', '<', now()->subDays($saleDays)) // 未支付提成 ->whereNull('profit_paid') // 微信分账订单 ->orderBy('wx_share->status', 'Y') ->limit(10) ->get(); foreach ($orders as $order) { try { DB::beginTransaction(); $service->wechatShare($order); DB::commit(); } catch (\Exception $e) { logger('app/Console/Commands/OrderProfitCommand error'); DB::rollBack(); report($e); $this->error($e->getMessage()); } } } }