lqmac 7 months ago
parent 117c078af7
commit c73bf032a3
  1. 2
      app/common/model/Goods.php
  2. 29
      app/job/service/goods/GoodsStoreImport.php
  3. 2
      app/store/controller/Goods.php

@ -208,7 +208,7 @@ class Goods extends BaseModel
// 执行查询 // 执行查询
$list = $query $list = $query
->alias($this->name) ->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) ->where('is_delete', '=', 0)
->order($sort) ->order($sort)
->paginate($listRows); ->paginate($listRows);

@ -207,14 +207,22 @@ class GoodsStoreImport extends BaseService
//批量导入销售区域处理 //批量导入销售区域处理
$region = []; $region = [];
$region_text = []; $region_text = [];
if ($original["J"]) { if ($original["L"]) {
$sale_areas = $original["L"] ? explode("、", $original["L"]) : []; $sale_areas = $original["L"] ? explode("、", $original["L"]) : [];
$cityNames = []; $cityNames = [];
foreach ($sale_areas as $value) { foreach ($sale_areas as $value) {
list($province, $city) = explode("-", $value); if (strpos($value, "-") === false) {
$cityNames[] = $city; $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 = []; $regionsnew = [];
foreach ($regions as $key => $value) { foreach ($regions as $key => $value) {
$regionsnew[$value['pid']][] = $value; $regionsnew[$value['pid']][] = $value;
@ -232,7 +240,10 @@ class GoodsStoreImport extends BaseService
$region_text[$pid]['citys'] = $citys; $region_text[$pid]['citys'] = $citys;
} }
} }
// echo "<pre>";
// print_r($region_text);
// print_r($region);
// exit();
// 整理商品数据 // 整理商品数据
$data = [ $data = [
'cmmdty_model' => $original["A"], 'cmmdty_model' => $original["A"],
@ -253,11 +264,13 @@ class GoodsStoreImport extends BaseService
'goods_status' => 10,//上架 'goods_status' => 10,//上架
'store_id' => $storeId, 'store_id' => $storeId,
//'sale_areas' => $arr ? implode("、", $arr) : "", //'sale_areas' => $arr ? implode("、", $arr) : "",
'region' => $region ? json_encode($region) : "", 'region' => $region ? json_encode($region, JSON_UNESCAPED_UNICODE) : "",
'region_text' => $region_text ? json_encode(array_values($region_text)) : "", 'region_text' => $region_text ? json_encode(array_values($region_text), JSON_UNESCAPED_UNICODE) : "",
'import' => 1,//是否是导入采集 'import' => 1,//是否是导入采集
]; ];
// echo "<pre>";
// print_r($data);
// exit();
// 过滤不存在的ID集数据 // 过滤不存在的ID集数据
$data['categoryIds'] = CategoryModel::filterCategoryIds($data['categoryIds'], $storeId); $data['categoryIds'] = CategoryModel::filterCategoryIds($data['categoryIds'], $storeId);

@ -35,7 +35,7 @@ class Goods extends Controller
// 获取列表记录 // 获取列表记录
$model = new GoodsModel; $model = new GoodsModel;
$params = $this->request->param(); $params = $this->request->param();
$params['channel'] = 'zy'; //$params['channel'] = 'zy';
$list= $model->getList($params, (int)$this->request->param('pageSize', 15)); $list= $model->getList($params, (int)$this->request->param('pageSize', 15));
return $this->renderSuccess(compact('list')); return $this->renderSuccess(compact('list'));
} }

Loading…
Cancel
Save