This commit is contained in:
wangjinlei
2023-10-26 17:52:54 +08:00
parent 7792024b15
commit c5e6cfdc89
9 changed files with 27 additions and 11 deletions

View File

@@ -313,14 +313,21 @@ public class BuyOrderController {
BigDecimal totalWeight = new BigDecimal(0);
for (ProductRequestVo product : products) {
ShopProduct shopProduct = shopProductService.getById(product.getProductId());
if(shopProduct.getIsFreeMail()==0){
continue;
}
BigDecimal weight = BigDecimal.valueOf(Double.valueOf(shopProduct.getWeight()) / 1000.0);
totalWeight = totalWeight.add(weight.multiply(new BigDecimal(product.getQuantity())));
}
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
QueryWrapper<SysConfigEntity> configQueryWrapper = new QueryWrapper<>();
configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS");
SysConfigEntity config = sysConfigService.getOne(configQueryWrapper);
BigDecimal expressFee = expressFeeService.calculateExpressFee(config.getParamValue(), totalWeight, regionCode);
BigDecimal expressFee = new BigDecimal(0);
if(totalWeight.compareTo(BigDecimal.ZERO)!=0){
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
QueryWrapper<SysConfigEntity> configQueryWrapper = new QueryWrapper<>();
configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS");
SysConfigEntity config = sysConfigService.getOne(configQueryWrapper);
expressFee = expressFeeService.calculateExpressFee(config.getParamValue(), totalWeight, regionCode);
}
return R.ok().put("result", expressFee);
}