diff --git a/api/logic/ExpressLogic.php b/api/logic/ExpressLogic.php index feb0180..f898c3b 100644 --- a/api/logic/ExpressLogic.php +++ b/api/logic/ExpressLogic.php @@ -40,7 +40,7 @@ class ExpressLogic extends BaseObject $this->order = $order; $allGoods = $this->findDifferentExpressTypeGoods($order);/*获取不同运费计算模式的商品*/ $uniformPostage = $this->countGoodsExpress($allGoods['uniformPostageGoods'], Goods::EXPRESS_TYPE_UNIFORM_POSTAGE);/*计算统一运费模式下所有商品运费*/ - $expressTemplate = $this->countGoodsExpress($allGoods['uniformPostageGoods'], Goods::EXPRESS_TYPE_UNIFORM_POSTATE);/*计算运费模板模式下所有商品的运费*/ + $expressTemplate = $this->countGoodsExpress($allGoods['uniformPostageGoods'], Goods::EXPRESS_TYPE_EXPRESS_TEMPLATE);/*计算运费模板模式下所有商品的运费*/ return $uniformPostage > $expressTemplate ? $uniformPostage : $expressTemplate;/*比较两种不同运费计算模式下,取金额大的值为最终收取运费*/ } @@ -49,7 +49,7 @@ class ExpressLogic extends BaseObject * @param $order * @return array * @throws NotFoundHttpException - * + * 获取不同运费计算模式的商品 */ private function findDifferentExpressTypeGoods($order) { @@ -78,6 +78,7 @@ class ExpressLogic extends BaseObject * @param $type * @return float|int * @throws NotFoundHttpException + * 根据不同计费模式计算商品运费 */ private function countGoodsExpress($allGoods, $type) { @@ -91,10 +92,12 @@ class ExpressLogic extends BaseObject $extraPrice = 0; $areasIds = []; foreach ($allGoods['object'] as $k => $goods) { + /*计算增重运费*/ $extraPrice += $this->countExtraAmount($allGoods['count'][$k], $allGoods['weight'][$k], $goods->express_template); $areasIds[] = $this->getAreaId($goods->express_template); } - $basic = $this->getBasicPriceAndAreaId($areasIds); + $basic = $this->getBasicPriceAndAreaId($areasIds);/*获取首重运费和对应的计费规则id*/ + /*返回所有按运费模板计费的商品运费(基础运费 + 所有商品增重运费 - 多余的增重运费)*/ return $basic['price'] + $extraPrice - $this->countSurplusPrice($basic['id']); } } @@ -104,7 +107,7 @@ class ExpressLogic extends BaseObject * @return float|int * @throws NotFoundHttpException * 计算多余(多算的)运费 - * 选定的作为基础运费的计费规则的对应商品基础数量内的扩展费用 + * 选定作为基础运费的计费规则对应商品基础数量内的增重费用 */ private function countSurplusPrice($areaId) { @@ -138,7 +141,7 @@ class ExpressLogic extends BaseObject * @param $templateId * @return float|int * @throws NotFoundHttpException - * 计算扩展运费 + * 计算增重运费 */ private function countExtraAmount($count, $weight, $templateId) { diff --git a/backend/modules/shop/models/ars/Order.php b/backend/modules/shop/models/ars/Order.php index e5e2af3..f6ae050 100755 --- a/backend/modules/shop/models/ars/Order.php +++ b/backend/modules/shop/models/ars/Order.php @@ -1,8 +1,9 @@ status === self::STATUS_UNCONFIRMED && $this->type == self::TYPE_SHOPPING) { - $this->shipping_amount = $this->countShippingAmount(); + $express = Yii::createObject([ + 'class' => 'api\logic\ExpressLogic', + ]); + $this->shipping_amount = $express->countShippingAmount($this); $this->receivables = $this->goods_amount + $this->shipping_amount; $this->payment_amount = $this->receivables - $this->discount_amount; } diff --git a/vendor/iron/grid/GridView.php b/vendor/iron/grid/GridView.php index e1812fa..a26eaef 100644 --- a/vendor/iron/grid/GridView.php +++ b/vendor/iron/grid/GridView.php @@ -263,8 +263,8 @@ HTML;
HTML; @@ -461,8 +461,6 @@ SCRIPT; return $this->renderFilter(); case '{batch}': return $this->renderBatch(); - case '{url}': - return Yii::$app->request->url; case '{export}': return $this->renderExport(); case '{create}':