From b0f267c52a393f36b723d658ed5b100da245605b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Wed, 17 Aug 2022 14:47:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#10000=20=E5=A2=9E=E5=8A=A0=E5=95=86?= =?UTF-8?q?=E5=93=81=E4=B8=8B=E8=BD=BD=20=E8=BD=AC=E5=BD=95=E5=88=B0?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/BusinessGoodsSkuToLocal.php | 103 ++++++++++++++++++ app/Console/Commands/Inventory.php | 2 +- 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/BusinessGoodsSkuToLocal.php diff --git a/app/Console/Commands/BusinessGoodsSkuToLocal.php b/app/Console/Commands/BusinessGoodsSkuToLocal.php new file mode 100644 index 0000000..c6efea9 --- /dev/null +++ b/app/Console/Commands/BusinessGoodsSkuToLocal.php @@ -0,0 +1,103 @@ + $v) { + if ($k > 3) { + $skuName .= $v; + } + } + } + if ($brand) { + $goodsBrand = GoodsBrand::firstOrCreate(['name' => $brand]); + $brand = $goodsBrand->id; + } + $goodsType = GoodsType::firstOrCreate(['name' => $type]); + [$goodsCode, $skuCode] = explode('_', $businessGoodsSku['external_sku_id']); + $goods = [ + 'title' => $goodsName, + 'type_id' => $goodsType->id, + 'brand_id' => $brand, + 'goods_code' => $goodsCode, + ]; + $goods = Goods::firstOrCreate($goods); + $goodsSku = [ + 'goods_id' => $goods->id, + 'title' => $skuName, + 'sku_code' => $skuCode, + ]; + GoodsSku::firstOrCreate($goodsSku); + ++$num; + } + }); + $this->info('导入成功: ' . $num); + } +} diff --git a/app/Console/Commands/Inventory.php b/app/Console/Commands/Inventory.php index 348c9d5..40d5de3 100644 --- a/app/Console/Commands/Inventory.php +++ b/app/Console/Commands/Inventory.php @@ -22,7 +22,7 @@ class Inventory extends Command * * @var string */ - protected $description = '定时盘点'; + protected $description = '定时库存盘点'; /** * Create a new command instance.