Commit 07225660 by 吕明尚

修改订单计算价格

parent 697eaeaa
......@@ -37,6 +37,8 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
@Autowired
private RoomLabelService roomLabelService;
@Autowired
private LabelService labelService;
@Autowired
private IPackService packService;
@Autowired
private ISRoomService roomService;
......@@ -134,9 +136,10 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
consumerSecondaryCard = consumerSecondaryCardService.list(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getConsumerId, user.getId()).orderByAsc(ConsumerSecondaryCard::getNumber));
if (!ObjectUtils.isEmpty(monthlyCardRequest.getRoomLabelId())) {
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(monthlyCardRequest.getRoomLabelId());
Label label = labelService.getById(roomLabel.getLabelId());
if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
//标签没绑定套餐
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && new BigDecimal(label.getDuration()).compareTo(BigDecimal.ONE) >= 0) {
consumerMonthlyCardList.add(consumerMonthlyCard.getId());
map.put("consumerMonthlyCard", consumerMonthlyCardList);
}
......
......@@ -3155,34 +3155,64 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) >= 0) {
priceResponse.setDuration(timeLong);
priceResponse.setRemainingDuration(consumerMonthlyCard.getFreeDuration().subtract(timeLong));
priceResponse.setDiscount(BigDecimal.ZERO);
totalFee = new BigDecimal(0);
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(new BigDecimal(0.00));
// priceResponse.setTotalFeeNow(priceResponse.getTotalFee());
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
priceResponse.setTotalFeeNow(priceResponse.getTotalFee());
} else if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerMonthlyCard.getFreeDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
//时长的金额
BigDecimal remainingBalance = consumerMonthlyCard.getFreeDuration().multiply(room.getPrice());
//恢复原价
// totalFee = totalFee.divide(memberConfig.getDiscountRatio(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
//原价减时长
remainingBalance = totalFee.subtract(remainingBalance);
priceResponse.setTotalFeeNow(remainingBalance);
priceResponse.setMemberDiscount(totalFee.subtract(remainingBalance));
totalFee = remainingBalance.multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100));
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setPayFee(remainingBalance);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
priceResponse.setMemberDiscount(remainingBalance.subtract(totalFee));
}
if (consumerWallet.getBalance().compareTo(priceResponse.getTotalFeeNow()) >= 0) {
priceResponse.setBalance(priceResponse.getTotalFeeNow());
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(priceResponse.getTotalFeeNow()));
BigDecimal divide = remainingBalance;
divide = divide.multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100));
priceResponse.setTotalFeeNow(divide);
priceResponse.setMemberDiscount(remainingBalance.subtract(divide));
if (consumerWallet.getBalance().compareTo(divide) >= 0) {
priceResponse.setBalance(divide);
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(divide));
totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(priceResponse.getTotalFeeNow()) < 0) {
} else if (consumerWallet.getBalance().compareTo(divide) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
priceResponse.setRemainingBalance(new BigDecimal(0));
totalFee = priceResponse.getTotalFeeNow().subtract(consumerWallet.getBalance());
priceResponse.setRemainingBalance(BigDecimal.ZERO);
totalFee = divide.subtract(consumerWallet.getBalance());
}
}
// 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.multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100));
// priceResponse.setTotalFeeNow(totalFee);
// priceResponse.setPayFee(remainingBalance);
// priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
// priceResponse.setMemberDiscount(remainingBalance.subtract(totalFee));
// }
// if (consumerWallet.getBalance().compareTo(BigDecimal.ZERO) > 0 && priceResponse.getTotalFeeNow().compareTo(BigDecimal.ZERO) > 0 &&consumerWallet.getBalance().compareTo(priceResponse.getTotalFeeNow()) >= 0) {
// priceResponse.setBalance(priceResponse.getTotalFeeNow());
// priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(priceResponse.getTotalFeeNow()));
// totalFee = new BigDecimal(0);
// } else if (consumerWallet.getBalance().compareTo(BigDecimal.ZERO) > 0 && priceResponse.getTotalFeeNow().compareTo(BigDecimal.ZERO) > 0 && consumerWallet.getBalance().compareTo(priceResponse.getTotalFeeNow()) < 0) {
// priceResponse.setBalance(consumerWallet.getBalance());
// priceResponse.setRemainingBalance(new BigDecimal(0));
// totalFee = priceResponse.getTotalFeeNow().subtract(consumerWallet.getBalance());
// }
return totalFee;
}
......
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