Commit 07225660 by 吕明尚

修改订单计算价格

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