|
@ -2,6 +2,8 @@ |
|
|
|
|
|
|
|
|
namespace backend\modules\shop\models\searchs; |
|
|
namespace backend\modules\shop\models\searchs; |
|
|
|
|
|
|
|
|
|
|
|
use backend\modules\shop\models\ars\City; |
|
|
|
|
|
use backend\modules\shop\models\ars\Province; |
|
|
use yii\base\Model; |
|
|
use yii\base\Model; |
|
|
use yii\data\ActiveDataProvider; |
|
|
use yii\data\ActiveDataProvider; |
|
|
use yii\helpers\ArrayHelper; |
|
|
use yii\helpers\ArrayHelper; |
|
@ -57,12 +59,24 @@ class ExpressAreaSearch extends ExpressArea |
|
|
'id', |
|
|
'id', |
|
|
['attribute' => 'city', |
|
|
['attribute' => 'city', |
|
|
'value' => function ($model) { |
|
|
'value' => function ($model) { |
|
|
$array = explode(',', $model->city); |
|
|
|
|
|
|
|
|
$expressAreas = ExpressArea::findOne($model->id); |
|
|
|
|
|
$expressAresCityIdArr = explode(',', $expressAreas->city); |
|
|
$cities = []; |
|
|
$cities = []; |
|
|
foreach (\backend\modules\shop\models\ars\City::find()->andWhere(['in', 'city_id', $array])->all() as $city) { |
|
|
|
|
|
$cities[] = $city->name; |
|
|
|
|
|
|
|
|
$provinces = Province::find()->cache(0)->all(); |
|
|
|
|
|
foreach ($provinces as $k => $v) { |
|
|
|
|
|
$cityId = City::find() |
|
|
|
|
|
->select(['city_id']) |
|
|
|
|
|
->where(['province_id' => $v->province_id]) |
|
|
|
|
|
->column(); |
|
|
|
|
|
if (empty(array_diff($cityId, $expressAresCityIdArr))) { |
|
|
|
|
|
$cities[] = $v->name; |
|
|
|
|
|
}else{ |
|
|
|
|
|
foreach (\backend\modules\shop\models\ars\City::find()->andWhere(['in', 'city_id', array_diff($cityId, array_diff($cityId, $expressAresCityIdArr))])->all() as $city) { |
|
|
|
|
|
$cities[] = $city->name; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return implode(' // ', $cities); |
|
|
|
|
|
|
|
|
return implode(' , ', $cities); |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
|
[ |
|
|
[ |
|
|