diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index eec905d1..6a132a23 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -208,7 +208,7 @@ class Goods extends BaseModel // 执行查询 $list = $query ->alias($this->name) - ->field(['goods.goods_id', 'goods.goods_name', 'cmmdty_model', 'remark', 'cost_price_min', 'stock_total', 'is_check', 'goods_price_min','goods_no','goods_source','delivery_time','delivery_id','status']) + ->field(['goods.goods_id', 'goods.goods_name', 'cmmdty_model', 'remark', 'cost_price_min', 'stock_total', 'is_check', 'goods_price_min','goods_no','goods_source','delivery_time','delivery_id','status','link','link_other']) ->where('is_delete', '=', 0) ->order($sort) ->paginate($listRows); diff --git a/app/job/service/goods/GoodsStoreImport.php b/app/job/service/goods/GoodsStoreImport.php index 7c2b922b..5e79308c 100644 --- a/app/job/service/goods/GoodsStoreImport.php +++ b/app/job/service/goods/GoodsStoreImport.php @@ -207,14 +207,22 @@ class GoodsStoreImport extends BaseService //批量导入销售区域处理 $region = []; $region_text = []; - if ($original["J"]) { + if ($original["L"]) { $sale_areas = $original["L"] ? explode("、", $original["L"]) : []; $cityNames = []; foreach ($sale_areas as $value) { - list($province, $city) = explode("-", $value); - $cityNames[] = $city; + if (strpos($value, "-") === false) { + $province = Region::withoutGlobalScope()->where('name', $value)->where('level', 1)->find(); + $citys = Region::withoutGlobalScope()->where('pid', $province['id'] ?? 0)->where('level', 2)->select()->toArray(); + $citys = array_column($citys, "name"); + + } else { + list($province, $city) = explode("-", $value); + $citys = [$city]; + } + $cityNames = array_merge($cityNames, $citys); } - $regions = Region::withoutGlobalScope()->whereIn('name', $cityNames)->select()->toArray(); + $regions = Region::withoutGlobalScope()->whereIn('name', $cityNames)->where('level', 2)->select()->toArray(); $regionsnew = []; foreach ($regions as $key => $value) { $regionsnew[$value['pid']][] = $value; @@ -232,7 +240,10 @@ class GoodsStoreImport extends BaseService $region_text[$pid]['citys'] = $citys; } } - + // echo "
";
+         //    print_r($region_text);
+         //    print_r($region);
+         //    exit();
         // 整理商品数据
         $data = [
             'cmmdty_model' => $original["A"],
@@ -253,11 +264,13 @@ class GoodsStoreImport extends BaseService
             'goods_status' => 10,//上架
             'store_id' => $storeId,
             //'sale_areas' => $arr ? implode("、", $arr) : "",
-            'region' => $region ? json_encode($region) : "",
-            'region_text' => $region_text ? json_encode(array_values($region_text)) : "",
+            'region' => $region ? json_encode($region, JSON_UNESCAPED_UNICODE) : "",
+            'region_text' => $region_text ? json_encode(array_values($region_text), JSON_UNESCAPED_UNICODE) : "",
             'import' => 1,//是否是导入采集
         ];
-        
+        // echo "
";
+        // print_r($data);
+        // exit();
         // 过滤不存在的ID集数据
         $data['categoryIds'] = CategoryModel::filterCategoryIds($data['categoryIds'], $storeId);
 
diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php
index 81f42f30..3b677e1c 100644
--- a/app/store/controller/Goods.php
+++ b/app/store/controller/Goods.php
@@ -35,7 +35,7 @@ class Goods extends Controller
         // 获取列表记录
         $model = new GoodsModel;
         $params = $this->request->param();
-        $params['channel'] = 'zy';
+        //$params['channel'] = 'zy';
         $list= $model->getList($params, (int)$this->request->param('pageSize', 15));
         return $this->renderSuccess(compact('list'));
     }