Commit e60d3fef by 吕明尚

修改计算订单价格,用户钱包计算增加会员日的处理

parent 99233996
...@@ -1858,7 +1858,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1858,7 +1858,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
BigDecimal timeLong = DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()); BigDecimal timeLong = DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate());
// 计算各种价格 // 计算各种价格
ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse(); ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse();
Activity activity; Activity activity = null;
ConsumerMember consumerMember = null; ConsumerMember consumerMember = null;
ConsumerWallet consumerWallet = null; ConsumerWallet consumerWallet = null;
LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>();
...@@ -1884,7 +1884,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1884,7 +1884,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity = activityService.getOne(queryWrapper); activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user); totalFee = getBigDecimal(request, activity, payPrice, user);
} }
totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, 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())) {
...@@ -1895,7 +1895,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1895,7 +1895,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity = activityService.getOne(queryWrapper); activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user); totalFee = getBigDecimal(request, activity, payPrice, user);
} }
totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, byId); // totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, byId);
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId);
} else { } else {
payPrice = totalPrice; payPrice = totalPrice;
request.setBuyType(BuyTypeEnum.TIME.getCode()); request.setBuyType(BuyTypeEnum.TIME.getCode());
...@@ -1904,7 +1905,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1904,7 +1905,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity = activityService.getOne(queryWrapper); activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user); totalFee = getBigDecimal(request, activity, payPrice, user);
} }
totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room); // totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room);
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room);
} }
} }
} else if (!ObjectUtils.isEmpty(request.getPackId())) { } else if (!ObjectUtils.isEmpty(request.getPackId())) {
...@@ -1916,7 +1918,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1916,7 +1918,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity = activityService.getOne(queryWrapper); activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user); totalFee = getBigDecimal(request, activity, payPrice, user);
} }
totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, byId); totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId);
} }
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) {
...@@ -1952,44 +1954,68 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1952,44 +1954,68 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return priceResponse; return priceResponse;
} }
private BigDecimal getBigDecimal(ConsumerWallet consumerWallet, BigDecimal timeLong, ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room) { private BigDecimal getBigDecimal(ConsumerWallet consumerWallet, Activity activity, BigDecimal timeLong, ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room) {
if (ObjectUtil.isNotEmpty(consumerWallet)) { if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (consumerWallet.getRemainingDuration().compareTo(timeLong) >= 0) { if (ObjectUtil.isEmpty(activity)) {
priceResponse.setDuration(timeLong); if (consumerWallet.getRemainingDuration().compareTo(timeLong) >= 0) {
priceResponse.setRemainingDuration(consumerWallet.getRemainingDuration().subtract(timeLong)); priceResponse.setDuration(timeLong);
totalFee = new BigDecimal(0); priceResponse.setRemainingDuration(consumerWallet.getRemainingDuration().subtract(timeLong));
} else if (consumerWallet.getRemainingDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerWallet.getRemainingDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
BigDecimal remainingBalance = timeLong.subtract(consumerWallet.getRemainingDuration()).multiply(room.getPrice());
if (consumerWallet.getBalance().compareTo(remainingBalance) >= 0) {
priceResponse.setBalance(remainingBalance);
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(remainingBalance));
totalFee = new BigDecimal(0); totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(remainingBalance) < 0) { } else if (consumerWallet.getRemainingDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerWallet.getRemainingDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
BigDecimal remainingBalance = timeLong.subtract(consumerWallet.getRemainingDuration()).multiply(room.getPrice());
if (consumerWallet.getBalance().compareTo(remainingBalance) >= 0) {
priceResponse.setBalance(remainingBalance);
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(remainingBalance));
totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(remainingBalance) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
totalFee = remainingBalance.subtract(consumerWallet.getBalance());
}
}
} else {
if (consumerWallet.getBalance().compareTo(totalFee) >= 0) {
priceResponse.setBalance(totalFee);
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(totalFee));
totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(totalFee) < 0) {
priceResponse.setBalance(consumerWallet.getBalance()); priceResponse.setBalance(consumerWallet.getBalance());
totalFee = remainingBalance.subtract(consumerWallet.getBalance()); totalFee = totalFee.subtract(consumerWallet.getBalance());
} }
} }
} }
return totalFee; return totalFee;
} }
private BigDecimal getBigDecimal(ConsumerWallet consumerWallet, BigDecimal timeLong, ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SPack byId) { private BigDecimal getBigDecimal(ConsumerWallet consumerWallet, Activity activity, BigDecimal timeLong, ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SPack byId) {
if (ObjectUtil.isNotEmpty(consumerWallet)) { if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (consumerWallet.getRemainingDuration().compareTo(timeLong) >= 0) { if (ObjectUtil.isEmpty(activity)) {
priceResponse.setDuration(timeLong); if (consumerWallet.getRemainingDuration().compareTo(timeLong) >= 0) {
priceResponse.setRemainingDuration(consumerWallet.getRemainingDuration().subtract(timeLong)); priceResponse.setDuration(timeLong);
totalFee = new BigDecimal(0); priceResponse.setRemainingDuration(consumerWallet.getRemainingDuration().subtract(timeLong));
} else if (consumerWallet.getRemainingDuration().compareTo(timeLong) < 0) { totalFee = new BigDecimal(0);
if (consumerWallet.getBalance().compareTo(byId.getPrice()) >= 0) { } else if (consumerWallet.getRemainingDuration().compareTo(timeLong) < 0) {
priceResponse.setBalance(byId.getPrice()); if (consumerWallet.getBalance().compareTo(byId.getPrice()) >= 0) {
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(byId.getPrice())); priceResponse.setBalance(byId.getPrice());
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(byId.getPrice()));
totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(byId.getPrice()) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
priceResponse.setRemainingBalance(new BigDecimal(0));
totalFee = byId.getPrice().subtract(consumerWallet.getBalance());
}
}
} else {
if (consumerWallet.getBalance().compareTo(totalFee) >= 0) {
priceResponse.setBalance(totalFee);
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(totalFee));
totalFee = new BigDecimal(0); totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(byId.getPrice()) < 0) { } else if (consumerWallet.getBalance().compareTo(totalFee) < 0) {
priceResponse.setBalance(consumerWallet.getBalance()); priceResponse.setBalance(consumerWallet.getBalance());
priceResponse.setRemainingBalance(new BigDecimal(0)); priceResponse.setRemainingBalance(new BigDecimal(0));
totalFee = byId.getPrice().subtract(consumerWallet.getBalance()); totalFee = totalFee.subtract(consumerWallet.getBalance());
} }
} }
} }
......
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