From f82a5d68003a250d88cd85f901aeb62795646f68 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Tue, 6 Feb 2024 16:01:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=BC=BA=E5=B0=91=E4=BA=8B=E5=8A=A1=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chint/application/in/OrderController.java | 6 ++++ .../order_sync/CTripOrderSyncAdapter.java | 36 +++++++++++-------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/chint/application/in/OrderController.java b/src/main/java/com/chint/application/in/OrderController.java index 57b77709..ea6453af 100644 --- a/src/main/java/com/chint/application/in/OrderController.java +++ b/src/main/java/com/chint/application/in/OrderController.java @@ -7,6 +7,7 @@ import com.chint.domain.value_object.*; import com.chint.infrastructure.util.Result; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -24,6 +25,8 @@ public class OrderController { @Autowired private OrderQuery orderQuery; + + @Transactional @ApiOperation("保存行程规划单") @PostMapping("/save") public Result creatOrder(@RequestBody OrderSaveData orderCreateData) { @@ -31,6 +34,8 @@ public class OrderController { return Result.Success(SUCCESS); } + + @Transactional @ApiOperation("提交审批行程规划单") @PostMapping("/approve") public Result approveOrder(@RequestBody ApproveLegData approveLegData) { @@ -38,6 +43,7 @@ public class OrderController { return Result.Success(SUCCESS); } + @Transactional @ApiOperation("同步行程规划单到供应商") @PostMapping("/sync") public Result syncOrder(@RequestBody SyncLegData syncLegData) { diff --git a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java index c40cd2bb..497cda7c 100644 --- a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java @@ -5,6 +5,7 @@ import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.CityRepository; import com.chint.domain.repository.LocationRepository; +import com.chint.domain.service.OrderDomainService; import com.chint.infrastructure.util.BaseContext; import com.chint.interfaces.rest.ctrip.CTripApprovalRequest; import com.chint.interfaces.rest.ctrip.dto.approval.ApprovalRequest; @@ -31,6 +32,10 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync { @Autowired private LocationRepository locationRepository; + + @Autowired + private OrderDomainService orderDomainService; + @Override public void syncSupplierOrder(RouteOrder order) { System.out.println("开始同步协程订单"); @@ -39,21 +44,22 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync { RankInfo rankInfo = RankInfo.of(currentUser.getRankCode()); List cityCode = new ArrayList<>(); List hotelList = new ArrayList<>(); - order.getLegItems().forEach( - leg -> { - cityCode.add( - cityRepository.findByCityName(leg.getOriginLocation().getLocationName()).getCity() - ); - if (leg.getLegType().equals(LEG_TYPE_HOTEL)) { - hotelList.add( - HotelEndorsementDetail.of(cityCode.stream().distinct().toList()) - .passenger(PassengerDetail.of(String.valueOf(currentUser.getEmployeeNo()))) - .starTime(leg.getStartTime()) - .endTime(leg.getEndTime()) - ); - } - } - ); + orderDomainService.queryLocation(order.getLegItems()) + .forEach( + leg -> { + cityCode.add( + cityRepository.findByCityName(leg.getOriginLocation().getLocationName()).getCity() + ); + if (leg.getLegType().equals(LEG_TYPE_HOTEL)) { + hotelList.add( + HotelEndorsementDetail.of(cityCode.stream().distinct().toList()) + .passenger(PassengerDetail.of(String.valueOf(currentUser.getEmployeeNo()))) + .starTime(leg.getStartTime()) + .endTime(leg.getEndTime()) + ); + } + } + ); ApprovalRequest approvalRequestParam = ApprovalRequest.buildApproval(String.valueOf(currentUser.getEmployeeNo()), approveOrderNo.getActualOrderNo(), rankInfo) .withHotel(hotelList); approvalRequest.approval(approvalRequestParam);