|
@@ -178,29 +178,30 @@ public class CmsGroupRelationController {
|
|
|
.field(GroupsRelationRechargeView::getStatus, List.of(GroupsRelation.Status.validity.name(), GroupsRelation.Status.outside.name())).op(Operator.InList)
|
|
.field(GroupsRelationRechargeView::getStatus, List.of(GroupsRelation.Status.validity.name(), GroupsRelation.Status.outside.name())).op(Operator.InList)
|
|
|
.build());
|
|
.build());
|
|
|
search.getDataList().forEach(data -> {
|
|
search.getDataList().forEach(data -> {
|
|
|
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
- .eq(OrderDon::getUserId, data.getUserId())
|
|
|
|
|
- .eq(OrderDon::getRelationId, data.getRelationId())
|
|
|
|
|
- .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
|
|
- .orderByDesc(OrderDon::getId)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- // A multi-quantity order has one order_don row but multiple ticket relations.
|
|
|
|
|
- // Only the legacy/primary relation can be stored in order_don.relation_id;
|
|
|
|
|
- // resolve every other ticket through its durable ticket slot.
|
|
|
|
|
- if (orderDon == null) {
|
|
|
|
|
- OrderDonTicketRecord ticketRecord = orderDonTicketRecordMapper.selectOne(
|
|
|
|
|
- Wrappers.lambdaQuery(OrderDonTicketRecord.class)
|
|
|
|
|
- .eq(OrderDonTicketRecord::getRelationId, data.getRelationId())
|
|
|
|
|
- .eq(OrderDonTicketRecord::getStatus, OrderDonTicketRecord.Status.success)
|
|
|
|
|
- .orderByDesc(OrderDonTicketRecord::getId)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- if (ticketRecord != null) {
|
|
|
|
|
- OrderDon slotOrder = orderDonMapper.selectById(ticketRecord.getOrderId());
|
|
|
|
|
- if (slotOrder != null && !Constant.noOrderAllStatus.contains(slotOrder.getStatus())) {
|
|
|
|
|
- orderDon = slotOrder;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Ticket-slot ownership is authoritative for multi-quantity orders. Resolve it
|
|
|
|
|
+ // before the legacy relation_id lookup, otherwise an old/generated relation order
|
|
|
|
|
+ // can mask the real multi-quantity parent order.
|
|
|
|
|
+ OrderDon orderDon = null;
|
|
|
|
|
+ OrderDonTicketRecord ticketRecord = orderDonTicketRecordMapper.selectOne(
|
|
|
|
|
+ Wrappers.lambdaQuery(OrderDonTicketRecord.class)
|
|
|
|
|
+ .eq(OrderDonTicketRecord::getRelationId, data.getRelationId())
|
|
|
|
|
+ .eq(OrderDonTicketRecord::getStatus, OrderDonTicketRecord.Status.success)
|
|
|
|
|
+ .orderByDesc(OrderDonTicketRecord::getId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (ticketRecord != null) {
|
|
|
|
|
+ OrderDon slotOrder = orderDonMapper.selectById(ticketRecord.getOrderId());
|
|
|
|
|
+ if (slotOrder != null && !Constant.noOrderAllStatus.contains(slotOrder.getStatus())) {
|
|
|
|
|
+ orderDon = slotOrder;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
+ .eq(OrderDon::getUserId, data.getUserId())
|
|
|
|
|
+ .eq(OrderDon::getRelationId, data.getRelationId())
|
|
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ }
|
|
|
if (orderDon != null) {
|
|
if (orderDon != null) {
|
|
|
data.setOrderNo(orderDon.getOrderNo());
|
|
data.setOrderNo(orderDon.getOrderNo());
|
|
|
}
|
|
}
|