|
|
@@ -398,23 +398,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
ticket.setRemainDays(remainDays);
|
|
|
ticket.setTotal(DateUtil.betweenDay(ticket.getStartTime(), ticket.getExpiryTime(), false) + 1);
|
|
|
}
|
|
|
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
- .eq(OrderDon::getRelationId, ticket.getRelationId())
|
|
|
- .in(OrderDon::getUserId, userIds)
|
|
|
- .eq(OrderDon::getOrderType, 1)
|
|
|
- .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
- .orderByDesc(OrderDon::getId)
|
|
|
- .last("limit 1"));
|
|
|
- if (orderDon == null) {
|
|
|
- OrderDonTicketRecord multiTicket = orderDonTicketRecordService.getActiveByRelationId(ticket.getRelationId());
|
|
|
- if (multiTicket != null) {
|
|
|
- orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
- .eq(OrderDon::getId, multiTicket.getOrderId())
|
|
|
- .in(OrderDon::getUserId, userIds)
|
|
|
- .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
- .last("limit 1"));
|
|
|
- }
|
|
|
- }
|
|
|
+ OrderDon orderDon = getCurrentTicketOrder(ticket.getRelationId(), userIds);
|
|
|
Long zhSkuId = ticket.getSkuId();
|
|
|
if (orderDon == null) {
|
|
|
if (ticket.getGoodsId() == Constant.NETFLIX_GID) {
|
|
|
@@ -2140,13 +2124,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
- .eq(OrderDon::getRelationId, ticket.getRelationId())
|
|
|
- .eq(OrderDon::getUserId, ticket.getUserId())
|
|
|
- .eq(OrderDon::getOrderType, 1)
|
|
|
- .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
- .orderByDesc(OrderDon::getId)
|
|
|
- .last("limit 1"));
|
|
|
+ OrderDon orderDon = getCurrentTicketOrder(ticket.getRelationId(), userIds);
|
|
|
if (orderDon != null) {
|
|
|
ticket.setOrderId(orderDon.getId());
|
|
|
}
|
|
|
@@ -2155,6 +2133,29 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Resolve the order that currently owns a ticket. A relation id can be reused
|
|
|
+ * after an old ticket expires or is cleared, so an active multi-quantity slot
|
|
|
+ * must take precedence over historical order_don.relation_id rows.
|
|
|
+ */
|
|
|
+ private OrderDon getCurrentTicketOrder(Long relationId, List<Long> userIds) {
|
|
|
+ OrderDonTicketRecord activeTicket = orderDonTicketRecordService.getActiveByRelationId(relationId);
|
|
|
+ if (activeTicket != null) {
|
|
|
+ return orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getId, activeTicket.getOrderId())
|
|
|
+ .in(OrderDon::getUserId, userIds)
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
+ .last("limit 1"));
|
|
|
+ }
|
|
|
+ return orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getRelationId, relationId)
|
|
|
+ .in(OrderDon::getUserId, userIds)
|
|
|
+ .eq(OrderDon::getOrderType, 1)
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
+ .last("limit 1"));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public TicketRenewUpgradeView getRenewUpgradeInfo(long userId, Long relationId) {
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|