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