fix:分页排序将已结束的订单放到最后,修复未提交审批的订单查询问题

This commit is contained in:
lulz1 2024-04-20 20:38:52 +08:00
parent 934ef23eaf
commit ab4dfe60be
9 changed files with 38 additions and 45 deletions

View File

@ -152,7 +152,7 @@ public class OrderQuery {
.skip((long) (pageNum - 1) * pageSize)
.limit(pageSize)
.map(routeOrder -> {
orderDomainService.queryLocation(routeOrder.getLegItems());
legDomainService.queryLocation(routeOrder.getLegItems());
User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId());
return getRouteOrderPageRes(routeOrder, user);
})
@ -318,7 +318,7 @@ public class OrderQuery {
public RouteOrder queryById(Long routeId) {
RouteOrder routeOrder = routeRepository.queryById(routeId);
if (routeOrder.getLegItems() != null && routeOrder.getLegItems().isEmpty()) {
orderDomainService.queryLocation(routeOrder.getLegItems());
legDomainService.queryLocation(routeOrder.getLegItems());
}
return routeOrder;
}
@ -356,7 +356,7 @@ public class OrderQuery {
userRepository.findByUserEmployeeNo(routeOrder.getUserId())
);
List<Leg> legItems =
orderDomainService.queryLocation(routeOrder.getLegItems());
legDomainService.queryLocation(routeOrder.getLegItems());
legItems.forEach(leg -> {
@ -523,7 +523,7 @@ public class OrderQuery {
if (legItems != null && !legItems.isEmpty()) {
//这里使用领域事件进行检查leg的订单状态 用户每次想要查看行程都会进行一次检查
legItems.forEach(leg -> legDomainService.legCheckOrder(leg));
orderDomainService.queryLocation(legItems);
legDomainService.queryLocation(legItems);
List<LegRes> list = legItems.stream().map(LegRes::copyFrom).toList();
routeOrderRes.setLegResList(list);
List<OrderDetailRes> orderDetailResList = routeOrder
@ -548,7 +548,7 @@ public class OrderQuery {
List<RouteOrder> routeOrders = routeRepository.findAllByEmployeeNo(currentUser.getEmployeeNo());
routeOrders = routeOrders.stream().filter(it -> it.getUserId().equals(currentUser.getEmployeeNo())).toList();
routeOrders.forEach(route -> {
orderDomainService.queryLocation(route.getLegItems());
legDomainService.queryLocation(route.getLegItems());
orderDomainService.checkRouteOrderStatus(route);
});
Stream<RouteOrder> stream = routeOrders.stream();

View File

@ -93,7 +93,7 @@ public class OrderApplicationService {
checkLegDataTime(addLegData, order);
LegData legData = addLegData.getLegData();
List<Leg> legs = processLegData(legData, order);
orderDomainService.queryLocation(legs);
legDomainService.queryLocation(legs);
RouteOrder routeOrder = orderDomainService.saveOrder(order);
legs.forEach(leg -> {
leg.reloadStatus();
@ -166,7 +166,7 @@ public class OrderApplicationService {
}
}
orderDomainService.queryLocation(List.of(oldLeg, leg));
legDomainService.queryLocation(List.of(oldLeg, leg));
//保存变更事件理由
leg = legDomainService.addChangeEvent(leg, legData.getChangeReason());

View File

@ -3,6 +3,7 @@ package com.chint.domain.aggregates.order;
import com.chint.application.commands.LegOrderedCommand;
import com.chint.domain.factoriy.leg.LegFactory;
import com.chint.domain.service.LegDomainService;
import com.chint.domain.service.OrderDomainService;
import com.chint.domain.service.amount_estimate.EstimateAdapter;
import com.chint.domain.service.supplier.SupplierConstantUtil;
@ -456,12 +457,12 @@ public class RouteOrder implements Serializable {
return this;
}
public OrderDetail matchOrderWithLeg(OrderDetail orderDetail, OrderDomainService orderDomainService) {
public OrderDetail matchOrderWithLeg(OrderDetail orderDetail, LegDomainService legDomainService) {
if (this.legItems.isEmpty()) {
return orderDetail;
}
orderDomainService.queryLocation(this.legItems);
legDomainService.queryLocation(this.legItems);
// 定义时间容差例如1天
long tolerance = Duration.ofDays(2).toMillis();

View File

@ -8,8 +8,7 @@ import com.chint.domain.repository.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
import static com.chint.infrastructure.constant.LegConstant.*;
@ -136,14 +135,17 @@ public class LegDomainService {
} else {
locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
}
List<Location> locationList = legExtensionField.getLocationList();
if (locationList == null || locationList.size() != locationIdsAsLong.size()) {
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
legExtensionField.setLocationList(byNameList);
}
if (leg.getOriginId() != null) {
}
if (leg.getOriginId() != null && leg.getOriginLocation() == null) {
leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId()));
}
if (leg.getDestinationId() != null) {
if (leg.getDestinationId() != null && leg.getDestinationLocation() == null) {
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
}
});

View File

@ -129,31 +129,6 @@ public class OrderDomainService {
}
}
public List<Leg> queryLocation(List<Leg> list) {
list.forEach(leg -> {
LegExtensionField legExtensionField = leg.getLegExtensionField();
if (legExtensionField != null && legExtensionField.getLocationIds() != null) {
List<Long> locationIdsAsLong;
if (legExtensionField.getLocationIds().startsWith("[")) {
locationIdsAsLong = legExtensionField.getLocationIdsAsLongFromArray();
} else {
locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
}
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
legExtensionField.setLocationList(byNameList);
}
if (leg.getOriginId() != null) {
leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId()));
}
if (leg.getDestinationId() != null) {
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
}
});
return list;
}
@ListenTo(command = "OrderCreateCommand", order = 0)
public RouteOrder createOrder(OrderCreateCommand command) {
User user = command.getUser();

View File

@ -3,6 +3,7 @@ package com.chint.domain.service.amount_estimate;
import com.chint.application.queryies.estimate.EstimatePrice;
import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.service.LegDomainService;
import com.chint.domain.service.OrderDomainService;
import com.chint.domain.value_object.FlightPriceData;
import com.chint.domain.value_object.HotelPriceData;
@ -29,6 +30,9 @@ public class CTripEstimate implements AmountEstimate {
@Autowired
private OrderDomainService orderDomainService;
@Autowired
private LegDomainService legDomainService;
@Override
public String amountEstimate(Leg leg) {
@ -69,7 +73,7 @@ public class CTripEstimate implements AmountEstimate {
private PriceQueryData getQueryData(Leg leg) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
PriceQueryData priceQueryData = new PriceQueryData();
leg = orderDomainService.queryLocation(List.of(leg)).get(0);
leg = legDomainService.queryLocation(List.of(leg)).get(0);
priceQueryData.setArriveCity(leg.getDestinationLocation().getLocationId());
priceQueryData.setDepartCity(leg.getOriginLocation().getLocationId());
priceQueryData.setDepartDate(dateTimeFormatter.format(leg.getStartTime()));

View File

@ -12,6 +12,7 @@ import com.chint.domain.factoriy.leg_event.LegEventFactory;
import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
import com.chint.domain.repository.*;
import com.chint.domain.service.LegDomainService;
import com.chint.domain.service.OrderDomainService;
import com.chint.domain.service.RouteRequestDomainService;
import com.chint.domain.service.order_sync.SyncAdapter;
@ -91,6 +92,9 @@ public class LegEventHandler implements LegEventService {
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@Autowired
private LegDomainService legDomainService;
@Value("${chint.envMark}")
private String envMark;
@ -229,7 +233,7 @@ public class LegEventHandler implements LegEventService {
first.isPresent()
) {
orderDetail = first.get();
orderDetail = routeOrder.matchOrderWithLeg(orderDetail, orderDomainService);
orderDetail = routeOrder.matchOrderWithLeg(orderDetail, legDomainService);
}
} else {
orderDetail = byOrderNo.get();

View File

@ -5,6 +5,7 @@ import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.repository.*;
import com.chint.domain.service.LegDomainService;
import com.chint.domain.service.LocationDomainService;
import com.chint.domain.service.OrderDomainService;
import com.chint.interfaces.rest.ctrip.CTripApprovalRequest;
@ -63,6 +64,9 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
@Autowired
private DistrictInfoRepository districtInfoRepository;
@Autowired
private LegDomainService legDomainService;
@Override
public boolean syncSupplierOrder(RouteOrder order) {
log.info("开始同步携程订单");
@ -113,7 +117,7 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
}
private ApprovalRequest generateApprovalRequestLegInfo(List<Leg> legList, String employeeNo, ApprovalRequest approvalRequestParam) {
Map<Integer, List<Leg>> collect = orderDomainService.queryLocation(
Map<Integer, List<Leg>> collect = legDomainService.queryLocation(
legList.stream()
.filter(leg -> leg.getLegType().equals(LEG_TYPE_HOTEL) ||
leg.getLegType().equals(LEG_TYPE_AIRPLANE) ||

View File

@ -5,6 +5,7 @@ import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.LocationRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.LegDomainService;
import com.chint.domain.service.OrderDomainService;
import com.chint.interfaces.rest.ly.LYPostRequest;
import com.chint.interfaces.rest.ly.dto.applyordersync.*;
@ -42,6 +43,8 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
@Value("${ly.baseUrl}")
private String lyBaseUrl;
@Autowired
private LegDomainService legDomainService;
@Override
public boolean syncSupplierOrder(RouteOrder order) {
@ -288,7 +291,7 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
LocalDateTime endDate = LocalDateTime.MIN;
StringBuilder departCityStr = new StringBuilder();
StringBuilder arriveCityStr = new StringBuilder();
orderDomainService.queryLocation(legItems);
legDomainService.queryLocation(legItems);
for (Leg leg : legItems) {
//开始时间
LocalDateTime startTime = leg.getStartTime();