修复:体积重 重量单位未转换导致运费计算错误

添加:多个物流时 按照物流费用排序
This commit is contained in:
wuhui_zzw 2023-10-12 14:35:31 +08:00
parent 71f1c85492
commit 698f5166f4
3 changed files with 13 additions and 6 deletions

View File

@ -200,11 +200,17 @@ class ProductController extends Controller
$totals = $this->computeOrderMoney($request);
$shipping = array_column($totals['data'],null,'code')['shipping'] ?? [];
// $logisticsItem['shipping_fee'] = $shipping['show_tips'] == 0 ? $shipping['amount_format'] : trans('shop/carts.to_be_negotiated');
if($shipping['show_tips'] == 0) $logisticsItem['shipping_fee'] = $shipping['amount_format'];
else $logisticsItem = [];
if($shipping['show_tips'] == 0) {
$logisticsItem['shipping_fee'] = $shipping['amount_format'];
$logisticsItem['amount'] = $shipping['amount'];
}else $logisticsItem = [];
}
}
// 存在多个物流 根据物流费用进行排序
if(count($data['list']) > 1){
$amounts = array_column($data['list'],'amount');
if($amounts) array_multisort($amounts,SORT_ASC,$data['list']);
}
$data['list'] = array_filter($data['list']);
return json_success(trans('common.success'),$data);

View File

@ -198,6 +198,7 @@ class ShippingService{
foreach(self::$productsList as $productInfo){
// 计算体积重 并且取数值大的作为重量计算
$volumeWeight = $productInfo['volume_weight'] / $logisticsInfo['throwing_ratio'];
$volumeWeight = (float)sprintf("%.2f",Weight::convert($volumeWeight,$productInfo['weight_class']));
$sumWeight = $productInfo['sum_weight'] > $volumeWeight ? $productInfo['sum_weight'] : $volumeWeight;
// 首重运费
$amount += (float)sprintf("%.2f",$firstWeightFee);

View File

@ -233,10 +233,10 @@
<div class="price-wrap d-flex align-items-end sku-price-wrap" v-if="price_setting === 'sku'">
<div class="sku-price-wrap-content fs-3">
<span>{{ $product['trade_term'] ?? 'DAP'}}<i class="bi bi-question-circle" id="tradeTerm" style="font-size: 15px;"></i></span>
@{{ product.price_format }}
<span v-if="product.price != product.origin_price && product.origin_price !== 0"> - @{{ product.origin_price_format }}</span>
<span class="fw-bold">@{{ product.price_format }}</span>
<span v-if="product.price != product.origin_price && product.origin_price !== 0" class="fw-bold"> - @{{ product.origin_price_format }}</span>
@if($product['unit'])
<span>/ {{explode('/',$product['unit'])[0]}}</span>
<span style="font-weight: 700 !important;">/ {{explode('/',$product['unit'])[0]}}</span>
@endif
<span v-if="minimum_order > 0" style="font-size: 18px;">
@if($product['sales_method'] == 'piece')