|
@@ -729,198 +729,204 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
if (!redisService.setNx(key, relationId, RedisService.key.NETFLIX_CHANGE_TICKET_KEY.getTimeout())) {
|
|
if (!redisService.setNx(key, relationId, RedisService.key.NETFLIX_CHANGE_TICKET_KEY.getTimeout())) {
|
|
|
throw BusinessRuntimeException.getInstance("正在更换车票中..");
|
|
throw BusinessRuntimeException.getInstance("正在更换车票中..");
|
|
|
}
|
|
}
|
|
|
- Long userId = relation.getUserId();
|
|
|
|
|
- log.info("用户userId:{}更换车票relationId:{}", userId, relationId);
|
|
|
|
|
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
- .eq(OrderDon::getUserId, userId)
|
|
|
|
|
- .eq(OrderDon::getRelationId, relationId)
|
|
|
|
|
- .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
|
|
- .orderByDesc(OrderDon::getId)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- OrderDiscountPlusPurchaseSkuRelation plusPurchaseSkuRelation = null;
|
|
|
|
|
- List<Long> plus_relationList = null;
|
|
|
|
|
- if (orderDon == null) {
|
|
|
|
|
- List<OrderDiscountPlusPurchaseSkuRelation> plusPurchaseSkuRelations = orderDiscountPlusPurchaseSkuRelationMapper.selectPlusRelationByIdAndUserId(relation.getId(), relation.getUserId());
|
|
|
|
|
- for (OrderDiscountPlusPurchaseSkuRelation data : plusPurchaseSkuRelations) {
|
|
|
|
|
- String relationIds = data.getRelationIds();
|
|
|
|
|
- if (StrUtil.isEmpty(relationIds)) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- List<Long> relationList = Jsons.parseList(relationIds, Long.class);
|
|
|
|
|
- if (relationList.contains(relationId)) {
|
|
|
|
|
- plusPurchaseSkuRelation = data;
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ Long userId = relation.getUserId();
|
|
|
|
|
+ log.info("用户userId:{}更换车票relationId:{}", userId, relationId);
|
|
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
+ .eq(OrderDon::getUserId, userId)
|
|
|
|
|
+ .eq(OrderDon::getRelationId, relationId)
|
|
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ OrderDiscountPlusPurchaseSkuRelation plusPurchaseSkuRelation = null;
|
|
|
|
|
+ List<Long> plus_relationList = null;
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ List<OrderDiscountPlusPurchaseSkuRelation> plusPurchaseSkuRelations = orderDiscountPlusPurchaseSkuRelationMapper.selectPlusRelationByIdAndUserId(relation.getId(), relation.getUserId());
|
|
|
|
|
+ for (OrderDiscountPlusPurchaseSkuRelation data : plusPurchaseSkuRelations) {
|
|
|
|
|
+ String relationIds = data.getRelationIds();
|
|
|
|
|
+ if (StrUtil.isEmpty(relationIds)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> relationList = Jsons.parseList(relationIds, Long.class);
|
|
|
|
|
+ if (relationList.contains(relationId)) {
|
|
|
|
|
+ plusPurchaseSkuRelation = data;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- if (plusPurchaseSkuRelation != null) {
|
|
|
|
|
- String relationIds = plusPurchaseSkuRelation.getRelationIds();
|
|
|
|
|
- if (StrUtil.isNotEmpty(relationIds)) {
|
|
|
|
|
- plus_relationList = Jsons.parseList(relationIds, Long.class);
|
|
|
|
|
- if (plus_relationList.contains(relationId)) {
|
|
|
|
|
- orderDon = new OrderDon();
|
|
|
|
|
- GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getId, relationId).build());
|
|
|
|
|
- Assert.notNull(groupsRelationView, "车票已不存在");
|
|
|
|
|
- orderDon.setUserId(groupsRelationView.getUserId());
|
|
|
|
|
- orderDon.setSkuId(groupsRelationView.getSkuId());
|
|
|
|
|
- orderDon.setGoodsId(groupsRelationView.getGoodsId());
|
|
|
|
|
- orderDon.setStatus(OrderDon.Status.complete);
|
|
|
|
|
- orderDon.setOrderType(1);
|
|
|
|
|
|
|
+ if (plusPurchaseSkuRelation != null) {
|
|
|
|
|
+ String relationIds = plusPurchaseSkuRelation.getRelationIds();
|
|
|
|
|
+ if (StrUtil.isNotEmpty(relationIds)) {
|
|
|
|
|
+ plus_relationList = Jsons.parseList(relationIds, Long.class);
|
|
|
|
|
+ if (plus_relationList.contains(relationId)) {
|
|
|
|
|
+ orderDon = new OrderDon();
|
|
|
|
|
+ GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getId, relationId).build());
|
|
|
|
|
+ Assert.notNull(groupsRelationView, "车票已不存在");
|
|
|
|
|
+ orderDon.setUserId(groupsRelationView.getUserId());
|
|
|
|
|
+ orderDon.setSkuId(groupsRelationView.getSkuId());
|
|
|
|
|
+ orderDon.setGoodsId(groupsRelationView.getGoodsId());
|
|
|
|
|
+ orderDon.setStatus(OrderDon.Status.complete);
|
|
|
|
|
+ orderDon.setOrderType(1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- Assert.notNull(orderDon, "订单不存在");
|
|
|
|
|
- if (orderDon.getStatus() == OrderDon.Status.refund) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("订单已退款");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //获取新车队
|
|
|
|
|
- LambdaQueryWrapper<GroupsTrips> queryWrapper = Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
|
|
- .eq(GroupsTrips::getSkuId, orderDon.getSkuId())
|
|
|
|
|
- .eq(GroupsTrips::getId, groupId)
|
|
|
|
|
- .ne(GroupsTrips::getId, relation.getGroupsId())
|
|
|
|
|
- .ne(GroupsTrips::getStatus, GroupsTrips.Status.down)
|
|
|
|
|
- .last("limit 1");
|
|
|
|
|
- GroupsTrips groups = groupsMapper.selectOne(queryWrapper);
|
|
|
|
|
- if (groups == null) throw BusinessRuntimeException.getInstance("车队不存在或已下架");
|
|
|
|
|
- if (!Constant.AI_goodsIds.contains(orderDon.getGoodsId()) && groups.getAvailableNum() <= 0) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("该新车位人员已满");
|
|
|
|
|
- }
|
|
|
|
|
- Integer relationNum = groups.getNum();
|
|
|
|
|
- //获取新车队车位
|
|
|
|
|
- GroupsRelation newRelation;
|
|
|
|
|
- Boolean isOutside = req.getIsOutside();
|
|
|
|
|
- if (Constant.AI_goodsIds.contains(orderDon.getGoodsId()) && ((isOutside != null && isOutside) || groups.getAvailableNum() == 0) && groups.getNum() > 1) {
|
|
|
|
|
- //Ai车队 额外增加车位 并不让上车
|
|
|
|
|
- newRelation = getChatGPTOutsideRelation(orderDon.getUserId(), groupId, relationNum, 1);
|
|
|
|
|
- } else {
|
|
|
|
|
- newRelation = getRelationThisTrips(orderDon.getUserId(), groupId, 1);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Assert.notNull(orderDon, "订单不存在");
|
|
|
|
|
+ if (orderDon.getStatus() == OrderDon.Status.refund) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单已退款");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- //校验座位
|
|
|
|
|
- int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
|
|
- .set(GroupsRelation::getUserId, userId)
|
|
|
|
|
- .eq(GroupsRelation::getUserId, 0)
|
|
|
|
|
- .eq(GroupsRelation::getId, newRelation.getId()));
|
|
|
|
|
- if (update == 0) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("系统繁忙,请重新操作");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- newRelation.setUserId(userId);
|
|
|
|
|
- newRelation.setStartTime(relation.getStartTime());
|
|
|
|
|
- newRelation.setExpiryTime(relation.getExpiryTime());
|
|
|
|
|
- newRelation.setYhsId(yhsId);
|
|
|
|
|
- newRelation.setCmt(relation.getCmt());
|
|
|
|
|
- newRelation.setCustomerService(relation.getCustomerService());
|
|
|
|
|
- if (newRelation.getStatus() != GroupsRelation.Status.outside) {
|
|
|
|
|
- newRelation.setStatus(GroupsRelation.Status.validity);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //清除原先车票
|
|
|
|
|
- relation.setNewRelationId(newRelation.getId());
|
|
|
|
|
- relationClearService.clearTicket(relation, source);
|
|
|
|
|
-
|
|
|
|
|
- //兜底处理 多余车票
|
|
|
|
|
- clearOtherChangeTicket(userId, relationId, newRelation, orderDon.getSkuId());
|
|
|
|
|
-
|
|
|
|
|
- //奈飞车票
|
|
|
|
|
- if (orderDon.getGoodsId() == 1) {
|
|
|
|
|
- User user = userMapper.selectById(newRelation.getUserId());
|
|
|
|
|
- GroupsTrips groupsTrips = groupsMapper.selectById(newRelation.getGroupsId());
|
|
|
|
|
- Account account = accountMapper.selectById(groupsTrips.getAccountId());
|
|
|
|
|
- AtomicInteger start = new AtomicInteger(1);
|
|
|
|
|
- groupsRelationNetflixService.timingSetNetflix(newRelation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(), newRelation.getExpiryTime(), start);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (plusPurchaseSkuRelation != null && plus_relationList != null) {
|
|
|
|
|
- plus_relationList.remove(relationId);
|
|
|
|
|
- plus_relationList.add(newRelation.getId());
|
|
|
|
|
- plusPurchaseSkuRelation.setRelationIds(plus_relationList.toString());
|
|
|
|
|
- orderDiscountPlusPurchaseSkuRelationMapper.updateById(plusPurchaseSkuRelation);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (source != null && source == UserTicketClearedRecord.Source.abnormal) {
|
|
|
|
|
- //将用户异常订单关闭
|
|
|
|
|
- workOrderMapper.update(null, Wrappers.lambdaUpdate(WorkOrder.class)
|
|
|
|
|
- .set(WorkOrder::getStatus, WorkOrder.Status.close)
|
|
|
|
|
- .eq(WorkOrder::getStatus, WorkOrder.Status.waiting)
|
|
|
|
|
- .eq(WorkOrder::getUserId, userId)
|
|
|
|
|
- .eq(WorkOrder::getRelationId, relationId));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (orderDon.getMoney() != null && orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
- //是否是实物权益车票
|
|
|
|
|
- UserPayEquipmentReceiveBenefitsRecord receiveBenefitsRecord = receiveBenefitsRecordMapper.selectOne(Wrappers.lambdaQuery(UserPayEquipmentReceiveBenefitsRecord.class)
|
|
|
|
|
- .eq(UserPayEquipmentReceiveBenefitsRecord::getTicketOrderId, orderDon.getId())
|
|
|
|
|
- .eq(UserPayEquipmentReceiveBenefitsRecord::getRelationId, relationId).last("limit 1"));
|
|
|
|
|
- if (receiveBenefitsRecord != null) {
|
|
|
|
|
- receiveBenefitsRecord.setRelationId(newRelation.getId());
|
|
|
|
|
- receiveBenefitsRecordMapper.updateById(receiveBenefitsRecord);
|
|
|
|
|
|
|
+ //获取新车队
|
|
|
|
|
+ LambdaQueryWrapper<GroupsTrips> queryWrapper = Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
|
|
+ .eq(GroupsTrips::getSkuId, orderDon.getSkuId())
|
|
|
|
|
+ .eq(GroupsTrips::getId, groupId)
|
|
|
|
|
+ .ne(GroupsTrips::getId, relation.getGroupsId())
|
|
|
|
|
+ .ne(GroupsTrips::getStatus, GroupsTrips.Status.down)
|
|
|
|
|
+ .last("limit 1");
|
|
|
|
|
+ GroupsTrips groups = groupsMapper.selectOne(queryWrapper);
|
|
|
|
|
+ if (groups == null) throw BusinessRuntimeException.getInstance("车队不存在或已下架");
|
|
|
|
|
+ if (!Constant.AI_goodsIds.contains(orderDon.getGoodsId()) && groups.getAvailableNum() <= 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该新车位人员已满");
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer relationNum = groups.getNum();
|
|
|
|
|
+ //获取新车队车位
|
|
|
|
|
+ GroupsRelation newRelation;
|
|
|
|
|
+ Boolean isOutside = req.getIsOutside();
|
|
|
|
|
+ if (Constant.AI_goodsIds.contains(orderDon.getGoodsId()) && ((isOutside != null && isOutside) || groups.getAvailableNum() == 0) && groups.getNum() > 1) {
|
|
|
|
|
+ //Ai车队 额外增加车位 并不让上车
|
|
|
|
|
+ newRelation = getChatGPTOutsideRelation(orderDon.getUserId(), groupId, relationNum, 1);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ newRelation = getRelationThisTrips(orderDon.getUserId(), groupId, 1);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- if ((newRelation.getStartTime() == null || newRelation.getExpiryTime() == null)) {
|
|
|
|
|
- List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getRelationId, relationId).eq(OrderDon::getStatus, OrderDon.Status.hasPayment));
|
|
|
|
|
- if (orderDonList.isEmpty()) {
|
|
|
|
|
- orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
- .eq(OrderDon::getUserId, userId)
|
|
|
|
|
- .eq(OrderDon::getRelationId, relationId)
|
|
|
|
|
- .eq(OrderDon::getStatus, OrderDon.Status.complete)
|
|
|
|
|
- .orderByDesc(OrderDon::getId)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
|
|
+ //校验座位
|
|
|
|
|
+ int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
|
|
+ .set(GroupsRelation::getUserId, userId)
|
|
|
|
|
+ .eq(GroupsRelation::getUserId, 0)
|
|
|
|
|
+ .eq(GroupsRelation::getId, newRelation.getId()));
|
|
|
|
|
+ if (update == 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("系统繁忙,请重新操作");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ newRelation.setUserId(userId);
|
|
|
|
|
+ newRelation.setStartTime(relation.getStartTime());
|
|
|
|
|
+ newRelation.setExpiryTime(relation.getExpiryTime());
|
|
|
|
|
+ newRelation.setYhsId(yhsId);
|
|
|
|
|
+ newRelation.setCmt(relation.getCmt());
|
|
|
|
|
+ newRelation.setCustomerService(relation.getCustomerService());
|
|
|
|
|
+ if (newRelation.getStatus() != GroupsRelation.Status.outside) {
|
|
|
|
|
+ newRelation.setStatus(GroupsRelation.Status.validity);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //清除原先车票
|
|
|
|
|
+ relation.setNewRelationId(newRelation.getId());
|
|
|
|
|
+ relationClearService.clearTicket(relation, source);
|
|
|
|
|
+
|
|
|
|
|
+ //兜底处理 多余车票
|
|
|
|
|
+ clearOtherChangeTicket(userId, relationId, newRelation, orderDon.getSkuId());
|
|
|
|
|
+
|
|
|
|
|
+ //奈飞车票
|
|
|
|
|
+ if (orderDon.getGoodsId() == 1) {
|
|
|
|
|
+ User user = userMapper.selectById(newRelation.getUserId());
|
|
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectById(newRelation.getGroupsId());
|
|
|
|
|
+ Account account = accountMapper.selectById(groupsTrips.getAccountId());
|
|
|
|
|
+ AtomicInteger start = new AtomicInteger(1);
|
|
|
|
|
+ groupsRelationNetflixService.timingSetNetflix(newRelation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(), newRelation.getExpiryTime(), start);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (plusPurchaseSkuRelation != null && plus_relationList != null) {
|
|
|
|
|
+ plus_relationList.remove(relationId);
|
|
|
|
|
+ plus_relationList.add(newRelation.getId());
|
|
|
|
|
+ plusPurchaseSkuRelation.setRelationIds(plus_relationList.toString());
|
|
|
|
|
+ orderDiscountPlusPurchaseSkuRelationMapper.updateById(plusPurchaseSkuRelation);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (source != null && source == UserTicketClearedRecord.Source.abnormal) {
|
|
|
|
|
+ //将用户异常订单关闭
|
|
|
|
|
+ workOrderMapper.update(null, Wrappers.lambdaUpdate(WorkOrder.class)
|
|
|
|
|
+ .set(WorkOrder::getStatus, WorkOrder.Status.close)
|
|
|
|
|
+ .eq(WorkOrder::getStatus, WorkOrder.Status.waiting)
|
|
|
|
|
+ .eq(WorkOrder::getUserId, userId)
|
|
|
|
|
+ .eq(WorkOrder::getRelationId, relationId));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (orderDon.getMoney() != null && orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
+ //是否是实物权益车票
|
|
|
|
|
+ UserPayEquipmentReceiveBenefitsRecord receiveBenefitsRecord = receiveBenefitsRecordMapper.selectOne(Wrappers.lambdaQuery(UserPayEquipmentReceiveBenefitsRecord.class)
|
|
|
|
|
+ .eq(UserPayEquipmentReceiveBenefitsRecord::getTicketOrderId, orderDon.getId())
|
|
|
|
|
+ .eq(UserPayEquipmentReceiveBenefitsRecord::getRelationId, relationId).last("limit 1"));
|
|
|
|
|
+ if (receiveBenefitsRecord != null) {
|
|
|
|
|
+ receiveBenefitsRecord.setRelationId(newRelation.getId());
|
|
|
|
|
+ receiveBenefitsRecordMapper.updateById(receiveBenefitsRecord);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (groups.getStatus() == GroupsTrips.Status.waiting) {
|
|
|
|
|
- orderDonList.forEach(hasPaymentOrder -> {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if ((newRelation.getStartTime() == null || newRelation.getExpiryTime() == null)) {
|
|
|
|
|
+ List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getRelationId, relationId).eq(OrderDon::getStatus, OrderDon.Status.hasPayment));
|
|
|
|
|
+ if (orderDonList.isEmpty()) {
|
|
|
|
|
+ orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
+ .eq(OrderDon::getUserId, userId)
|
|
|
|
|
+ .eq(OrderDon::getRelationId, relationId)
|
|
|
|
|
+ .eq(OrderDon::getStatus, OrderDon.Status.complete)
|
|
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (groups.getStatus() == GroupsTrips.Status.waiting) {
|
|
|
|
|
+ orderDonList.forEach(hasPaymentOrder -> {
|
|
|
|
|
+ hasPaymentOrder.setRelationId(newRelation.getId());
|
|
|
|
|
+ orderDonMapper.updateById(hasPaymentOrder);
|
|
|
|
|
+ });
|
|
|
|
|
+ relationMapper.updateById(newRelation);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ orderDonList.forEach((hasPaymentOrder) -> {
|
|
|
|
|
+ //如果续费增加时间,如果首次则设置当前时间为初始时间
|
|
|
|
|
+ Date expiryTime = Optional.ofNullable(newRelation.getExpiryTime()).orElse(new Date());
|
|
|
|
|
+ GoodsDonSku donSku = skuMapper.selectById(hasPaymentOrder.getSkuId());
|
|
|
|
|
+ Date newDate;
|
|
|
|
|
+ if (donSku.getDays() != null && donSku.getDays() > 0) {
|
|
|
|
|
+ newDate = DateUtil.offsetDay(expiryTime, donSku.getDays() * hasPaymentOrder.getNum());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ newDate = DateUtil.offset(expiryTime, DateField.MONTH, donSku.getMonths() * hasPaymentOrder.getNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ newRelation.setExpiryTime(newDate);
|
|
|
|
|
+ newRelation.setStartTime(newRelation.getStartTime() == null ? new Date() : null);
|
|
|
|
|
+ relationMapper.updateById(newRelation);
|
|
|
|
|
+
|
|
|
|
|
+ hasPaymentOrder.setStatus(OrderDon.Status.complete);
|
|
|
hasPaymentOrder.setRelationId(newRelation.getId());
|
|
hasPaymentOrder.setRelationId(newRelation.getId());
|
|
|
orderDonMapper.updateById(hasPaymentOrder);
|
|
orderDonMapper.updateById(hasPaymentOrder);
|
|
|
});
|
|
});
|
|
|
- relationMapper.updateById(newRelation);
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- orderDonList.forEach((hasPaymentOrder) -> {
|
|
|
|
|
- //如果续费增加时间,如果首次则设置当前时间为初始时间
|
|
|
|
|
- Date expiryTime = Optional.ofNullable(newRelation.getExpiryTime()).orElse(new Date());
|
|
|
|
|
- GoodsDonSku donSku = skuMapper.selectById(hasPaymentOrder.getSkuId());
|
|
|
|
|
- Date newDate;
|
|
|
|
|
- if (donSku.getDays() != null && donSku.getDays() > 0) {
|
|
|
|
|
- newDate = DateUtil.offsetDay(expiryTime, donSku.getDays() * hasPaymentOrder.getNum());
|
|
|
|
|
- } else {
|
|
|
|
|
- newDate = DateUtil.offset(expiryTime, DateField.MONTH, donSku.getMonths() * hasPaymentOrder.getNum());
|
|
|
|
|
- }
|
|
|
|
|
- newRelation.setExpiryTime(newDate);
|
|
|
|
|
- newRelation.setStartTime(newRelation.getStartTime() == null ? new Date() : null);
|
|
|
|
|
- relationMapper.updateById(newRelation);
|
|
|
|
|
|
|
|
|
|
- hasPaymentOrder.setStatus(OrderDon.Status.complete);
|
|
|
|
|
- hasPaymentOrder.setRelationId(newRelation.getId());
|
|
|
|
|
- orderDonMapper.updateById(hasPaymentOrder);
|
|
|
|
|
|
|
+ List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getRelationId, relationId).eq(OrderDon::getStatus, OrderDon.Status.complete));
|
|
|
|
|
+ orderDonList.forEach(completeOrder->{
|
|
|
|
|
+ completeOrder.setRelationId(newRelation.getId());
|
|
|
|
|
+ orderDonMapper.updateById(completeOrder);
|
|
|
});
|
|
});
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- List<OrderDon> orderDonList = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getRelationId, relationId).eq(OrderDon::getStatus, OrderDon.Status.complete));
|
|
|
|
|
- orderDonList.forEach(completeOrder->{
|
|
|
|
|
- completeOrder.setRelationId(newRelation.getId());
|
|
|
|
|
- orderDonMapper.updateById(completeOrder);
|
|
|
|
|
- });
|
|
|
|
|
- log.info("userId:{}更换车票,原座位号relationId:{}======>新座位号newRelationId:{}", newRelation.getUserId(), relationId, newRelation.getId());
|
|
|
|
|
- relationMapper.updateById(newRelation);
|
|
|
|
|
-
|
|
|
|
|
- //更换车票 调整GPT相关规格新车队 上车数
|
|
|
|
|
- GoodsDonSku sku = goodsDonSkuMapper.selectById(groups.getSkuId());
|
|
|
|
|
- groupRelationFrontService.adjustGroupsParkingTime(newRelation.getId(), sku);
|
|
|
|
|
-
|
|
|
|
|
- //关闭正在恢复的车票
|
|
|
|
|
- if (orderDon.getGoodsId() == Constant.NETFLIX_GID) {
|
|
|
|
|
- List<Long> userIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
|
|
|
- NetflixUserAccountSubmitRecoverRecord recoverRecord = netflixUserAccountSubmitRecoverRecordMapper.selectOne(Wrappers.lambdaQuery(NetflixUserAccountSubmitRecoverRecord.class)
|
|
|
|
|
- .eq(NetflixUserAccountSubmitRecoverRecord::getRelationId, orderDon.getRelationId())
|
|
|
|
|
- .in(NetflixUserAccountSubmitRecoverRecord::getUserId, userIdList)
|
|
|
|
|
- .eq(NetflixUserAccountSubmitRecoverRecord::getStatus, 0)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- if (recoverRecord != null) {
|
|
|
|
|
- recoverRecord.setStatus(3);
|
|
|
|
|
- netflixUserAccountSubmitRecoverRecordMapper.updateById(recoverRecord);
|
|
|
|
|
|
|
+ log.info("userId:{}更换车票,原座位号relationId:{}======>新座位号newRelationId:{}", newRelation.getUserId(), relationId, newRelation.getId());
|
|
|
|
|
+ relationMapper.updateById(newRelation);
|
|
|
|
|
+
|
|
|
|
|
+ //更换车票 调整GPT相关规格新车队 上车数
|
|
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(groups.getSkuId());
|
|
|
|
|
+ groupRelationFrontService.adjustGroupsParkingTime(newRelation.getId(), sku);
|
|
|
|
|
+
|
|
|
|
|
+ //关闭正在恢复的车票
|
|
|
|
|
+ if (orderDon.getGoodsId() == Constant.NETFLIX_GID) {
|
|
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
|
|
|
+ NetflixUserAccountSubmitRecoverRecord recoverRecord = netflixUserAccountSubmitRecoverRecordMapper.selectOne(Wrappers.lambdaQuery(NetflixUserAccountSubmitRecoverRecord.class)
|
|
|
|
|
+ .eq(NetflixUserAccountSubmitRecoverRecord::getRelationId, orderDon.getRelationId())
|
|
|
|
|
+ .in(NetflixUserAccountSubmitRecoverRecord::getUserId, userIdList)
|
|
|
|
|
+ .eq(NetflixUserAccountSubmitRecoverRecord::getStatus, 0)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (recoverRecord != null) {
|
|
|
|
|
+ recoverRecord.setStatus(3);
|
|
|
|
|
+ netflixUserAccountSubmitRecoverRecordMapper.updateById(recoverRecord);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ if (redisService.hasKey(key)) {
|
|
|
|
|
+ redisService.del(key);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1545,7 +1551,6 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
|
|
|
if (relation == null) {
|
|
if (relation == null) {
|
|
|
relation = new GroupsRelation();
|
|
relation = new GroupsRelation();
|
|
|
relation.setStatus(GroupsRelation.Status.outside);
|
|
relation.setStatus(GroupsRelation.Status.outside);
|
|
|
- relation.setUserId(userId);
|
|
|
|
|
relation.setGroupsId(groupsId);
|
|
relation.setGroupsId(groupsId);
|
|
|
GroupsRelation maxNumRelation = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId, groupsId).orderByDesc(GroupsRelation::getNum).last("limit 1"));
|
|
GroupsRelation maxNumRelation = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId, groupsId).orderByDesc(GroupsRelation::getNum).last("limit 1"));
|
|
|
relation.setNum(maxNumRelation.getNum() + 1);
|
|
relation.setNum(maxNumRelation.getNum() + 1);
|