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()
{
$service = new \App\Services\DistributeService();
try {
DB::beginTransaction();
$query = Order::completable();
if ($id = $this->argument('order')) {
$query->whereIn('id', explode(',', $id));
while (true) {
try {
DB::beginTransaction();
$query = Order::completable();
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();
$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);
sleep(60);
}
return 0;
}
}