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