console
parent
f14228509a
commit
c65385a21c
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue