update 计算订单会员折扣逻辑

This commit is contained in:
2024-01-11 17:28:45 +08:00
parent e71ddfb2c8
commit ed47e1e1e0
4 changed files with 38 additions and 53 deletions

View File

@@ -584,13 +584,19 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
Map<String, List<OrderPayRecord>> payRecordMap = payRecordList.stream().collect(Collectors.groupingBy(OrderPayRecord::getPayMode));
// 获取本金支付的记录
List<OrderPayRecord> principalPayRecordList = payRecordMap.get(OrderPayRecordEnum.PRINCIPAL_BALANCE_PAYMENT.getValue());
BigDecimal principalPay = principalPayRecordList.stream().map(OrderPayRecord::getPayAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal principalPay = null;
if (CollectionUtils.isNotEmpty(principalPayRecordList)) {
principalPay = principalPayRecordList.stream().map(OrderPayRecord::getPayAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
}
// 获取赠送金支付的记录
List<OrderPayRecord> giftPayRecordList = payRecordMap.get(OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue());
BigDecimal giftPay = giftPayRecordList.stream().map(OrderPayRecord::getPayAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal giftPay = null;
if (CollectionUtils.isNotEmpty(giftPayRecordList)) {
giftPay = giftPayRecordList.stream().map(OrderPayRecord::getPayAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
}
// 计算需要退回的金额
Map<String, BigDecimal> returnAmountMap = calculateReturnAmount(principalPay, giftPay, orderAmount);
Map<String, BigDecimal> returnAmountMap = calculateReturnAmount(principalPay, giftPay, orderAmount, orderBasicInfo.getDiscountAmount());
logger.info("结算订单:{}, 剩余金额退回余额, 订单消费金额:{}, 本金支付金额:{}, 赠送支付金额:{}, 退回金额map:{}",
orderCode, orderAmount, principalPay, null, JSONObject.toJSONString(returnAmountMap));