6
0
Fork 0
release
panliang 2022-05-23 11:27:38 +08:00
parent f14228509a
commit c65385a21c
1 changed files with 20 additions and 18 deletions

View File

@ -41,25 +41,27 @@ class OrderDistribute extends Command
public function handle() public function handle()
{ {
$service = new \App\Services\DistributeService(); $service = new \App\Services\DistributeService();
try { while (true) {
DB::beginTransaction(); try {
$query = Order::completable(); DB::beginTransaction();
if ($id = $this->argument('order')) { $query = Order::completable();
$query->whereIn('id', explode(',', $id)); if ($id = $this->argument('order')) {
$query->whereIn('id', explode(',', $id));
}
$orders = $query->get();
$this->line('总数: ' . $orders->count());
$count = 0;
foreach($orders as $order) {
$profit = $service->storeByOrder($order);
$count++;
}
$this->info('符合要求: ' . $count);
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
$this->line($th);
} }
$orders = $query->get(); sleep(60);
$this->line('总数: ' . $orders->count());
$count = 0;
foreach($orders as $order) {
$profit = $service->storeByOrder($order);
$count++;
}
$this->info('符合要求: ' . $count);
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
$this->line($th);
} }
return 0;
} }
} }