Commit eb323519 by 吕明尚

修改订单计算

parent 2dec1bba
...@@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import share.common.constant.SmsConstants; import share.common.constant.SmsConstants;
import share.common.core.page.TableDataInfo;
import share.common.enums.ConsumerCouponUseStatusEnum; import share.common.enums.ConsumerCouponUseStatusEnum;
import share.common.enums.PositionEnum; import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum; import share.common.enums.RoleTypeEnum;
...@@ -23,9 +22,7 @@ import share.common.utils.BaseUtil; ...@@ -23,9 +22,7 @@ import share.common.utils.BaseUtil;
import share.common.utils.DateUtil; import share.common.utils.DateUtil;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import share.system.domain.*; import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.*;
import share.system.domain.vo.MemberConfigVo;
import share.system.domain.vo.SConsumerVo;
import share.system.mapper.SConsumerMapper; import share.system.mapper.SConsumerMapper;
import share.system.mapper.SStoreConsumerMapper; import share.system.mapper.SStoreConsumerMapper;
import share.system.request.RegisterThirdSConsumerRequest; import share.system.request.RegisterThirdSConsumerRequest;
...@@ -35,7 +32,6 @@ import java.math.BigDecimal; ...@@ -35,7 +32,6 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 会员用户Service业务层处理 * 会员用户Service业务层处理
......
...@@ -2483,39 +2483,39 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2483,39 +2483,39 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscount(BigDecimal.ZERO); priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO); priceResponse.setMemberDiscount(BigDecimal.ZERO);
Activity activity = null; Activity activity = null;
ConsumerMember consumerMember = null; // ConsumerMember consumerMember = null;
ConsumerWallet consumerWallet = null; // ConsumerWallet consumerWallet = null;
ConsumerMonthlyCard consumerMonthlyCard = null; ConsumerMonthlyCard consumerMonthlyCard = null;
List<ConsumerSecondaryCard> consumerSecondaryCardList = null; List<ConsumerSecondaryCard> consumerSecondaryCardList = 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::getConsumerId, user.getId()));
consumerSecondaryCardList = consumerSecondaryCardService.list(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getConsumerId, user.getId()) consumerSecondaryCardList = consumerSecondaryCardService.list(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getConsumerId, user.getId())
.ne(ConsumerSecondaryCard::getNumber, YesNoEnum.no.getIndex()) .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())) {
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex()); //// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex());
//// } else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
//// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex());
//// } else {
//// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex());
//// }
// if (consumerMember.getIsRecharge().equals(YesNoEnum.no.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex());
// } else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
// queryWrapper.in(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex(), MemberTypeEnum.RIGHTS.getIndex());
// } else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) { // } else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
//// activity.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex()); // queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex());
// } else { // } else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRecharge().equals(YesNoEnum.no.getIndex())) {
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex()); //// activity.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex());
// }
// } // }
if (consumerMember.getIsRecharge().equals(YesNoEnum.no.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex());
} else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
queryWrapper.in(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex(), MemberTypeEnum.RIGHTS.getIndex());
} else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
// activity.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex());
} else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRecharge().equals(YesNoEnum.no.getIndex())) {
// activity.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex());
}
}
// if (ObjectUtil.isNotEmpty(consumerWallet)) { // if (ObjectUtil.isNotEmpty(consumerWallet)) {
// priceResponse.setAvailableBalance(consumerWallet.getBalance()); // priceResponse.setAvailableBalance(consumerWallet.getBalance());
// priceResponse.setAvailableDuration(consumerWallet.getRemainingDuration()); // priceResponse.setAvailableDuration(consumerWallet.getRemainingDuration());
...@@ -2532,17 +2532,17 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2532,17 +2532,17 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.TIME.getCode()); request.setBuyType(BuyTypeEnum.TIME.getCode());
if (ObjectUtil.isNotEmpty(consumerMember)) { // if (ObjectUtil.isNotEmpty(consumerMember)) {
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);
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
// priceResponse.setTotalFeeNow(totalFee); // priceResponse.setTotalFeeNow(totalFee);
priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100))); // priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscountRatio(priceResponse.getDiscount()); //// priceResponse.setTotalFeeNow(totalFee);
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember); // priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
} // priceResponse.setDiscountRatio(priceResponse.getDiscount());
// totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
// }
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) { if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room); totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room);
} }
...@@ -2553,16 +2553,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2553,16 +2553,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.PACK.getCode()); request.setBuyType(BuyTypeEnum.PACK.getCode());
if (ObjectUtil.isNotEmpty(consumerMember)) { // if (ObjectUtil.isNotEmpty(consumerMember)) {
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);
priceResponse.setTotalFeeNow(totalFee); // priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee)); // priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100))); // priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
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)) { if (CollectionUtils.isNotEmpty(consumerSecondaryCardList)) {
totalFee = getBigDecimal(consumerSecondaryCardList, priceResponse, byId, payPrice); totalFee = getBigDecimal(consumerSecondaryCardList, priceResponse, byId, payPrice);
} }
...@@ -2576,16 +2576,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2576,16 +2576,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.TIME.getCode()); request.setBuyType(BuyTypeEnum.TIME.getCode());
if (ObjectUtil.isNotEmpty(consumerMember)) { // if (ObjectUtil.isNotEmpty(consumerMember)) {
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);
priceResponse.setTotalFeeNow(totalFee); // priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee)); // priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100))); // priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
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)) { if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room); totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room);
} }
...@@ -2599,15 +2599,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2599,15 +2599,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
priceResponse.setTotalFeeNow(payPrice); priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.PACK.getCode()); request.setBuyType(BuyTypeEnum.PACK.getCode());
if (ObjectUtil.isNotEmpty(consumerMember)) { // if (ObjectUtil.isNotEmpty(consumerMember)) {
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);
priceResponse.setTotalFeeNow(totalFee); // priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee)); // priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100))); // priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request); // totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
} // }
} }
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
...@@ -2645,54 +2645,54 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2645,54 +2645,54 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setRemainingBalance(new BigDecimal(0)); priceResponse.setRemainingBalance(new BigDecimal(0));
priceResponse.setRemainingDuration(new BigDecimal(0)); priceResponse.setRemainingDuration(new BigDecimal(0));
if (priceResponse.getPayFee().compareTo(new BigDecimal(0)) > 0) { if (priceResponse.getPayFee().compareTo(new BigDecimal(0)) > 0) {
if (ObjectUtil.isNotEmpty(consumerWallet) && ObjectUtil.isNotEmpty(consumerMember)) { // if (ObjectUtil.isNotEmpty(consumerWallet) && ObjectUtil.isNotEmpty(consumerMember)) {
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel())); // MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) >= 0) { // if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) >= 0) {
BigDecimal payFee = priceResponse.getPayFee(); // BigDecimal payFee = priceResponse.getPayFee();
BigDecimal divide = priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); // BigDecimal divide = priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
if (payFee.compareTo(divide) == 0) { // if (payFee.compareTo(divide) == 0) {
priceResponse.setDiscount(BigDecimal.ZERO); // priceResponse.setDiscount(BigDecimal.ZERO);
} // }
//总金额乘以折扣比例除以100 // //总金额乘以折扣比例除以100
priceResponse.setPayFee(divide); // priceResponse.setPayFee(divide);
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee())); // priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
priceResponse.setTotalFeeNow(divide); // priceResponse.setTotalFeeNow(divide);
priceResponse.setMemberDiscount(payFee.subtract(divide)); // priceResponse.setMemberDiscount(payFee.subtract(divide));
//
priceResponse.setBalance(priceResponse.getPayFee()); // priceResponse.setBalance(priceResponse.getPayFee());
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(priceResponse.getPayFee())); // priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(priceResponse.getPayFee()));
totalFee = new BigDecimal(0); // totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) < 0) { // } else if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) < 0) {
priceResponse.setBalance(consumerWallet.getBalance()); // priceResponse.setBalance(consumerWallet.getBalance());
totalFee = priceResponse.getPayFee().subtract(consumerWallet.getBalance()); // totalFee = priceResponse.getPayFee().subtract(consumerWallet.getBalance());
} // }
priceResponse.setPayFee(totalFee); // priceResponse.setPayFee(totalFee);
priceResponse.setTotalFeeNow(totalFee); // priceResponse.setTotalFeeNow(totalFee);
if (priceResponse.getPayFee().compareTo(BigDecimal.ZERO) > 0) { // if (priceResponse.getPayFee().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal payFee = priceResponse.getPayFee(); // BigDecimal payFee = priceResponse.getPayFee();
BigDecimal divide = priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); // BigDecimal divide = priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
if (payFee.compareTo(divide) == 0) { // if (payFee.compareTo(divide) == 0) {
priceResponse.setDiscount(BigDecimal.ZERO); // priceResponse.setDiscount(BigDecimal.ZERO);
} // }
//总金额乘以折扣比例除以100 // //总金额乘以折扣比例除以100
priceResponse.setPayFee(divide); // priceResponse.setPayFee(divide);
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee())); // priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
priceResponse.setTotalFeeNow(divide); // priceResponse.setTotalFeeNow(divide);
priceResponse.setMemberDiscount(payFee.subtract(divide)); // priceResponse.setMemberDiscount(payFee.subtract(divide));
// priceResponse.setCouponFee(priceResponse.getDiscountFee()); //// priceResponse.setCouponFee(priceResponse.getDiscountFee());
// if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) { //// 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))); //// priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// } else { //// } else {
// priceResponse.setDiscountRatio(new BigDecimal(0)); //// priceResponse.setDiscountRatio(new BigDecimal(0));
//// }
// }
// } // }
}
}
// priceResponse.setDiscount(priceResponse.getPayFee().divide(priceResponse.getTotalFeeNow(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100))); // priceResponse.setDiscount(priceResponse.getPayFee().divide(priceResponse.getTotalFeeNow(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
if (ObjectUtil.isEmpty(consumerWallet) && ObjectUtil.isEmpty(consumerMember)) { // if (ObjectUtil.isEmpty(consumerWallet) && ObjectUtil.isEmpty(consumerMember)) {
priceResponse.setTotalFeeNow(priceResponse.getPayFee()); // priceResponse.setTotalFeeNow(priceResponse.getPayFee());
priceResponse.setMemberDiscount(priceResponse.getTotalFee().subtract(priceResponse.getPayFee())); // priceResponse.setMemberDiscount(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
} // }
} else { } else {
priceResponse.setDiscount(BigDecimal.ZERO); priceResponse.setDiscount(BigDecimal.ZERO);
...@@ -2936,6 +2936,46 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2936,6 +2936,46 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return payPrice; return payPrice;
} }
private BigDecimal getBigDecimal(ConsumerMonthlyCard consumerMonthlyCard, BigDecimal timeLong,
ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room) {
if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) >= 0) {
priceResponse.setDuration(timeLong);
priceResponse.setRemainingDuration(consumerMonthlyCard.getFreeDuration().subtract(timeLong));
priceResponse.setDiscount(BigDecimal.ZERO);
totalFee = new BigDecimal(0);
priceResponse.setMemberDiscount(new BigDecimal(0.00));
priceResponse.setTotalFeeNow(priceResponse.getTotalFee());
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
} else if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerMonthlyCard.getFreeDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
BigDecimal remainingBalance = consumerMonthlyCard.getFreeDuration().multiply(room.getPrice());
remainingBalance = totalFee.subtract(remainingBalance);
priceResponse.setTotalFeeNow(remainingBalance);
priceResponse.setMemberDiscount(totalFee.subtract(remainingBalance));
totalFee = remainingBalance;
priceResponse.setPayFee(remainingBalance);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
}
return totalFee;
}
private BigDecimal getBigDecimal(List<ConsumerSecondaryCard> consumerSecondaryCardList,
ComputedOrderPriceResponse priceResponse, SPack byId, BigDecimal payPrice) {
//获取集合中次数最少的次卡,次数不低于0
ConsumerSecondaryCard consumerSecondaryCard = consumerSecondaryCardList.stream().min(Comparator.comparing(ConsumerSecondaryCard::getNumber)).get();
if (consumerSecondaryCard.getPackId().equals(byId.getId())) {
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
priceResponse.setTotalFeeNow(payPrice);
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setSecondaryCardId(consumerSecondaryCard.getId());
payPrice = BigDecimal.ZERO;
}
return payPrice;
}
private BigDecimal computeTotalPrice(Long packId, BigDecimal totalPrice) { private BigDecimal computeTotalPrice(Long packId, BigDecimal totalPrice) {
SPack pack = packService.getById(packId); SPack pack = packService.getById(packId);
if (Objects.isNull(pack)) { if (Objects.isNull(pack)) {
......
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