Commit 00f53dcf by 吕明尚

修改订单价格计算中月卡计算

parent e812c717
...@@ -2664,15 +2664,13 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2664,15 +2664,13 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
ConsumerMember consumerMember = null; ConsumerMember consumerMember = null;
ConsumerWallet consumerWallet = null; ConsumerWallet consumerWallet = null;
ConsumerMonthlyCard consumerMonthlyCard = null; ConsumerMonthlyCard consumerMonthlyCard = null;
List<ConsumerSecondaryCard> consumerSecondaryCardList = null; ConsumerSecondaryCard consumerSecondaryCard = null;
LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(user)) { if (ObjectUtil.isNotEmpty(user)) {
consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId())); consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId())); consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
consumerMonthlyCard = consumerMonthlyCardService.getOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getConsumerId, user.getId())); consumerMonthlyCard = consumerMonthlyCardService.getOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getId, request.getMonthlyCardId()));
consumerSecondaryCardList = consumerSecondaryCardService.list(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getConsumerId, user.getId()) consumerSecondaryCard = consumerSecondaryCardService.getOne(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getId, request.getSecondaryCardId()));
.ne(ConsumerSecondaryCard::getNumber, YesNoEnum.no.getIndex())
);
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex()); queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex());
// if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) { // if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
...@@ -2711,6 +2709,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2711,6 +2709,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.TIME.getCode()); request.setBuyType(BuyTypeEnum.TIME.getCode());
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room, consumerMember);
} else {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId()); queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper); activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember); totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
...@@ -2721,9 +2722,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2721,9 +2722,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(priceResponse.getDiscount()); priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
} }
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room);
} }
} else { } else {
SPack byId = packService.getById(roomLabel.getPackId()); SPack byId = packService.getById(roomLabel.getPackId());
if (!ObjectUtils.isEmpty(byId) && byId.getIsOpen().equals(YesNoEnum.yes.getIndex())) { if (!ObjectUtils.isEmpty(byId) && byId.getIsOpen().equals(YesNoEnum.yes.getIndex())) {
...@@ -2732,6 +2732,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2732,6 +2732,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.PACK.getCode()); request.setBuyType(BuyTypeEnum.PACK.getCode());
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
if (ObjectUtil.isNotEmpty(consumerSecondaryCard)) {
totalFee = getBigDecimal(consumerSecondaryCard, priceResponse, byId, payPrice);
} else {
queryWrapper.eq(Activity::getPackId, roomLabel.getPackId()); queryWrapper.eq(Activity::getPackId, roomLabel.getPackId());
activity = activityService.getOne(queryWrapper); activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember); totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
...@@ -2741,9 +2744,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2741,9 +2744,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(priceResponse.getDiscount()); priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
} }
if (CollectionUtils.isNotEmpty(consumerSecondaryCardList)) {
totalFee = getBigDecimal(consumerSecondaryCardList, priceResponse, byId, payPrice);
} }
// if(ObjectUtil.isNotEmpty(consumerMonthlyCard)){ // if(ObjectUtil.isNotEmpty(consumerMonthlyCard)){
// totalFee = getBigDecimal(consumerMonthlyCard,timeLong,priceResponse,totalFee,room); // totalFee = getBigDecimal(consumerMonthlyCard,timeLong,priceResponse,totalFee,room);
// } // }
...@@ -2755,6 +2757,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2755,6 +2757,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.TIME.getCode()); request.setBuyType(BuyTypeEnum.TIME.getCode());
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room, consumerMember);
} else {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId()); queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper); activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember); totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
...@@ -2764,8 +2769,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2764,8 +2769,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(priceResponse.getDiscount()); priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
} }
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room);
} }
// totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room); // totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room);
...@@ -2778,6 +2781,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2778,6 +2781,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.PACK.getCode()); request.setBuyType(BuyTypeEnum.PACK.getCode());
if (ObjectUtil.isNotEmpty(consumerMember)) { if (ObjectUtil.isNotEmpty(consumerMember)) {
if (ObjectUtil.isNotEmpty(consumerSecondaryCard)) {
totalFee = getBigDecimal(consumerSecondaryCard, priceResponse, byId, payPrice);
} else {
queryWrapper.eq(Activity::getPackId, request.getPackId()); queryWrapper.eq(Activity::getPackId, request.getPackId());
activity = activityService.getOne(queryWrapper); activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember); totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
...@@ -2787,10 +2793,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2787,10 +2793,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(priceResponse.getDiscount()); priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
} }
if (CollectionUtils.isNotEmpty(consumerSecondaryCardList)) {
totalFee = getBigDecimal(consumerSecondaryCardList, priceResponse, byId, payPrice);
} }
} }
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
if (ObjectUtil.isEmpty(consumerWallet) && totalFee.compareTo(new BigDecimal(0)) == 0) { if (ObjectUtil.isEmpty(consumerWallet) && totalFee.compareTo(new BigDecimal(0)) == 0) {
...@@ -3121,7 +3124,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -3121,7 +3124,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} }
private BigDecimal getBigDecimal(ConsumerMonthlyCard consumerMonthlyCard, BigDecimal timeLong, private BigDecimal getBigDecimal(ConsumerMonthlyCard consumerMonthlyCard, BigDecimal timeLong,
ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room) { ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room, ConsumerMember consumerMember) {
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
priceResponse.setDiscountRatio(memberConfig.getDiscountRatio());
priceResponse.setTotalFee(totalFee);
if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) >= 0) { if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) >= 0) {
priceResponse.setDuration(timeLong); priceResponse.setDuration(timeLong);
priceResponse.setRemainingDuration(consumerMonthlyCard.getFreeDuration().subtract(timeLong)); priceResponse.setRemainingDuration(consumerMonthlyCard.getFreeDuration().subtract(timeLong));
...@@ -3138,21 +3144,22 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -3138,21 +3144,22 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
remainingBalance = totalFee.subtract(remainingBalance); remainingBalance = totalFee.subtract(remainingBalance);
priceResponse.setTotalFeeNow(remainingBalance); priceResponse.setTotalFeeNow(remainingBalance);
priceResponse.setMemberDiscount(totalFee.subtract(remainingBalance)); priceResponse.setMemberDiscount(totalFee.subtract(remainingBalance));
totalFee = remainingBalance; totalFee = remainingBalance.multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100));
;
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setPayFee(remainingBalance); priceResponse.setPayFee(remainingBalance);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId()); priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
priceResponse.setMemberDiscount(remainingBalance.subtract(totalFee));
} }
return totalFee; return totalFee;
} }
private BigDecimal getBigDecimal(List<ConsumerSecondaryCard> consumerSecondaryCardList, private BigDecimal getBigDecimal(ConsumerSecondaryCard consumerSecondaryCard,
ComputedOrderPriceResponse priceResponse, SPack byId, BigDecimal payPrice) { ComputedOrderPriceResponse priceResponse, SPack byId, BigDecimal payPrice) {
//获取集合中次数最少的次卡,次数不低于0
ConsumerSecondaryCard consumerSecondaryCard = consumerSecondaryCardList.stream().min(Comparator.comparing(ConsumerSecondaryCard::getNumber)).get();
if (consumerSecondaryCard.getPackId().equals(byId.getId())) { if (consumerSecondaryCard.getPackId().equals(byId.getId())) {
priceResponse.setDiscount(BigDecimal.ZERO); priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO); priceResponse.setMemberDiscount(BigDecimal.ZERO);
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(BigDecimal.ZERO);
priceResponse.setPayFee(BigDecimal.ZERO); priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setSecondaryCardId(consumerSecondaryCard.getId()); priceResponse.setSecondaryCardId(consumerSecondaryCard.getId());
payPrice = BigDecimal.ZERO; payPrice = BigDecimal.ZERO;
......
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