|
|
@ -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) |
|
|
|
{ |
|
|
|