Commit 412ea1a4 by 吕明尚

修改订单计算

parent 829874d7
......@@ -114,5 +114,11 @@ public class OrderVo {
private BigDecimal payPrice;
private BigDecimal duration;
private BigDecimal balance;
private BigDecimal discountRatio;
}
......@@ -42,6 +42,10 @@ public class ComputedOrderPriceResponse implements Serializable {
@ApiModelProperty(value = "折扣比例")
private BigDecimal discountRatio;
//会员折扣
@ApiModelProperty(value = "会员折扣")
private BigDecimal memberDiscount;
@ApiModelProperty(value = "可用时长")
private BigDecimal availableDuration;
......
......@@ -2310,6 +2310,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setRemainingDuration(BigDecimal.ZERO);
priceResponse.setAvailableDuration(BigDecimal.ZERO);
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
Activity activity = null;
ConsumerMember consumerMember = null;
ConsumerWallet consumerWallet = null;
......@@ -2340,10 +2341,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
priceResponse.setTotalFeeNow(totalFee);
// priceResponse.setTotalFeeNow(totalFee);
priceResponse.setDiscount(totalFee.divide(payPrice).multiply(new BigDecimal(100)));
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
}
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request);
} else {
SPack byId = packService.getById(roomLabel.getPackId());
if (!ObjectUtils.isEmpty(byId) && byId.getIsOpen().equals(YesNoEnum.yes.getIndex())) {
......@@ -2355,10 +2356,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscount(totalFee.divide(payPrice).multiply(new BigDecimal(100)));
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
}
// totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, byId);
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
} else {
payPrice = totalPrice;
priceResponse.setTotalFeeNow(payPrice);
......@@ -2367,11 +2370,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
priceResponse.setTotalFeeNow(totalFee);
// priceResponse.setTotalFeeNow(totalFee);
priceResponse.setDiscount(totalFee.divide(payPrice).multiply(new BigDecimal(100)));
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
}
// totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room);
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request);
}
}
} else if (!ObjectUtils.isEmpty(request.getPackId())) {
......@@ -2384,10 +2388,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscount(totalFee.divide(payPrice).multiply(new BigDecimal(100)));
}
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
}
}
priceResponse.setTotalFee(payPrice);
if (ObjectUtil.isEmpty(consumerWallet) && totalFee.compareTo(new BigDecimal(0)) == 0) {
priceResponse.setPayFee(payPrice);
......@@ -2457,8 +2463,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
private BigDecimal getBigDecimal(ConsumerWallet consumerWallet, Activity activity, BigDecimal timeLong,
ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room, OrderComputedPriceRequest request) {
if (ObjectUtil.isNotEmpty(consumerWallet)) {
ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room, OrderComputedPriceRequest request, ConsumerMember consumerMember) {
if (ObjectUtil.isNotEmpty(consumerWallet) && ObjectUtil.isNotEmpty(consumerMember)) {
MemberConfig memberConfig = memberConfigService.getById(consumerMember.getMemberConfigId());
CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
priceResponse.setDuration(BigDecimal.ZERO);
priceResponse.setRemainingDuration(BigDecimal.ZERO);
......@@ -2471,6 +2478,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (consumerWallet.getBalance().compareTo(totalFee) >= 0) {
priceResponse.setBalance(totalFee);
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(totalFee));
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(totalFee);
totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(totalFee) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
......@@ -2485,14 +2494,19 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDuration(consumerWallet.getRemainingDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
BigDecimal remainingBalance = consumerWallet.getRemainingDuration().multiply(room.getPrice());
remainingBalance = priceResponse.getTotalFeeNow().subtract(remainingBalance);
if (consumerWallet.getBalance().compareTo(remainingBalance) >= 0) {
priceResponse.setBalance(remainingBalance);
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(remainingBalance));
totalFee = totalFee.divide(memberConfig.getDiscountRatio()).multiply(new BigDecimal(100));
remainingBalance = totalFee.subtract(remainingBalance);
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(remainingBalance) < 0) {
} else if (consumerWallet.getBalance().compareTo(divide) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
totalFee = remainingBalance.subtract(consumerWallet.getBalance());
totalFee = divide.subtract(consumerWallet.getBalance());
}
}
}
......@@ -2504,17 +2518,24 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} else if (consumerWallet.getRemainingDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerWallet.getRemainingDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
//时长的金额
BigDecimal remainingBalance = consumerWallet.getRemainingDuration().multiply(room.getPrice());
remainingBalance = priceResponse.getTotalFeeNow().subtract(remainingBalance);
if (consumerWallet.getBalance().compareTo(remainingBalance) >= 0) {
priceResponse.setBalance(remainingBalance);
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(remainingBalance));
//恢复原价
totalFee = totalFee.divide(memberConfig.getDiscountRatio()).multiply(new BigDecimal(100));
//原价减时长
remainingBalance = totalFee.subtract(remainingBalance);
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(remainingBalance) < 0) {
} else if (consumerWallet.getBalance().compareTo(divide) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
priceResponse.setRemainingBalance(BigDecimal.ZERO);
totalFee = remainingBalance.subtract(consumerWallet.getBalance());
totalFee = divide.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