Commit b4a10e8f by 吕明尚

下单计算月卡,次卡

parent 06d6a649
...@@ -9,6 +9,8 @@ import org.apache.commons.lang3.builder.ToStringStyle; ...@@ -9,6 +9,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel; import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity; import share.common.core.domain.BaseEntity;
import java.math.BigDecimal;
/** /**
* 月卡使用记录对象 s_monthly_card_log * 月卡使用记录对象 s_monthly_card_log
* *
...@@ -47,13 +49,13 @@ public class MonthlyCardLog extends BaseEntity { ...@@ -47,13 +49,13 @@ public class MonthlyCardLog extends BaseEntity {
* 使用时长 * 使用时长
*/ */
@Excel(name = "使用时长") @Excel(name = "使用时长")
private Long useDuration; private BigDecimal useDuration;
/** /**
* 剩余时长 * 剩余时长
*/ */
@Excel(name = "剩余时长") @Excel(name = "剩余时长")
private Long residueDuration; private BigDecimal residueDuration;
/** /**
* 删除标记:1-删除,0-正常 * 删除标记:1-删除,0-正常
......
...@@ -89,4 +89,12 @@ public class CreateOrderRequest { ...@@ -89,4 +89,12 @@ public class CreateOrderRequest {
@ApiModelProperty(value = "使用时长") @ApiModelProperty(value = "使用时长")
private BigDecimal duration; private BigDecimal duration;
//次卡ID
@ApiModelProperty(value = "次卡ID")
private Long secondaryCardId;
//月卡ID
@ApiModelProperty(value = "月卡ID")
private Long monthlyCardId;
} }
...@@ -173,7 +173,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -173,7 +173,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired @Autowired
private ConsumerMonthlyCardService consumerMonthlyCardService; private ConsumerMonthlyCardService consumerMonthlyCardService;
@Autowired @Autowired
private MonthlyCardLogService monthlyCardLogService;
@Autowired
private ConsumerSecondaryCardService consumerSecondaryCardService; private ConsumerSecondaryCardService consumerSecondaryCardService;
@Autowired
private SecondaryCardLogService secondaryCardLogService;
private final static Long FIVE = 5L; private final static Long FIVE = 5L;
...@@ -876,6 +880,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -876,6 +880,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} }
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId())); ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId())); ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
ConsumerMonthlyCard consumerMonthlyCard = consumerMonthlyCardService.getById(request.getMonthlyCardId());
ConsumerSecondaryCard consumerSecondaryCard = consumerSecondaryCardService.getById(request.getSecondaryCardId());
List<SStore> stores = storeService.list(); List<SStore> stores = storeService.list();
SRoom room = roomService.getById(request.getRoomId()); SRoom room = roomService.getById(request.getRoomId());
SStore sStore = storeService.getById(request.getStoreId()); SStore sStore = storeService.getById(request.getStoreId());
...@@ -933,6 +939,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -933,6 +939,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sOrder.setPayStatus(YesNoEnum.yes.getIndex()); sOrder.setPayStatus(YesNoEnum.yes.getIndex());
sOrder.setPayTime(DateUtils.getNowDate()); sOrder.setPayTime(DateUtils.getNowDate());
creatExtracted(consumerWallet, sOrder, consumerMember); creatExtracted(consumerWallet, sOrder, consumerMember);
createCard(consumerMonthlyCard, sOrder, consumerSecondaryCard);
} else { } else {
// response = orderPayService.payment(sOrder); // response = orderPayService.payment(sOrder);
// 扫呗聚合支付 // 扫呗聚合支付
...@@ -1066,6 +1073,32 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1066,6 +1073,32 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
} }
} }
private void createCard(ConsumerMonthlyCard consumerMonthlyCard, SOrder sOrder, ConsumerSecondaryCard consumerSecondaryCard) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
MonthlyCardLog monthlyCardLog = new MonthlyCardLog();
monthlyCardLog.setConsumerMonthlyCardId(consumerMonthlyCard.getId());
monthlyCardLog.setConsumerId(sOrder.getConsumerId());
monthlyCardLog.setPhone(sOrder.getConsumerPhone());
monthlyCardLog.setUseDuration(sOrder.getDuration());
monthlyCardLog.setResidueDuration(consumerMonthlyCard.getFreeDuration().subtract(sOrder.getDuration()));
consumerMonthlyCard.setFreeDuration(consumerMonthlyCard.getFreeDuration().subtract(sOrder.getDuration()));
consumerMonthlyCardService.updateById(consumerMonthlyCard);
monthlyCardLogService.save(monthlyCardLog);
} else if (ObjectUtil.isNotEmpty(consumerSecondaryCard)) {
SecondaryCardLog secondaryCardLog = new SecondaryCardLog();
secondaryCardLog.setConsumerSecondaryCardId(consumerSecondaryCard.getId());
secondaryCardLog.setConsumerId(sOrder.getConsumerId());
secondaryCardLog.setPhone(sOrder.getConsumerPhone());
secondaryCardLog.setPackId(sOrder.getPackId());
secondaryCardLog.setUsageCount(1L);
secondaryCardLog.setResidueCount(consumerSecondaryCard.getNumber() - 1L);
consumerSecondaryCard.setNumber(consumerSecondaryCard.getNumber() - 1);
secondaryCardLogService.save(secondaryCardLog);
consumerSecondaryCardService.updateById(consumerSecondaryCard);
}
}
private void creatExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember) { private void creatExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember) {
if (ObjectUtil.isNotEmpty(consumerWallet)) { if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0) { if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0) {
...@@ -1585,10 +1618,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1585,10 +1618,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
order.setBalance(priceResponse.getBalance()); order.setBalance(priceResponse.getBalance());
order.setDuration(priceResponse.getDuration()); order.setDuration(priceResponse.getDuration());
order.setDiscountRatio(priceResponse.getDiscountRatio()); order.setDiscountRatio(priceResponse.getDiscountRatio());
if (ObjectUtil.isNotEmpty(request.getMonthlyCardId())) {
order.setMonthlyCardId(request.getMonthlyCardId());
}
if (ObjectUtil.isNotEmpty(request.getSecondaryCardId())) {
order.setSecondaryCardId(request.getSecondaryCardId());
}
if (priceResponse.getPayFee().compareTo(order.getPayPrice()) != 0 if (priceResponse.getPayFee().compareTo(order.getPayPrice()) != 0
&& priceResponse.getDuration().compareTo(request.getDuration()) != 0 && priceResponse.getDuration().compareTo(request.getDuration()) != 0
&& priceResponse.getBalance().compareTo(request.getBalance()) != 0 && priceResponse.getBalance().compareTo(request.getBalance()) != 0
&& priceResponse.getDiscountRatio().compareTo(request.getDiscountRatio()) != 0 && priceResponse.getDiscountRatio().compareTo(request.getDiscountRatio()) != 0
&& (ObjectUtil.isNotEmpty(request.getSecondaryCardId()) && priceResponse.getSecondaryCardId().compareTo(request.getSecondaryCardId()) != 0)
&& (ObjectUtil.isNotEmpty(request.getMonthlyCardId()) && priceResponse.getMonthlyCardId().compareTo(request.getMonthlyCardId()) != 0)
) { ) {
throw new BaseException("订单金额异常!"); throw new BaseException("订单金额异常!");
} }
......
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