From 14a9ea91d9e86e6b2ed34162fdc7eb67af05e04f Mon Sep 17 00:00:00 2001 From: lqmac Date: Mon, 1 Jul 2024 23:22:38 +0800 Subject: [PATCH] 1 --- app/admin/controller/Store.php | 42 +++++++++++++++++----------------- app/api/controller/Goods.php | 3 +++ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/admin/controller/Store.php b/app/admin/controller/Store.php index a1630389..4801d48c 100644 --- a/app/admin/controller/Store.php +++ b/app/admin/controller/Store.php @@ -383,27 +383,27 @@ class Store extends Controller //删除分类 Category::where('store_id', $storeId)->delete(); - GoodsSku::where('store_id', $storeId)->delete(); - GoodsImage::where('store_id', $storeId)->delete(); - GoodsSpecRel::where('store_id', $storeId)->delete(); - GoodsModel::where('store_id', $storeId)->delete(); - // $page = 1; - // while (TRUE) { - // $goods_list = GoodsModel::where('store_id', $storeId)->field('goods_id')->page($page)->limit(2000)->select(); - // if ($goods_list->isEmpty()) { - // return $this->renderSuccess(); - // } - // $goods_ids = array_column($goods_list->toArray(), "goods_id"); - // //删除商品sku - // GoodsSku::whereIn('goods_id', $goods_ids)->delete(); - // //删除商品图片 - // GoodsImage::whereIn('goods_id', $goods_ids)->delete(); - // //删除商品规格 - // GoodsSpecRel::whereIn('goods_id', $goods_ids)->delete(); - // //删除商品 - // GoodsModel::whereIn('goods_id', $goods_ids)->delete(); - // $page++; - // } + // GoodsSku::where('store_id', $storeId)->delete(); + // GoodsImage::where('store_id', $storeId)->delete(); + // GoodsSpecRel::where('store_id', $storeId)->delete(); + // GoodsModel::where('store_id', $storeId)->delete(); + $page = 1; + while (TRUE) { + $goods_list = GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->field('goods_id')->page($page)->limit(2000)->select(); + if ($goods_list->isEmpty()) { + return $this->renderSuccess(); + } + $goods_ids = array_column($goods_list->toArray(), "goods_id"); + //删除商品sku + GoodsSku::whereIn('goods_id', $goods_ids)->delete(); + //删除商品图片 + GoodsImage::whereIn('goods_id', $goods_ids)->delete(); + //删除商品规格 + GoodsSpecRel::whereIn('goods_id', $goods_ids)->delete(); + //删除商品 + GoodsModel::whereIn('goods_id', $goods_ids)->delete(); + $page++; + } return $this->renderSuccess(); } diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index ef4b5d78..648c2ea0 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -124,6 +124,7 @@ class Goods extends Controller case 'jd': case 'jd1': case 'jd2': + case 'zy': $province = Region::withoutGlobalScope()->where('name', $params['province'])->where('level', 1)->find(); //$city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find(); $district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find(); @@ -131,6 +132,8 @@ class Goods extends Controller $arr = []; $ret = $jd->getGoodsStock($province->jd_code, $city->jd_code, $district->jd_code, $goods['goods_no'], $value['num'] ?? 1); + // echo "
";
+                    // print_r($ret);
                     //var_dump($ret);
                     if ($ret) {
                         $res = $ret['stockResp']['desc'] ?? "无货";