where('consignor_id', '>', 1)//到1用户或者公司的订单不需要再分配 ->where('allocated_at', '<', now()->subHours(app_settings('dealer.order_auto_allocate_times'))) ->chunkById(200, function ($orders) { $orders->load([ 'consignor', ]); $orderService = new OrderService(); foreach ($orders as $order) { try { DB::beginTransaction(); $orderService->updateOrderConsignor($order); DB::commit(); } catch (Throwable $th) { DB::rollBack(); report($th); } } }); return 0; } }