From bea2fee22220e6655b1859a4dcdac871c7d7bd7f Mon Sep 17 00:00:00 2001 From: liapples Date: Mon, 25 Oct 2021 18:08:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Collector.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Console/Commands/Collector.php b/app/Console/Commands/Collector.php index e6f557a..3eadfa9 100644 --- a/app/Console/Commands/Collector.php +++ b/app/Console/Commands/Collector.php @@ -81,22 +81,22 @@ class Collector extends Command } if (ctype_digit($supplier_id)) { + $ids = [$supplier_id]; + } else if ($supplier_id == 'all') { + $ids = Supplier::query()->pluck('id'); + } else { + return; + } + + foreach ($ids as $supplier_id) { + $this->line('正在导入 ' . $supplier_id); array_walk($import_data, function ($v) use ($supplier_id) { $v['supplier_id'] = $supplier_id; unset($v['unique_id'], $v['site']); Product::query()->updateOrCreate(['supplier_id' => $supplier_id, 'title' => $v['title']], $v); }); - } else if ($supplier_id == 'all') { - $ids = Supplier::query()->pluck('id'); - foreach ($ids as $supplier_id) { - array_walk($import_data, function ($v) use ($supplier_id) { - $v['supplier_id'] = $supplier_id; - unset($v['unique_id'], $v['site']); - - Product::query()->updateOrCreate(['supplier_id' => $supplier_id, 'title' => $v['title']], $v); - }); - } + $this->line("导入 $supplier_id 结束"); } }