Commit 7a8b7439 by 吕明尚

增加月卡时长和钱包时长混和使用

parent ea269889
......@@ -46,6 +46,8 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
private IPackService packService;
@Autowired
private ISRoomService roomService;
@Autowired
private ConsumerWalletService consumerWalletService;
/**
* 查询用户月卡
......@@ -128,12 +130,14 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
SConsumer user = sConsumerService.getInfo();
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()).eq(ConsumerMember::getIsRights
, YesNoEnum.yes.getIndex()));
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
ConsumerMonthlyCard consumerMonthlyCard = null;
List<ConsumerSecondaryCard> consumerSecondaryCard = null;
MonthlyCardResponse map = new MonthlyCardResponse();
List<ConsumerMonthlyCard> consumerMonthlyCardList = new ArrayList<>();
List<ConsumerSecondaryCard> consumerSecondaryCardList = new ArrayList<>();
//可用时长
BigDecimal freeDuration = consumerWallet.getRemainingDuration();
if (ObjectUtil.isNotEmpty(consumerMember)) {
SRoom room = roomService.getById(monthlyCardRequest.getRoomId());
consumerMonthlyCard = baseMapper.selectOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getConsumerId, user.getId()).gt(ConsumerMonthlyCard::getFreeDuration, 0));
......@@ -142,6 +146,7 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
.gt(ConsumerSecondaryCard::getNumber, 0)
.orderByAsc(ConsumerSecondaryCard::getNumber)
);
freeDuration = freeDuration.add(consumerMonthlyCard.getFreeDuration());
if (!ObjectUtils.isEmpty(monthlyCardRequest.getRoomLabelId())) {
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(monthlyCardRequest.getRoomLabelId());
Label label = labelService.getById(roomLabel.getLabelId());
......@@ -179,7 +184,7 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
}
});
}
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && consumerMonthlyCard.getFreeDuration().compareTo(new BigDecimal(byId.getDuration())) >= 0) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && freeDuration.compareTo(new BigDecimal(byId.getDuration())) >= 0) {
consumerMonthlyCardList.add(consumerMonthlyCard);
map.setConsumerMonthlyCard(consumerMonthlyCardList);
}
......@@ -218,7 +223,7 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
}
});
}
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && consumerMonthlyCard.getFreeDuration().compareTo(new BigDecimal(pack.getDuration())) >= 0) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard) && freeDuration.compareTo(new BigDecimal(pack.getDuration())) >= 0) {
consumerMonthlyCardList.add(consumerMonthlyCard);
map.setConsumerMonthlyCard(consumerMonthlyCardList);
}
......
......@@ -528,11 +528,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
//退款
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode())) {
try {
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) || !ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(consumerMonthlyCard, sOrder, consumerSecondaryCard);
} else {
refundExtracted(consumerWallet, sOrder, consumerMember);
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(sOrder, consumerSecondaryCard);
}
refundExtracted(consumerWallet, sOrder, consumerMember, consumerMonthlyCard);
orderRefundService.refundOp(request, sOrder);
} catch (Exception e) {
e.printStackTrace();
......@@ -540,11 +539,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
} else {
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) || !ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(consumerMonthlyCard, sOrder, consumerSecondaryCard);
} else {
refundExtracted(consumerWallet, sOrder, consumerMember);
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(sOrder, consumerSecondaryCard);
}
refundExtracted(consumerWallet, sOrder, consumerMember, consumerMonthlyCard);
sOrder.setStatus(OrderStatusEnum.CANCEL.getCode());
sOrder.setRefundStatus(RefundStatusEnum.REFUNDED.getCode());
sOrder.setRefundReasonTime(cn.hutool.core.date.DateUtil.date());
......@@ -992,10 +990,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
response.setOrderNo(sOrder.getOrderNo());
sOrder.setPayStatus(YesNoEnum.yes.getIndex());
sOrder.setPayTime(DateUtils.getNowDate());
if (!ObjectUtils.isEmpty(request.getMonthlyCardId()) || !ObjectUtils.isEmpty(request.getSecondaryCardId())) {
creatExtracted(consumerMonthlyCard, sOrder, consumerSecondaryCard);
if (!ObjectUtils.isEmpty(request.getSecondaryCardId())) {
creatExtracted(sOrder, consumerSecondaryCard);
}
creatExtracted(consumerWallet, sOrder, consumerMember);
creatExtracted(consumerWallet, sOrder, consumerMember, consumerMonthlyCard);
} else {
// response = orderPayService.payment(sOrder);
// 扫呗聚合支付
......@@ -1129,9 +1127,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
private void creatExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember) {
private void creatExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember, ConsumerMonthlyCard consumerMonthlyCard) {
if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0 && ObjectUtil.isEmpty(sOrder.getMonthlyCardId())) {
if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0) {
if (ObjectUtil.isEmpty(sOrder.getMonthlyCardId())) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(sOrder.getConsumerId());
durationLog.setVariableDuration(sOrder.getDuration());
......@@ -1143,6 +1143,51 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
durationLogService.save(durationLog);
consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().subtract(sOrder.getDuration()));
consumerWalletService.updateById(consumerWallet);
} else {
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) && !ObjectUtils.isEmpty(sOrder.getDuration())) {
if (consumerMonthlyCard.getFreeDuration().compareTo(sOrder.getDuration()) >= 0) {
consumerMonthlyCard.setFreeDuration(consumerMonthlyCard.getFreeDuration().subtract(sOrder.getDuration()));
MonthlyCardLog monthlyCardLog = new MonthlyCardLog();
monthlyCardLog.setConsumerMonthlyCardId(sOrder.getMonthlyCardId());
monthlyCardLog.setConsumerId(consumerMonthlyCard.getConsumerId());
monthlyCardLog.setPhone(sOrder.getConsumerPhone());
monthlyCardLog.setUseDuration(sOrder.getDuration());
monthlyCardLog.setResidueDuration(consumerMonthlyCard.getFreeDuration());
monthlyCardLog.setOperationType(YesNoEnum.no.getIndex());
monthlyCardLog.setOperationTime(new Date());
monthlyCardLog.setCreateTime(new Date());
consumerMonthlyCardService.updateById(consumerMonthlyCard);
monthlyCardLogService.save(monthlyCardLog);
} else if (consumerMonthlyCard.getFreeDuration().compareTo(sOrder.getDuration()) < 0) {
BigDecimal duration = sOrder.getDuration();
MonthlyCardLog monthlyCardLog = new MonthlyCardLog();
monthlyCardLog.setConsumerMonthlyCardId(sOrder.getMonthlyCardId());
monthlyCardLog.setConsumerId(consumerMonthlyCard.getConsumerId());
monthlyCardLog.setPhone(sOrder.getConsumerPhone());
monthlyCardLog.setUseDuration(consumerMonthlyCard.getFreeDuration());
duration = duration.subtract(consumerMonthlyCard.getFreeDuration());
consumerMonthlyCard.setFreeDuration(BigDecimal.ZERO);
monthlyCardLog.setResidueDuration(consumerMonthlyCard.getFreeDuration());
monthlyCardLog.setOperationType(YesNoEnum.no.getIndex());
monthlyCardLog.setOperationTime(new Date());
monthlyCardLog.setCreateTime(new Date());
consumerMonthlyCardService.updateById(consumerMonthlyCard);
monthlyCardLogService.save(monthlyCardLog);
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(sOrder.getConsumerId());
durationLog.setVariableDuration(duration);
durationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationType(YesNoEnum.no.getIndex());
durationLog.setDurationType(DurationTypeEnum.ORDER.getCode());
durationLog.setOperationTime(new Date());
durationLog.setCreateTime(new Date());
durationLogService.save(durationLog);
consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().subtract(duration));
consumerWalletService.updateById(consumerWallet);
}
}
}
}
if (ObjectUtil.isNotEmpty(sOrder.getBalance()) && sOrder.getBalance().compareTo(BigDecimal.ZERO) > 0) {
BalanceLog balanceLog = new BalanceLog();
......@@ -1321,23 +1366,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
private void creatExtracted(ConsumerMonthlyCard consumerMonthlyCard, SOrder sOrder, ConsumerSecondaryCard consumerSecondaryCard) {
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) && !ObjectUtils.isEmpty(sOrder.getDuration())) {
if (consumerMonthlyCard.getFreeDuration().compareTo(sOrder.getDuration()) >= 0) {
consumerMonthlyCard.setFreeDuration(consumerMonthlyCard.getFreeDuration().subtract(sOrder.getDuration()));
MonthlyCardLog monthlyCardLog = new MonthlyCardLog();
monthlyCardLog.setConsumerMonthlyCardId(sOrder.getMonthlyCardId());
monthlyCardLog.setConsumerId(consumerMonthlyCard.getConsumerId());
monthlyCardLog.setPhone(sOrder.getConsumerPhone());
monthlyCardLog.setUseDuration(sOrder.getDuration());
monthlyCardLog.setResidueDuration(consumerMonthlyCard.getFreeDuration());
monthlyCardLog.setOperationType(YesNoEnum.no.getIndex());
monthlyCardLog.setOperationTime(new Date());
monthlyCardLog.setCreateTime(new Date());
consumerMonthlyCardService.updateById(consumerMonthlyCard);
monthlyCardLogService.save(monthlyCardLog);
}
}
private void creatExtracted(SOrder sOrder, ConsumerSecondaryCard consumerSecondaryCard) {
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
consumerSecondaryCard.setNumber(consumerSecondaryCard.getNumber() - 1);
SecondaryCardLog secondaryCardLog = new SecondaryCardLog();
......@@ -1354,9 +1384,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
private void refundExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember) {
private void refundExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember, ConsumerMonthlyCard consumerMonthlyCard) {
if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0 && ObjectUtil.isEmpty(sOrder.getMonthlyCardId())) {
if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0) {
if (ObjectUtil.isEmpty(sOrder.getMonthlyCardId())) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(sOrder.getConsumerId());
durationLog.setVariableDuration(sOrder.getDuration());
......@@ -1368,6 +1399,62 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
durationLogService.save(durationLog);
consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().add(sOrder.getDuration()));
consumerWalletService.updateById(consumerWallet);
} else {
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) && !ObjectUtils.isEmpty(sOrder.getDuration())) {
BigDecimal duration = sOrder.getDuration();
BigDecimal monthlyCardTime = new BigDecimal(sysConfigService.selectConfigByKey("monthlyCardTime"));
if (monthlyCardTime.compareTo(duration) >= 0) {
//判断订单的下单时间是否是当前天
LocalDate localDate1 = sOrder.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate localDate2 = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
if (localDate1.equals(localDate2)) {
consumerMonthlyCard.setFreeDuration(consumerMonthlyCard.getFreeDuration().add(sOrder.getDuration()));
MonthlyCardLog monthlyCardLog = new MonthlyCardLog();
monthlyCardLog.setConsumerMonthlyCardId(sOrder.getMonthlyCardId());
monthlyCardLog.setConsumerId(consumerMonthlyCard.getConsumerId());
monthlyCardLog.setPhone(sOrder.getConsumerPhone());
monthlyCardLog.setUseDuration(sOrder.getDuration());
monthlyCardLog.setResidueDuration(consumerMonthlyCard.getFreeDuration());
monthlyCardLog.setOperationType(YesNoEnum.yes.getIndex());
monthlyCardLog.setOperationTime(new Date());
monthlyCardLog.setCreateTime(new Date());
consumerMonthlyCardService.updateById(consumerMonthlyCard);
monthlyCardLogService.save(monthlyCardLog);
}
} else if (monthlyCardTime.compareTo(duration) < 0) {
//判断订单的下单时间是否是当前天
LocalDate localDate1 = sOrder.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate localDate2 = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
duration = duration.subtract(monthlyCardTime);
if (localDate1.equals(localDate2)) {
consumerMonthlyCard.setFreeDuration(consumerMonthlyCard.getFreeDuration().add(monthlyCardTime));
MonthlyCardLog monthlyCardLog = new MonthlyCardLog();
monthlyCardLog.setConsumerMonthlyCardId(sOrder.getMonthlyCardId());
monthlyCardLog.setConsumerId(consumerMonthlyCard.getConsumerId());
monthlyCardLog.setPhone(sOrder.getConsumerPhone());
monthlyCardLog.setUseDuration(monthlyCardTime);
monthlyCardLog.setResidueDuration(consumerMonthlyCard.getFreeDuration());
monthlyCardLog.setOperationType(YesNoEnum.yes.getIndex());
monthlyCardLog.setOperationTime(new Date());
monthlyCardLog.setCreateTime(new Date());
consumerMonthlyCardService.updateById(consumerMonthlyCard);
monthlyCardLogService.save(monthlyCardLog);
}
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(sOrder.getConsumerId());
durationLog.setVariableDuration(duration);
durationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setDurationType(DurationTypeEnum.ORDER_REFUND.getCode());
durationLog.setOperationTime(new Date());
durationLog.setCreateTime(new Date());
durationLogService.save(durationLog);
consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().add(duration));
consumerWalletService.updateById(consumerWallet);
}
}
}
}
if (ObjectUtil.isNotEmpty(sOrder.getBalance()) && sOrder.getBalance().compareTo(BigDecimal.ZERO) > 0) {
BalanceLog balanceLog = new BalanceLog();
......@@ -1571,26 +1658,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// }
}
private void refundExtracted(ConsumerMonthlyCard consumerMonthlyCard, SOrder sOrder, ConsumerSecondaryCard consumerSecondaryCard) {
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) && !ObjectUtils.isEmpty(sOrder.getDuration())) {
//判断订单的下单时间是否是当前天
LocalDate localDate1 = sOrder.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate localDate2 = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
if (localDate1.equals(localDate2)) {
consumerMonthlyCard.setFreeDuration(consumerMonthlyCard.getFreeDuration().add(sOrder.getDuration()));
MonthlyCardLog monthlyCardLog = new MonthlyCardLog();
monthlyCardLog.setConsumerMonthlyCardId(sOrder.getMonthlyCardId());
monthlyCardLog.setConsumerId(consumerMonthlyCard.getConsumerId());
monthlyCardLog.setPhone(sOrder.getConsumerPhone());
monthlyCardLog.setUseDuration(sOrder.getDuration());
monthlyCardLog.setResidueDuration(consumerMonthlyCard.getFreeDuration());
monthlyCardLog.setOperationType(YesNoEnum.yes.getIndex());
monthlyCardLog.setOperationTime(new Date());
monthlyCardLog.setCreateTime(new Date());
consumerMonthlyCardService.updateById(consumerMonthlyCard);
monthlyCardLogService.save(monthlyCardLog);
}
}
private void refundExtracted(SOrder sOrder, ConsumerSecondaryCard consumerSecondaryCard) {
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
consumerSecondaryCard.setNumber(consumerSecondaryCard.getNumber() + 1);
SecondaryCardLog secondaryCardLog = new SecondaryCardLog();
......@@ -1812,6 +1880,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
order.setBalance(priceResponse.getBalance());
order.setDuration(priceResponse.getDuration());
order.setDiscountRatio(priceResponse.getDiscountRatio());
order.setMonthlyCardId(priceResponse.getMonthlyCardId());
order.setSecondaryCardId(priceResponse.getSecondaryCardId());
if (priceResponse.getPayFee().compareTo(order.getPayPrice()) != 0
&& priceResponse.getDuration().compareTo(request.getDuration()) != 0
&& priceResponse.getBalance().compareTo(request.getBalance()) != 0
......@@ -2156,10 +2226,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, 5,
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
}
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) || !ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(consumerMonthlyCard, sOrder, consumerSecondaryCard);
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(sOrder, consumerSecondaryCard);
} else {
refundExtracted(consumerWallet, sOrder, consumerMember);
refundExtracted(consumerWallet, sOrder, consumerMember, consumerMonthlyCard);
}
}
} else {
......@@ -2191,10 +2261,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (sOrder.getIsDelete().equals(YesNoEnum.yes.getIndex()) && sOrder.getPayStatus().equals(YesNoEnum.yes.getIndex())) {
sOrder.setIsDelete(YesNoEnum.no.getIndex());
}
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) || !ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
creatExtracted(consumerMonthlyCard, sOrder, consumerSecondaryCard);
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
creatExtracted(sOrder, consumerSecondaryCard);
}
creatExtracted(consumerWallet, sOrder, consumerMember);
creatExtracted(consumerWallet, sOrder, consumerMember, consumerMonthlyCard);
baseMapper.updateSOrder(sOrder);
unLockOrder(sOrder.getRoomId());
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
......@@ -2348,10 +2418,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, 5,
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
}
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) || !ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(consumerMonthlyCard, sOrder, consumerSecondaryCard);
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(sOrder, consumerSecondaryCard);
}
refundExtracted(consumerWallet, sOrder, consumerMember);
refundExtracted(consumerWallet, sOrder, consumerMember, consumerMonthlyCard);
}
} catch (Exception e) {
......@@ -2379,10 +2449,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
try {
sOrder.setRefundReason(request.getRefundReason());
updateById(sOrder);
if (!ObjectUtils.isEmpty(sOrder.getMonthlyCardId()) || !ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(consumerMonthlyCard, sOrder, consumerSecondaryCard);
if (!ObjectUtils.isEmpty(sOrder.getSecondaryCardId())) {
refundExtracted(sOrder, consumerSecondaryCard);
}
refundExtracted(consumerWallet, sOrder, consumerMember);
refundExtracted(consumerWallet, sOrder, consumerMember, consumerMonthlyCard);
//微信退款
// if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode()) && request.getAmount().compareTo(BigDecimal.ZERO) == 0) {
// 退款task, 定时任务退优惠券
......@@ -2877,6 +2947,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setBalance(new BigDecimal(0));
priceResponse.setRemainingBalance(new BigDecimal(0));
priceResponse.setRemainingDuration(new BigDecimal(0));
priceResponse.setMonthlyCardId(null);
priceResponse.setSecondaryCardId(null);
if (priceResponse.getPayFee().compareTo(new BigDecimal(0)) > 0) {
if (ObjectUtil.isNotEmpty(consumerWallet) && ObjectUtil.isNotEmpty(consumerMember)) {
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
......@@ -3180,21 +3252,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscountRatio(memberConfig.getDiscountRatio());
priceResponse.setDiscount(memberConfig.getDiscountRatio());
priceResponse.setTotalFee(totalFee);
priceResponse.setAvailableDuration(consumerMonthlyCard.getFreeDuration());
if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) >= 0) {
priceResponse.setAvailableDuration(consumerMonthlyCard.getFreeDuration().add(consumerWallet.getRemainingDuration()));
if (priceResponse.getAvailableDuration().compareTo(timeLong) >= 0) {
priceResponse.setDuration(timeLong);
priceResponse.setRemainingDuration(consumerMonthlyCard.getFreeDuration().subtract(timeLong));
priceResponse.setRemainingDuration(priceResponse.getAvailableDuration().subtract(timeLong));
totalFee = new BigDecimal(0);
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(new BigDecimal(0.00));
priceResponse.setTotalFeeNow(priceResponse.getTotalFee());
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
priceResponse.setPayFee(BigDecimal.ZERO);
} else if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerMonthlyCard.getFreeDuration());
} else if (priceResponse.getAvailableDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(priceResponse.getAvailableDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
//时长的金额
BigDecimal remainingBalance = consumerMonthlyCard.getFreeDuration().multiply(room.getPrice());
BigDecimal remainingBalance = priceResponse.getAvailableDuration().multiply(room.getPrice());
//恢复原价
// totalFee = totalFee.divide(memberConfig.getDiscountRatio(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
//原价减时长
......
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