|
|
@@ -146,7 +146,7 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
orderDon.setOpenId(user.getOpenId());
|
|
|
//获取会员价格
|
|
|
VipDeductDto vipMoneyIfDeduct = getVipMoneyIfDeduct(user, payRequest.getIsDeduct());
|
|
|
- BigDecimal vipMoney = getVipMoney();
|
|
|
+ BigDecimal vipMoney = getVipMoney(payRequest.getNum());
|
|
|
payRequest.setDonMoney(vipMoney);
|
|
|
if (vipMoneyIfDeduct != null) {
|
|
|
payRequest.setDonMoney(vipMoney.subtract(vipMoneyIfDeduct.getDeductMoney()));
|
|
|
@@ -165,6 +165,8 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
//设置订单支付商品信息
|
|
|
orderDon.setPayTitle(Constant.VIP_TITLE);
|
|
|
orderDon.setGoodsId(Constant.VIP_RELATE_GOODS_ID);
|
|
|
+ //购买月数
|
|
|
+ orderDon.setNum(payRequest.getNum());
|
|
|
this.saveOrUpdate(orderDon);
|
|
|
|
|
|
Long orderId = orderDon.getId();
|
|
|
@@ -257,7 +259,7 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
orderDon.setOrderNo(donNo);
|
|
|
orderDon.setOpenId(user.getOpenId());
|
|
|
//获取续费会员价格
|
|
|
- payRequest.setDonMoney(getVipMoney());
|
|
|
+ payRequest.setDonMoney(getVipMoney(payRequest.getNum()));
|
|
|
//续费订单
|
|
|
orderDon.setOrderType(2);
|
|
|
orderDon.setMoney(payRequest.getDonMoney());
|
|
|
@@ -364,10 +366,11 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
.in(VipUser::getUserId, userIdList)
|
|
|
.last("limit 1"))).orElse(new VipUser());
|
|
|
vipUser.setUserId(userId);
|
|
|
+ int offsetMonths = orderDon.getNum();
|
|
|
//发放会员车票 普通订单
|
|
|
if (orderDon.getOrderType() == 1) {
|
|
|
vipUser.setStartTime(DateTime.now());
|
|
|
- vipUser.setExpiryTime(DateUtil.offsetMonth(vipUser.getStartTime(), 1));
|
|
|
+ vipUser.setExpiryTime(DateUtil.offsetMonth(vipUser.getStartTime(), offsetMonths));
|
|
|
if (vipUser.getId() == null) {
|
|
|
try {
|
|
|
vipUserMapper.insert(vipUser);
|
|
|
@@ -378,7 +381,7 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
sendVipTicketToUser(vipUser.getUserId(), vipUser.getStartTime(), vipUser.getExpiryTime(), userIdList, orderDon.getId());
|
|
|
} else {
|
|
|
//续费订单
|
|
|
- vipUser.setExpiryTime(DateUtil.offsetMonth(vipUser.getExpiryTime(), 1));
|
|
|
+ vipUser.setExpiryTime(DateUtil.offsetMonth(vipUser.getExpiryTime(), offsetMonths));
|
|
|
vipUserMapper.updateById(vipUser);
|
|
|
//续费订单
|
|
|
setTicketToVipExpiryTime(userIdList, vipUser.getUserId(), vipUser.getExpiryTime());
|
|
|
@@ -492,15 +495,19 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
.eq(GroupsRelation::getIsVip, Boolean.TRUE));
|
|
|
}
|
|
|
|
|
|
- private BigDecimal getVipMoney() {
|
|
|
+ private BigDecimal getVipMoney(Integer num) {
|
|
|
SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
.eq(SysConfig::getSysKey, Constant.VIP_FEE_KEY)
|
|
|
.last("limit 1"));
|
|
|
if (sysConfig == null || StrUtil.isEmpty(sysConfig.getSysValue())) {
|
|
|
throw BusinessRuntimeException.getInstance("系统异常");
|
|
|
}
|
|
|
+ //校验月数
|
|
|
+ if (num != 1 && num != 3 && num != 12) {
|
|
|
+ throw BusinessRuntimeException.getInstance("购买的会员月数错误");
|
|
|
+ }
|
|
|
BigDecimal vipFee = BigDecimal.valueOf(Long.valueOf(sysConfig.getSysValue()));
|
|
|
- return vipFee;
|
|
|
+ return vipFee.multiply(BigDecimal.valueOf(num));
|
|
|
}
|
|
|
|
|
|
private void recordVipDeductRelationIds(Long orderId, Long userId, List<Long> deductRelationIds) {
|