Browse Source

修改变量名

master
李可松 4 years ago
parent
commit
b2a17ca7f9
  1. 10
      app/Console/Commands/OrderTimeout.php

10
app/Console/Commands/OrderTimeout.php

@ -53,14 +53,14 @@ class OrderTimeout extends Command
->whereNotNull('timeout') ->whereNotNull('timeout')
->min('id');*/ ->min('id');*/
$min_id = 0;
$current_id = 0;
while (true) { while (true) {
Order::with('orderProductItem') Order::with('orderProductItem')
// ->where('id', '>=', $min_id) // ->where('id', '>=', $min_id)
->whereIn('status', $status_arr) ->whereIn('status', $status_arr)
->whereNotNull('timeout') ->whereNotNull('timeout')
->orderBy('id') ->orderBy('id')
->chunk(100, function ($order) use (&$min_id) {
->chunk(100, function ($order) use (&$current_id) {
foreach ($order as $v) { foreach ($order as $v) {
if (!is_null($v->timeout) && strtotime($v->timeout) < time()) { if (!is_null($v->timeout) && strtotime($v->timeout) < time()) {
DB::beginTransaction(); DB::beginTransaction();
@ -102,7 +102,7 @@ class OrderTimeout extends Command
} }
DB::commit(); DB::commit();
$min_id = $v->id;
$current_id = $v->id;
} catch (\Exception $exception) { } catch (\Exception $exception) {
DB::rollBack(); DB::rollBack();
$this->line("订单ID {$v->id} 错误:" . $exception->getMessage()); $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); sleep(5);
} }
return 0; return 0;

Loading…
Cancel
Save