|
@@ -3,6 +3,7 @@ package com.cyksj.service.order.impl;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
+import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alipay.api.AlipayApiException;
|
|
import com.alipay.api.AlipayApiException;
|
|
@@ -448,7 +449,7 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
}
|
|
}
|
|
|
} else vipUserMapper.updateById(vipUser);
|
|
} else vipUserMapper.updateById(vipUser);
|
|
|
//发送车票
|
|
//发送车票
|
|
|
- sendVipTicketToUser(vipUser.getUserId(), vipUser.getStartTime(), vipUser.getExpiryTime(), userIdList, orderDon.getId());
|
|
|
|
|
|
|
+ sendVipTicketToUser(orderDon.getNum(), vipUser.getUserId(), vipUser.getStartTime(), vipUser.getExpiryTime(), userIdList, orderDon.getId());
|
|
|
} else {
|
|
} else {
|
|
|
//续费订单
|
|
//续费订单
|
|
|
vipUser.setExpiryTime(DateUtil.offsetMonth(vipUser.getExpiryTime(), offsetMonths));
|
|
vipUser.setExpiryTime(DateUtil.offsetMonth(vipUser.getExpiryTime(), offsetMonths));
|
|
@@ -457,15 +458,17 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
setTicketToVipExpiryTime(userIdList, vipUser.getUserId(), vipUser.getExpiryTime());
|
|
setTicketToVipExpiryTime(userIdList, vipUser.getUserId(), vipUser.getExpiryTime());
|
|
|
|
|
|
|
|
//增加nano剩余次数
|
|
//增加nano剩余次数
|
|
|
- NanoUserQuota nanoUserQuota = nanoUserQuotaMapper.selectOne(Wrappers.lambdaQuery(NanoUserQuota.class).in(NanoUserQuota::getUid, userIdList).last("limit 1"));
|
|
|
|
|
- if (nanoUserQuota != null) {
|
|
|
|
|
- GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getId, nanoUserQuota.getRelationId()).build());
|
|
|
|
|
- Long skuId = groupsRelationView.getSkuId();
|
|
|
|
|
- GoodsDonSku sku = skuMapper.selectById(skuId);
|
|
|
|
|
- Integer offestNum = offsetMonths * sku.getNanoQuota();
|
|
|
|
|
- nanoUserQuota.setTotalQuota(nanoUserQuota.getTotalQuota() + offestNum);
|
|
|
|
|
- nanoUserQuota.setRemainingQuota(nanoUserQuota.getRemainingQuota() + offestNum);
|
|
|
|
|
- nanoUserQuotaMapper.updateById(nanoUserQuota);
|
|
|
|
|
|
|
+ GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getUserId, userIdList).op(Operator.InList).field(GroupsRelationView::getIsVip, Boolean.TRUE).build());
|
|
|
|
|
+ if (groupsRelationView != null) {
|
|
|
|
|
+ NanoUserQuota nanoUserQuota = nanoUserQuotaMapper.selectOne(Wrappers.lambdaQuery(NanoUserQuota.class).eq(NanoUserQuota::getRelationId, groupsRelationView.getId()).last("limit 1"));
|
|
|
|
|
+ if (nanoUserQuota != null) {
|
|
|
|
|
+ Long skuId = groupsRelationView.getSkuId();
|
|
|
|
|
+ GoodsDonSku sku = skuMapper.selectById(skuId);
|
|
|
|
|
+ Integer offestNum = offsetMonths * sku.getNanoQuota();
|
|
|
|
|
+ nanoUserQuota.setTotalQuota(nanoUserQuota.getTotalQuota() + offestNum);
|
|
|
|
|
+ nanoUserQuota.setRemainingQuota(nanoUserQuota.getRemainingQuota() + offestNum);
|
|
|
|
|
+ nanoUserQuotaMapper.updateById(nanoUserQuota);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//金额大于0 是否是分销订单
|
|
//金额大于0 是否是分销订单
|
|
@@ -480,7 +483,7 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
deductIfCloseOrderReturnBalance(orderDon.getId(), UserBalanceSourceRecord.Source.vip_order_close);
|
|
deductIfCloseOrderReturnBalance(orderDon.getId(), UserBalanceSourceRecord.Source.vip_order_close);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void sendVipTicketToUser(Long userId, Date vipStartTime, Date vipExpiryTime, List<Long> userIds, Long orderId) {
|
|
|
|
|
|
|
+ private void sendVipTicketToUser(Integer num, Long userId, Date vipStartTime, Date vipExpiryTime, List<Long> userIds, Long orderId) {
|
|
|
//是否存在抵扣 抵扣成功 清除车票
|
|
//是否存在抵扣 抵扣成功 清除车票
|
|
|
VipOrderDonDeductRelation vipOrderDonDeductRelation = vipOrderDonDeductRelationMapper.selectOne(Wrappers.lambdaQuery(VipOrderDonDeductRelation.class)
|
|
VipOrderDonDeductRelation vipOrderDonDeductRelation = vipOrderDonDeductRelationMapper.selectOne(Wrappers.lambdaQuery(VipOrderDonDeductRelation.class)
|
|
|
.eq(VipOrderDonDeductRelation::getOrderId, orderId)
|
|
.eq(VipOrderDonDeductRelation::getOrderId, orderId)
|
|
@@ -539,7 +542,12 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
for (VipGoodsSku sku : skus) {
|
|
for (VipGoodsSku sku : skus) {
|
|
|
//未有抵扣 直接发送会员车票
|
|
//未有抵扣 直接发送会员车票
|
|
|
if (deductSkuIds == null || !deductSkuIds.contains(sku.getSkuId())) {
|
|
if (deductSkuIds == null || !deductSkuIds.contains(sku.getSkuId())) {
|
|
|
- groupRelationFrontService.getTicket(userId, sku.getSkuId(), Boolean.TRUE);
|
|
|
|
|
|
|
+ Long relationId = groupRelationFrontService.getTicket(userId, sku.getSkuId(), Boolean.TRUE);
|
|
|
|
|
+ if (relationId != null && sku.getGoodsId() == Constant.NANO_GOODS_ID) {
|
|
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
|
|
+ GoodsDonSku goodsDonSku = skuMapper.selectById(sku.getSkuId());
|
|
|
|
|
+ createNanoUser(relationId, user, goodsDonSku.getNanoQuota() * num);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -968,4 +976,22 @@ public class VipOrderDonServiceImpl extends ServiceImpl<VipOrderDonMapper, VipOr
|
|
|
userBalanceSourceRecordMapper.deleteById(userBalanceSourceRecord.getId());
|
|
userBalanceSourceRecordMapper.deleteById(userBalanceSourceRecord.getId());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private NanoUserQuota createNanoUser(Long relationId, User user, Integer nanoQuota) {
|
|
|
|
|
+ NanoUserQuota nanoUserQuota = new NanoUserQuota();
|
|
|
|
|
+ nanoUserQuota.setUid(user.getId());
|
|
|
|
|
+ nanoUserQuota.setRelationId(relationId);
|
|
|
|
|
+ nanoUserQuota.setUserToken(UUID.randomUUID().toString());
|
|
|
|
|
+ nanoUserQuota.setNickname(user.getNickname());
|
|
|
|
|
+ nanoUserQuota.setAvatar(user.getHeadimgurl());
|
|
|
|
|
+ nanoUserQuota.setPurchaseDate(DateTime.now());
|
|
|
|
|
+ nanoUserQuota.setTotalQuota(nanoQuota);
|
|
|
|
|
+ nanoUserQuota.setRemainingQuota(nanoUserQuota.getTotalQuota());
|
|
|
|
|
+ try {
|
|
|
|
|
+ nanoUserQuotaMapper.insert(nanoUserQuota);
|
|
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return nanoUserQuota;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|