From aea8ca7f0ceceda703fccc280829245bc571681b Mon Sep 17 00:00:00 2001 From: dengwc Date: Tue, 6 Feb 2024 17:07:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=90=8C=E7=A8=8B=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=8E=A5=E5=8F=A3=E7=9A=84=E6=B5=8B=E8=AF=95=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chint/domain/aggregates/order/RouteOrder.java | 1 + .../service/amount_estimate/LYEstimate.java | 1 + .../domain/service/leg_event/LegEventHandler.java | 2 +- .../service/order_sync/LYOrderSyncAdapter.java | 15 +++++++++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index 5d9e164e..b8a12cf8 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -95,6 +95,7 @@ public class RouteOrder extends BaseEntity { this.getLegItems().forEach(Leg::reloadStatus); this.estimateAmount = this.getLegItems() .stream() + .filter(leg -> leg.getEstimateAmount() != null) .map(Leg::getEstimateAmount) .reduce(BigDecimalCalculator::add) .orElse(KEEP_TWO_DECIMAL_ZERO); diff --git a/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java b/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java index 26acfe87..3f08258c 100644 --- a/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java +++ b/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java @@ -2,6 +2,7 @@ package com.chint.domain.service.amount_estimate; import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.service.OrderDomainService; import com.chint.infrastructure.constant.Constant; import com.chint.infrastructure.util.BigDecimalCalculator; import com.chint.interfaces.rest.ly.LYPostRequest; diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index 8875eddb..edd1b9f1 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -47,7 +47,7 @@ public class LegEventHandler implements LegEventService{ @Override public void approveLeg(LegApprovalCommand command) { ApproveLegData data = command.getData(); - RouteOrder routeOrder = routeRepository.findByFakeOrderNo(data.getFakeOrderNo()); + RouteOrder routeOrder = routeRepository.findByFakeOrderNo(data.getFakeOrderNo()).reloadStatus(); if (routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE)) { ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); diff --git a/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java index df3592a9..5fdcbfc3 100644 --- a/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java @@ -4,6 +4,7 @@ import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.LocationRepository; +import com.chint.domain.service.OrderDomainService; import com.chint.infrastructure.constant.Constant; import com.chint.infrastructure.util.BaseContext; import com.chint.interfaces.rest.ly.LYPostRequest; @@ -26,6 +27,9 @@ public class LYOrderSyncAdapter implements SupplierOrderSync { @Autowired private LocationRepository locationRepository; + @Autowired + private OrderDomainService orderDomainService; + @Override public boolean syncSupplierOrder(RouteOrder order) { String supplierOrderSyncUrl = Constant.L_Y_BASE_URL + Constant.L_Y_ORDER_PATH;//请求地址 @@ -44,7 +48,7 @@ public class LYOrderSyncAdapter implements SupplierOrderSync { param.setOperationType(1);//1新增,2更新 //获取用户信息 User user = BaseContext.getCurrentUser(); - param.setOutEmployeeId(String.valueOf(user.getUserId()));//用户id + param.setOutEmployeeId(String.valueOf(user.getEmployeeNo()));//用户id param.setTravelDescription("同程订单");//描述信息 param.setBookableProducts("1,3,5");//1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车 //2.同程的行程节点集合 @@ -70,13 +74,15 @@ public class LYOrderSyncAdapter implements SupplierOrderSync { param.setApproveRuleType(0);//审批规则 SupplierOrderSyncDto supplierOrderSyncDto = new SupplierOrderSyncDto(); supplierOrderSyncDto.setParam(param); - Result post = postRequest.post(supplierOrderSyncUrl, supplierOrderSyncDto, Result.class); - System.out.println("post = " + post); + Result result = postRequest.post(supplierOrderSyncUrl, supplierOrderSyncDto, Result.class); + System.out.println("result = " + result); System.out.println("开始同步同程订单"); + String success = result.getSuccess(); + return Boolean.parseBoolean(success); } //同程Leg集合解析 - private static ArrayList getAosItems(RouteOrder order) { + private ArrayList getAosItems(RouteOrder order) { ArrayList aosItems = new ArrayList<>(); AOSItem aosItem = new AOSItem(); LocalDateTime startDate = LocalDateTime.MAX; @@ -85,6 +91,7 @@ public class LYOrderSyncAdapter implements SupplierOrderSync { StringBuilder arriveCityStr = new StringBuilder(); //提取所有行程节点信息 List legItems = order.getLegItems(); + orderDomainService.queryLocation(legItems); for (Leg leg : legItems) { //开始时间 LocalDateTime startTime = leg.getStartTime();