BigDecimal 坑
This commit is contained in:
parent
59a79fddf4
commit
4a97513de2
|
|
@ -181,8 +181,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
//总打包费
|
||||
BigDecimal packAmount = BigDecimal.ZERO;
|
||||
//总商品支付金额 不包含打包费 用来计算后续
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
processOrderDetails(orderDetails, packAmount, totalAmount);
|
||||
BigDecimal totalAmount = processOrderDetails(orderDetails, packAmount);
|
||||
log.info("下单2 总金额{} {}", totalAmount, JSONObject.toJSONString(orderDetails));
|
||||
if (packAmount.compareTo(param.getPackFee()) != 0) {
|
||||
throw new ValidateException("生成订单失败,打包费不正确");
|
||||
|
|
@ -409,9 +408,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
*
|
||||
* @param orderDetails 订单详情 需要回填
|
||||
* @param packAmount 打包费
|
||||
* @param totalAmount 最终总金额
|
||||
*/
|
||||
private void processOrderDetails(List<OrderDetail> orderDetails, BigDecimal packAmount, BigDecimal totalAmount) {
|
||||
private BigDecimal processOrderDetails(List<OrderDetail> orderDetails, BigDecimal packAmount) {
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
for (OrderDetail detail : orderDetails) {
|
||||
if (detail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && detail.getPackAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
packAmount = packAmount.add(detail.getPackAmount().multiply(detail.getPackNumber()));
|
||||
|
|
@ -419,6 +418,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
detail.setPayAmount(detail.getNum().multiply(detail.getPrice()));
|
||||
totalAmount = totalAmount.add(detail.getPayAmount());
|
||||
}
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue