From 32d1cc5afeb22f456b88161185b8bed9fbdd9308 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Tue, 10 Dec 2019 15:08:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E4=BD=8D=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/modules/shop/logic/ShopManager.php | 78 ++++++++++++++++++++-- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/backend/modules/shop/logic/ShopManager.php b/backend/modules/shop/logic/ShopManager.php index a463a05..39baa99 100644 --- a/backend/modules/shop/logic/ShopManager.php +++ b/backend/modules/shop/logic/ShopManager.php @@ -1,10 +1,12 @@ basic_price *= self::proportionalConversion(self::UNIT_TYPE_MONEY); + $expressAreaModel->extra_price *= self::proportionalConversion(self::UNIT_TYPE_MONEY); + if ($expressTemplateModel->calculation_type == ExpressTemplate::CALCULATION_TYPE_WEIGHT) { + $expressAreaModel->basic_count *= self::proportionalConversion(self::UNIT_TYPE_WEIGHT); + $expressAreaModel->extra_count *= self::proportionalConversion(self::UNIT_TYPE_WEIGHT); + } else { + $expressAreaModel->basic_count *= self::proportionalConversion(self::UNIT_TYPE_ITEM); + $expressAreaModel->extra_count *= self::proportionalConversion(self::UNIT_TYPE_ITEM); + } + } + + /** + * @param $expressAresModel + * @return array + * 除去已被选取的城市,筛选剩下的城市数据 + */ + public static function filterCity($expressAresModel) + { + $data = []; + $query = ExpressArea::find() + ->select(['city']) + ->where(['express_template' => $expressAresModel->express_template]); + if ($expressAresModel->id) { //修改操作时,除去自身的城市 + $query = $query->andWhere(['!=', 'id', $expressAresModel->id]); + } + $expressAreas = $query->all(); + + //获取已选的城市id数组 + $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 $data; + } } \ No newline at end of file