|
@@ -70,58 +70,63 @@ class FreightLogic extends BaseLogic
|
|
|
$templateList[$good['express_template_id']][] = $good;
|
|
$templateList[$good['express_template_id']][] = $good;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- foreach ($templateList as $templateId => $templateGoods) {
|
|
|
|
|
-
|
|
|
|
|
- $freight = FreightLogic::getFreightsByAddress($templateId, $userAddress);
|
|
|
|
|
-
|
|
|
|
|
- if (empty($freight)) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- switch ($freight['charge_way']) {
|
|
|
|
|
- // 件数
|
|
|
|
|
- case FreightEnum::CHARGE_WAY_PIECE:
|
|
|
|
|
- $nums = array_sum(array_column($templateGoods, 'goods_num'));
|
|
|
|
|
- $real_count_field = 'goods_num';
|
|
|
|
|
- break;
|
|
|
|
|
- // 重量
|
|
|
|
|
- case FreightEnum::CHARGE_WAY_WEIGHT:
|
|
|
|
|
- $nums = array_sum(array_column($templateGoods, 'total_weight'));
|
|
|
|
|
- $real_count_field = 'total_weight';
|
|
|
|
|
- break;
|
|
|
|
|
- // 体积
|
|
|
|
|
- case FreightEnum::CHARGE_WAY_VOLUME:
|
|
|
|
|
- $nums = array_sum(array_column($templateGoods, 'total_volume'));
|
|
|
|
|
- $real_count_field = 'total_volume';
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- continue 2;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 计算运费
|
|
|
|
|
- if ($nums > $freight['first_unit'] && $freight['continue_unit'] > 0) {
|
|
|
|
|
- $left = ceil(($nums - $freight['first_unit']) / $freight['continue_unit']);
|
|
|
|
|
- $this_express_money = $freight['first_money'] + $left * $freight['continue_money'];
|
|
|
|
|
- } else {
|
|
|
|
|
- $this_express_money = $freight['first_money'];
|
|
|
|
|
|
|
+ $area_flag = ConfigService::get('shop', 'area_flag');
|
|
|
|
|
+ if($area_flag == 1){
|
|
|
|
|
+ $expressPrice +=22;
|
|
|
|
|
+ }else {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($templateList as $templateId => $templateGoods) {
|
|
|
|
|
+
|
|
|
|
|
+ $freight = FreightLogic::getFreightsByAddress($templateId, $userAddress);
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($freight)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ switch ($freight['charge_way']) {
|
|
|
|
|
+ // 件数
|
|
|
|
|
+ case FreightEnum::CHARGE_WAY_PIECE:
|
|
|
|
|
+ $nums = array_sum(array_column($templateGoods, 'goods_num'));
|
|
|
|
|
+ $real_count_field = 'goods_num';
|
|
|
|
|
+ break;
|
|
|
|
|
+ // 重量
|
|
|
|
|
+ case FreightEnum::CHARGE_WAY_WEIGHT:
|
|
|
|
|
+ $nums = array_sum(array_column($templateGoods, 'total_weight'));
|
|
|
|
|
+ $real_count_field = 'total_weight';
|
|
|
|
|
+ break;
|
|
|
|
|
+ // 体积
|
|
|
|
|
+ case FreightEnum::CHARGE_WAY_VOLUME:
|
|
|
|
|
+ $nums = array_sum(array_column($templateGoods, 'total_volume'));
|
|
|
|
|
+ $real_count_field = 'total_volume';
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ continue 2;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 计算运费
|
|
|
|
|
+ if ($nums > $freight['first_unit'] && $freight['continue_unit'] > 0) {
|
|
|
|
|
+ $left = ceil(($nums - $freight['first_unit']) / $freight['continue_unit']);
|
|
|
|
|
+ $this_express_money = $freight['first_money'] + $left * $freight['continue_money'];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $this_express_money = $freight['first_money'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 计算每个商品 所占运费金额
|
|
|
|
|
+ $goods_moneys = static::array_proportion($this_express_money, array_column($templateGoods, $real_count_field), 2, 'end');
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($templateGoods as $ko => $templateGood) {
|
|
|
|
|
+ $goodsExpressMoneys[$templateGood['id']] = $goods_moneys['gets'][$ko] ?? 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 总的运费
|
|
|
|
|
+ $expressPrice += $this_express_money;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 计算每个商品 所占运费金额
|
|
|
|
|
- $goods_moneys = static::array_proportion($this_express_money, array_column($templateGoods, $real_count_field), 2, 'end');
|
|
|
|
|
-
|
|
|
|
|
- foreach ($templateGoods as $ko => $templateGood) {
|
|
|
|
|
- $goodsExpressMoneys[$templateGood['id']] = $goods_moneys['gets'][$ko] ?? 0;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($goods as &$good) {
|
|
|
|
|
+ $good['express_price'] = $goodsExpressMoneys[$good['id']] ?? $good['express_price'] ?? 0;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 总的运费
|
|
|
|
|
- $expressPrice += $this_express_money;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- foreach ($goods as &$good) {
|
|
|
|
|
- $good['express_price'] = $goodsExpressMoneys[$good['id']] ?? $good['express_price'] ?? 0;
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return [ 'goods' => $goods, 'express_price' => $expressPrice ];
|
|
return [ 'goods' => $goods, 'express_price' => $expressPrice ];
|
|
|
}
|
|
}
|
|
|
|
|
|