From b2a17ca7f9067e3c9ad1f04a619996dd9ebc4a89 Mon Sep 17 00:00:00 2001 From: liapples Date: Mon, 27 Sep 2021 09:14:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=98=E9=87=8F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/OrderTimeout.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Console/Commands/OrderTimeout.php b/app/Console/Commands/OrderTimeout.php index be90efe..74fb34f 100644 --- a/app/Console/Commands/OrderTimeout.php +++ b/app/Console/Commands/OrderTimeout.php @@ -53,14 +53,14 @@ class OrderTimeout extends Command ->whereNotNull('timeout') ->min('id');*/ - $min_id = 0; + $current_id = 0; while (true) { Order::with('orderProductItem') // ->where('id', '>=', $min_id) ->whereIn('status', $status_arr) ->whereNotNull('timeout') ->orderBy('id') - ->chunk(100, function ($order) use (&$min_id) { + ->chunk(100, function ($order) use (&$current_id) { foreach ($order as $v) { if (!is_null($v->timeout) && strtotime($v->timeout) < time()) { DB::beginTransaction(); @@ -102,7 +102,7 @@ class OrderTimeout extends Command } DB::commit(); - $min_id = $v->id; + $current_id = $v->id; } catch (\Exception $exception) { DB::rollBack(); $this->line("订单ID {$v->id} 错误:" . $exception->getMessage()); @@ -111,9 +111,7 @@ class OrderTimeout extends Command } }); - //TODO 产品规格表加库存 - - $this->line('[' . date('Y-m-d H:i:s') . "] ID游标:$min_id ,等待下一个任务"); + $this->line('[' . date('Y-m-d H:i:s') . "] ID游标:$current_id ,等待下一个任务"); sleep(5); } return 0;