|
|
|
@ -199,13 +199,32 @@ class AdminImport extends BaseService |
|
|
|
|
|
|
|
|
|
$channel = Channel::where('name', $original["B"])->find(); |
|
|
|
|
|
|
|
|
|
$arr = []; |
|
|
|
|
$sale_areas = $original["J"] ? explode("、", $original["J"]) : []; |
|
|
|
|
if ($sale_areas) { |
|
|
|
|
//批量导入销售区域处理 |
|
|
|
|
$region = []; |
|
|
|
|
$region_text = []; |
|
|
|
|
if ($original["J"]) { |
|
|
|
|
$sale_areas = $original["J"] ? explode("、", $original["J"]) : []; |
|
|
|
|
$cityNames = []; |
|
|
|
|
foreach ($sale_areas as $value) { |
|
|
|
|
$regions = Region::whereIn('name', explode(".", $value))->select()->toArray(); |
|
|
|
|
$regions = array_column($regions, null, "level"); |
|
|
|
|
$arr[] = $regions[1]['id'].".".$regions[2]['id']; |
|
|
|
|
list($province, $city) = explode(".", $value); |
|
|
|
|
$cityNames[] = $city; |
|
|
|
|
} |
|
|
|
|
$regions = Region::whereIn('name', $cityNames)->select()->toArray(); |
|
|
|
|
$regionsnew = []; |
|
|
|
|
foreach ($regions as $key => $value) { |
|
|
|
|
$regionsnew[$value['pid']][] = $value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($regionsnew as $pid => $value) { |
|
|
|
|
$privince = Region::where('id', $pid)->find(); |
|
|
|
|
$region_text[$pid]['name'] = $privince['name'] ?? ""; |
|
|
|
|
$citys = []; |
|
|
|
|
|
|
|
|
|
foreach ($value as $val) { |
|
|
|
|
$region[] = $val['id']; |
|
|
|
|
$citys[] = ['name' => $val['name']]; |
|
|
|
|
} |
|
|
|
|
$region_text[$pid]['citys'] = $citys; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -225,9 +244,9 @@ class AdminImport extends BaseService |
|
|
|
|
'goods_type' => 10,//实物 |
|
|
|
|
'goods_status' => 10,//上架 |
|
|
|
|
'store_id' => $storeId, |
|
|
|
|
'sale_areas' => $arr ? implode("、", $arr) : "", |
|
|
|
|
'region' => $arr ? implode("、", $arr) : "", |
|
|
|
|
'region_text' => $arr ? implode("、", $arr) : "", |
|
|
|
|
//'sale_areas' => $arr ? implode("、", $arr) : "", |
|
|
|
|
'region' => $region ? json_encode($region) : "", |
|
|
|
|
'region_text' => $region_text ? json_encode(array_values($region_text)) : "", |
|
|
|
|
'import' => 1,//是否是导入采集 |
|
|
|
|
]; |
|
|
|
|
// echo "<pre>"; |
|
|
|
|