|
|
@@ -55,6 +55,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -473,25 +474,49 @@ public class WxCorpController {
|
|
|
.field(TicketView::getGrStatus, List.of("validity", "outside")).op(Operator.InList)
|
|
|
.orderBy(TicketView::getExpiryTime).asc()
|
|
|
.build());
|
|
|
- ticketViews.getDataList().forEach(ticket->{
|
|
|
- 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"));
|
|
|
+ fillTicketOrderInfo(ticketViews.getDataList());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(ticketViews);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillTicketOrderInfo(List<TicketView> tickets) {
|
|
|
+ if (tickets == null || tickets.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> relationIds = tickets.stream()
|
|
|
+ .map(TicketView::getRelationId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<Long> ticketUserIds = tickets.stream()
|
|
|
+ .map(TicketView::getUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (relationIds.isEmpty() || ticketUserIds.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<OrderDon> orderDons = orderDonMapper.selectLatestTicketOrders(relationIds, ticketUserIds, Constant.noOrderAllStatus);
|
|
|
+ if (orderDons.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, OrderDon> latestOrderMap = orderDons.stream()
|
|
|
+ .collect(Collectors.toMap(orderDon -> ticketOrderKey(orderDon.getRelationId(), orderDon.getUserId()), orderDon -> orderDon));
|
|
|
+ tickets.forEach(ticket -> {
|
|
|
+ OrderDon orderDon = latestOrderMap.get(ticketOrderKey(ticket.getRelationId(), ticket.getUserId()));
|
|
|
if (orderDon != null) {
|
|
|
ticket.setOrderNo(orderDon.getOrderNo());
|
|
|
ticket.setOrderId(orderDon.getId());
|
|
|
ticket.setTransactionId(orderDon.getTransactionId());
|
|
|
if (ticket.getSecondType() != null && ticket.getSecondType() == 1) {
|
|
|
- //是否完成邀请 根据订单状态
|
|
|
+ // invite order completion follows order status
|
|
|
ticket.setIsComplete(orderDon.getStatus() == OrderDon.Status.complete ? true : false);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(ticketViews);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String ticketOrderKey(Long relationId, Long userId) {
|
|
|
+ return relationId + "_" + userId;
|
|
|
}
|
|
|
|
|
|
|