Commit 31c4f90f by 吕明尚

增加优惠券和余额计算

parent 71a9eee6
......@@ -1960,6 +1960,32 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice);
SConsumerCoupon consumerCoupon = consumerCouponService.getById(request.getCouponId());
computedCouponPrice(request, priceResponse, user, consumerCoupon);
priceResponse.setDuration(new BigDecimal(0));
priceResponse.setRemainingDuration(new BigDecimal(0));
if (priceResponse.getPayFee().compareTo(new BigDecimal(0)) > 0) {
if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) >= 0) {
priceResponse.setBalance(priceResponse.getPayFee());
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(priceResponse.getPayFee()));
totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
totalFee = priceResponse.getPayFee().subtract(consumerWallet.getBalance());
}
priceResponse.setPayFee(totalFee);
if (ObjectUtil.isNotEmpty(consumerMember)) {
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getId, consumerMember.getMemberConfigId()));
//总金额乘以折扣比例除以100
priceResponse.setPayFee(priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100)));
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
priceResponse.setCouponFee(priceResponse.getDiscountFee());
if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
} else {
priceResponse.setDiscountRatio(new BigDecimal(0));
}
}
}
}
}
return priceResponse;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment