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);