|
@ -36,8 +36,8 @@ class ShopManager |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param $expressAreaModel |
|
|
|
|
|
* @param $expressTemplateModel |
|
|
|
|
|
|
|
|
* @param ExpressArea|$expressAreaModel |
|
|
|
|
|
* @param ExpressTemplate|$expressTemplateModel |
|
|
* 区域运费模板按比例转化数据 |
|
|
* 区域运费模板按比例转化数据 |
|
|
*/ |
|
|
*/ |
|
|
public static function expressAreaScaleDate($expressAreaModel, $expressTemplateModel) |
|
|
public static function expressAreaScaleDate($expressAreaModel, $expressTemplateModel) |
|
@ -54,22 +54,33 @@ class ShopManager |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param $expressAresModel |
|
|
|
|
|
|
|
|
* @param ExpressArea|$expressAreaModel |
|
|
* @return array |
|
|
* @return array |
|
|
* 除去已被选取的城市,筛选剩下的城市数据 |
|
|
* 除去已被选取的城市,筛选剩下的城市数据 |
|
|
*/ |
|
|
*/ |
|
|
public static function filterCity($expressAresModel) |
|
|
|
|
|
|
|
|
public static function filterCity($expressAreaModel) |
|
|
{ |
|
|
{ |
|
|
$data = []; |
|
|
|
|
|
$query = ExpressArea::find() |
|
|
$query = ExpressArea::find() |
|
|
->select(['city']) |
|
|
->select(['city']) |
|
|
->where(['express_template' => $expressAresModel->express_template]); |
|
|
|
|
|
if ($expressAresModel->id) { //修改操作时,除去自身的城市
|
|
|
|
|
|
$query = $query->andWhere(['!=', 'id', $expressAresModel->id]); |
|
|
|
|
|
|
|
|
->where(['express_template' => $expressAreaModel->express_template]); |
|
|
|
|
|
if ($expressAreaModel->id) { //修改操作时,除去自身的城市
|
|
|
|
|
|
$query = $query->andWhere(['!=', 'id', $expressAreaModel->id]); |
|
|
} |
|
|
} |
|
|
$expressAreas = $query->all(); |
|
|
|
|
|
|
|
|
$allDate = $query->all(); |
|
|
|
|
|
|
|
|
|
|
|
$expressAresCityIdArr = self::filterSelectedCtiyIdArr($allDate); |
|
|
|
|
|
|
|
|
|
|
|
$leftoverCityArr = self::filterLeftoverCityArr($expressAresCityIdArr); |
|
|
|
|
|
return $leftoverCityArr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//获取已选的城市id数组
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param $expressAreas |
|
|
|
|
|
* @return array 已选的城市id数组 |
|
|
|
|
|
* 获取已选的城市id数组 |
|
|
|
|
|
*/ |
|
|
|
|
|
private static function filterSelectedCtiyIdArr($expressAreas) |
|
|
|
|
|
{ |
|
|
$expressAresCityIdArr = []; |
|
|
$expressAresCityIdArr = []; |
|
|
if ($expressAreas) { |
|
|
if ($expressAreas) { |
|
|
foreach ($expressAreas as $expressAreaCity) { |
|
|
foreach ($expressAreas as $expressAreaCity) { |
|
@ -77,23 +88,31 @@ class ShopManager |
|
|
$expressAresCityIdArr = array_unique(array_merge($cityIdArr, $expressAresCityIdArr)); |
|
|
$expressAresCityIdArr = array_unique(array_merge($cityIdArr, $expressAresCityIdArr)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return $expressAresCityIdArr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//筛选剩下的城市
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param $expressAresCityIdArr |
|
|
|
|
|
* @return array 未选的城市id数组 |
|
|
|
|
|
* 筛选剩下的城市 |
|
|
|
|
|
*/ |
|
|
|
|
|
private static function filterLeftoverCityArr($expressAresCityIdArr) |
|
|
|
|
|
{ |
|
|
|
|
|
$data = []; |
|
|
$provinces = Province::find()->cache(0)->all(); |
|
|
$provinces = Province::find()->cache(0)->all(); |
|
|
$j = 0; |
|
|
|
|
|
foreach ($provinces as $k => $v) { |
|
|
|
|
|
|
|
|
foreach ($provinces as $key => $province) { |
|
|
$cities = City::find() |
|
|
$cities = City::find() |
|
|
->where(['province_id' => $v->province_id]) |
|
|
|
|
|
|
|
|
->where(['province_id' => $province->province_id]) |
|
|
->andWhere(['not in', 'city_id', $expressAresCityIdArr]) |
|
|
->andWhere(['not in', 'city_id', $expressAresCityIdArr]) |
|
|
->all(); |
|
|
->all(); |
|
|
|
|
|
|
|
|
if ($cities) { |
|
|
if ($cities) { |
|
|
$data[$j]['province'] = $v->name; |
|
|
|
|
|
|
|
|
$data[$key]['province'] = $province->name; |
|
|
foreach ($cities as $city) { |
|
|
foreach ($cities as $city) { |
|
|
$data[$j]['city'][] = ['id' => $city->city_id, 'name' => $city->name]; |
|
|
|
|
|
|
|
|
$data[$key]['city'][] = ['id' => $city->city_id, 'name' => $city->name]; |
|
|
} |
|
|
} |
|
|
$j++; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return $data; |
|
|
|
|
|
|
|
|
return array_values($data); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |