diff --git a/src/main/java/com/chint/application/in/OrderPublicController.java b/src/main/java/com/chint/application/in/OrderPublicController.java index e28a7055..60b055db 100644 --- a/src/main/java/com/chint/application/in/OrderPublicController.java +++ b/src/main/java/com/chint/application/in/OrderPublicController.java @@ -108,7 +108,17 @@ public class OrderPublicController { @ApiOperation("处理审批结果回复") @PostMapping("/approve/response") public Result approveOrder(@RequestBody ApprovalResultData data) { + if(data == null || data.getApprovalRecordNo() == null || data.getApprovalStatus() == null){ + return Result.error("Param can not be null"); + } routeApprovalDomainService.handlerApprovalResponse(data); return Result.Success(SUCCESS); } + + @ApiOperation("行程规划单重新载入差标或推送至商旅平台") + @PostMapping("/standard/reload") + public Result orderStandardReload(@RequestBody OrderQueryData queryData) { + orderDomainService.orderStandardReload(queryData); + return Result.Success(SUCCESS); + } } diff --git a/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java b/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java index f2dbdd94..b3873af1 100644 --- a/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java +++ b/src/main/java/com/chint/domain/aggregates/approval/ApprovalSubmit.java @@ -74,6 +74,8 @@ public class ApprovalSubmit implements ApplicationListener record.getApprovalRecordNo().equals(data.getApprovalRecordNo())) .findFirst(); matchingApprovalRecord.ifPresent(record -> processHandleApprovalResult(data, routeOrder, record)); + } else { + throw new CommandException("Approval record not found: " + data.getApprovalRecordNo()); } } diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index a1f3a4d1..9c981c1b 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -8,11 +8,9 @@ import com.chint.domain.exceptions.OrderException; 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.CompanyBlackListRepository; -import com.chint.domain.repository.OrderDetailRepository; -import com.chint.domain.repository.RouteRepository; -import com.chint.domain.repository.SupplierRepository; +import com.chint.domain.repository.*; import com.chint.domain.value_object.ApproveRouteData; +import com.chint.domain.value_object.OrderQueryData; import com.chint.domain.value_object.UserLoginParam; import com.chint.infrastructure.constant.RouteConstant; import com.chint.infrastructure.echo_framework.annotation.ListenTo; @@ -27,6 +25,7 @@ import com.chint.interfaces.rest.ctrip.dto.search.car.OrderFee; import com.chint.interfaces.rest.ctrip.dto.search.flight.*; import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity; import com.chint.interfaces.rest.ctrip.dto.search.hotel.RefundInfo; +import com.chint.interfaces.rest.data_center.user.UserHttpRequest; import com.chint.interfaces.rest.ly.LYSearchRequest; import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse; @@ -85,6 +84,12 @@ public class OrderDomainService { @Autowired private SupplierRepository supplierRepository; + @Autowired + private UserRepository userRepository; + + @Autowired + private UserHttpRequest userHttpRequest; + @Autowired private RedisTemplate redisTemplate; @@ -484,4 +489,17 @@ public class OrderDomainService { } return orderDetail; } + + public void orderStandardReload(OrderQueryData queryData) { + Long routeId = queryData.getRouteId(); + RouteOrder routeOrder = routeRepository.queryById(routeId); + User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId()); + userHttpRequest.loadUserInfo(user); + routeOrder.setStandardLevel(user.getStandardLevel()); + if ("1".equals(queryData.getExtension())) { + Command.of(RouteAutoSyncCommand.class).route(routeOrder).async().sendToQueue(); + } else { + routeRepository.save(routeOrder); + } + } } diff --git a/src/main/java/com/chint/domain/service/RouteRequestDomainService.java b/src/main/java/com/chint/domain/service/RouteRequestDomainService.java index 39f1ae42..8538ba25 100644 --- a/src/main/java/com/chint/domain/service/RouteRequestDomainService.java +++ b/src/main/java/com/chint/domain/service/RouteRequestDomainService.java @@ -84,16 +84,16 @@ public class RouteRequestDomainService { legDomainService.checkLegIfStartApproval(routeOrder); List> futures = new ArrayList<>(); supplierRepository.findAll() - .forEach(it -> futures.add( - CompletableFuture.runAsync(() -> { - List legs = legDomainService.queryLegsCanSync(routeOrder, it); - List legIdList = legs.stream().map(Leg::getLegId).collect(Collectors.toList()); - if(!legIdList.isEmpty()){ - RouteRequest routeRequest = createRouteRequest(routeOrder, legIdList, it.getName()); - syncRouteRequest(routeRequest, it); - } - }) - )); + .forEach(it -> { + List legs = legDomainService.queryLegsCanSync(routeOrder, it); + List legIdList = legs.stream().map(Leg::getLegId).collect(Collectors.toList()); + if (!legIdList.isEmpty()) { + RouteRequest routeRequest = createRouteRequest(routeOrder, legIdList, it.getName()); + futures.add( + CompletableFuture.runAsync(() -> syncRouteRequest(routeRequest, it)) + ); + } + }); CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])) .thenRun(() -> routeRepository.save(routeOrder)) //保存聚合根 .join(); diff --git a/src/main/java/com/chint/domain/value_object/OrderQueryData.java b/src/main/java/com/chint/domain/value_object/OrderQueryData.java index 9543b7f3..f205c929 100644 --- a/src/main/java/com/chint/domain/value_object/OrderQueryData.java +++ b/src/main/java/com/chint/domain/value_object/OrderQueryData.java @@ -25,4 +25,5 @@ public class OrderQueryData extends BaseQuery { private String supplierName; private String customFieldName; private String customFieldValue; + private String extension; }