Update
parent
fc303f26f6
commit
aa722e553f
|
|
@ -32,25 +32,37 @@ class OrderAutoAllocate extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
DealerOrder::where('status', DealerOrderStatus::Pending)
|
do {
|
||||||
->where('consignor_id', '>', 1)//到1用户或者公司的订单不需要再分配
|
$page = 0;
|
||||||
->where('allocated_at', '<', now()->subMinutes(app_settings('dealer.order_auto_allocate_times')))
|
|
||||||
->chunkById(200, function ($orders) {
|
DealerOrder::where('status', DealerOrderStatus::Pending)
|
||||||
$orders->load([
|
->where('consignor_id', '>', 1) // 到1用户或者公司的订单不需要再分配
|
||||||
'consignor',
|
->where('allocated_at', '<', now()->subMinutes(app_settings('dealer.order_auto_allocate_times')))
|
||||||
]);
|
->chunkById(200, function ($orders) use (&$page) {
|
||||||
$orderService = new OrderService();
|
$orders->load([
|
||||||
foreach ($orders as $order) {
|
'consignor',
|
||||||
try {
|
]);
|
||||||
DB::beginTransaction();
|
$orderService = new OrderService();
|
||||||
$orderService->updateOrderConsignor($order);
|
foreach ($orders as $order) {
|
||||||
DB::commit();
|
try {
|
||||||
} catch (Throwable $th) {
|
DB::beginTransaction();
|
||||||
DB::rollBack();
|
$orderService->updateOrderConsignor($order);
|
||||||
report($th);
|
DB::commit();
|
||||||
}
|
} catch (Throwable $th) {
|
||||||
|
DB::rollBack();
|
||||||
|
report($th);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$page++;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($page > 1) {
|
||||||
|
sleep(15);
|
||||||
|
} else {
|
||||||
|
sleep(60);
|
||||||
}
|
}
|
||||||
});
|
} while (true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue