|
@ -308,4 +308,59 @@ class ExpressTemplateController extends Controller |
|
|
'expressTemplateModel' => $expressTemplateModel |
|
|
'expressTemplateModel' => $expressTemplateModel |
|
|
]); |
|
|
]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @return array|mixed|string|Response |
|
|
|
|
|
* 运费区域模板区域更新方法 |
|
|
|
|
|
*/ |
|
|
|
|
|
public function actionExpressAreaUpdate($id) |
|
|
|
|
|
{ |
|
|
|
|
|
$expressTemplateId = Yii::$app->request->get('expressTemplateId'); |
|
|
|
|
|
$expressTemplateModel = ExpressTemplate::findOne($expressTemplateId); |
|
|
|
|
|
$model = ExpressArea::findOne($id); |
|
|
|
|
|
$model->basic_price /= 100; |
|
|
|
|
|
$model->extra_price /= 100; |
|
|
|
|
|
if ($expressTemplateModel->calculation_type == ExpressTemplate::CALCULATION_TYPE_WEIGHT) { |
|
|
|
|
|
$model->basic_count /= 10; |
|
|
|
|
|
$model->extra_count /= 10; |
|
|
|
|
|
} |
|
|
|
|
|
$data = Yii::$app->request->post('ExpressArea'); |
|
|
|
|
|
if ($data) { |
|
|
|
|
|
if (Yii::$app->request->post('area') == null) { |
|
|
|
|
|
return $this->redirect(Yii::$app->request->referrer . '&status=1'); |
|
|
|
|
|
} |
|
|
|
|
|
$cityIds = array_keys(Yii::$app->request->post('area')); |
|
|
|
|
|
$data['city'] = implode(',', $cityIds); |
|
|
|
|
|
$model->load($data, ''); |
|
|
|
|
|
$model->save(); |
|
|
|
|
|
return $this->redirect('express-area-list?id='.$model->express_template); |
|
|
|
|
|
} |
|
|
|
|
|
$data = []; |
|
|
|
|
|
$expressAreas = ExpressArea::find()->select(['city'])->where(['express_template' => $expressTemplateModel->id])->andWhere(['!=', 'id', $id])->all(); |
|
|
|
|
|
$expressAresCityIdArr = []; |
|
|
|
|
|
if ($expressAreas) { |
|
|
|
|
|
foreach ($expressAreas as $expressAreaCity) { |
|
|
|
|
|
$cityIdArr = explode(',', $expressAreaCity->city); |
|
|
|
|
|
$expressAresCityIdArr = array_unique(array_merge($cityIdArr, $expressAresCityIdArr)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
$provinces = Province::find()->cache(0)->all(); |
|
|
|
|
|
$j = 0; |
|
|
|
|
|
foreach ($provinces as $k => $v) { |
|
|
|
|
|
$cities = City::find() |
|
|
|
|
|
->where(['province_id' => $v->province_id]) |
|
|
|
|
|
->andWhere(['not in', 'city_id', $expressAresCityIdArr]) |
|
|
|
|
|
->all(); |
|
|
|
|
|
if ($cities) { |
|
|
|
|
|
$data[$j]['province'] = $v->name; |
|
|
|
|
|
foreach ($cities as $city) { |
|
|
|
|
|
$data[$j]['city'][] = ['id' => $city->city_id, 'name' => $city->name]; |
|
|
|
|
|
} |
|
|
|
|
|
$j++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return $this->render('express_area_update', [ |
|
|
|
|
|
'model' => $model, 'data' => $data, 'cities' => explode(',', $model->city), 'expressTemplateModel' => $expressTemplateModel |
|
|
|
|
|
]); |
|
|
|
|
|
} |
|
|
} |
|
|
} |