|
|
|
@ -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 "<pre>"; |
|
|
|
|
// 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 "<pre>"; |
|
|
|
|
// print_r($data); |
|
|
|
|
// exit(); |
|
|
|
|
// 过滤不存在的ID集数据 |
|
|
|
|
$data['categoryIds'] = CategoryModel::filterCategoryIds($data['categoryIds'], $storeId); |
|
|
|
|
|
|
|
|
|