|
|
@ -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) { |
|
|
|
|
|
|
|
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); |
|
|
|
list($province, $city) = explode("-", $value); |
|
|
|
$cityNames[] = $city; |
|
|
|
$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); |
|
|
|
|
|
|
|
|
|
|
|