|
@@ -462,18 +462,21 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
|
//目前逻辑为一个边民订单只有一个商品
|
|
|
GoodsDto goods = levelOneServerInterface.getByGoodsId(orderDto.getGoodsId());
|
|
|
List<TbItemRules> newRuleList = ruleList.stream().filter(rule -> rule.getGoodsCodes().contains(goods.getCode())).collect(Collectors.toList());
|
|
|
- AtomicReference<Float> sum= new AtomicReference<>(0.00F);
|
|
|
- newRuleList.forEach(ruleItem -> {
|
|
|
+ BigDecimal chargesPrice = BigDecimal.ZERO;
|
|
|
+ BigDecimal TotalPrice = new BigDecimal(orderDto.getTotalPrice());
|
|
|
+ BigDecimal GrossWt = new BigDecimal(orderDto.getGrossWt());
|
|
|
+ for (TbItemRules ruleItem : newRuleList) {
|
|
|
+ BigDecimal Percent = new BigDecimal(ruleItem.getPercent());
|
|
|
//类型(1=按交易额收取,2=按次收取,3=按吨)
|
|
|
- if("1".equals(ruleItem.getFeeType())) {
|
|
|
- sum.updateAndGet(v -> new Float((float) (v + (orderDto.getTotalPrice() * ruleItem.getPercent()/100) )));
|
|
|
- } else if("2".equals(ruleItem.getFeeType())) {
|
|
|
- sum.updateAndGet(v -> new Float((float) (v + ruleItem.getFeeMoney().doubleValue() )));
|
|
|
- } else if("3".equals(ruleItem.getFeeType())) {
|
|
|
- sum.updateAndGet(v -> new Float((float) (v + (orderDto.getTotalPrice() * ruleItem.getPercent() /100) )));
|
|
|
+ if ("1".equals(ruleItem.getFeeType())) {
|
|
|
+ chargesPrice = chargesPrice.add(TotalPrice.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));//保留两位小数,四舍五入
|
|
|
+ } else if ("2".equals(ruleItem.getFeeType())) {
|
|
|
+ chargesPrice = chargesPrice.add(ruleItem.getFeeMoney());
|
|
|
+ } else if ("3".equals(ruleItem.getFeeType())) {
|
|
|
+ chargesPrice = chargesPrice.add(GrossWt.multiply(Percent).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));//保留两位小数,四舍五入
|
|
|
}
|
|
|
- });
|
|
|
- Double sumPrice = sum.get() + orderDto.getTotalPrice() + 50;//50为边民利润,暂时写死
|
|
|
+ }
|
|
|
+ Double sumPrice = chargesPrice.add(TotalPrice).doubleValue();
|
|
|
return sumPrice;
|
|
|
}
|
|
|
|