diff --git a/src/main/java/com/chint/application/out/OrderOutController.java b/src/main/java/com/chint/application/out/OrderOutController.java index 515d500a..3a301987 100644 --- a/src/main/java/com/chint/application/out/OrderOutController.java +++ b/src/main/java/com/chint/application/out/OrderOutController.java @@ -21,11 +21,16 @@ import static com.chint.infrastructure.constant.Constant.SUCCESS; public class OrderOutController { - - @Autowired private OrderQuery orderQuery; + @ApiOperation("根据临时单号查询订单") + @PostMapping("/query/billcode") + public Result queryOrderByBillCode(@RequestBody OrderQueryData queryData) { + return Result.Success(SUCCESS, orderQuery.queryByBillCode(queryData.getBillcode()).reloadStatus()); + } + + @ApiOperation("查询行程规划订单详情") @PostMapping("/query") public Result queryOrder(@RequestBody OrderQueryData queryData) { diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index be3379b5..b1f7c3d2 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -1,11 +1,9 @@ package com.chint.application.queryies; import com.chint.domain.aggregates.order.RouteOrder; -import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.RouteRepository; import com.chint.domain.service.OrderDomainService; import com.chint.domain.value_object.OrderQueryData; -import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -36,4 +34,8 @@ public class OrderQuery { orderDomainService.queryLocation(routeOrder.getLegItems()); return routeOrder; } + + public RouteOrder queryByBillCode(String billCode) { + return routeRepository.findByFakeOrderNo(billCode); + } } diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java index bf7b29de..09fb67b5 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java @@ -77,7 +77,7 @@ public class LegEventServiceImpl implements LegEventService { @Override public void syncLeg(LegSyncCommand command) { SyncLegData data = command.getData(); - RouteOrder routeOrder = routeRepository.queryById(data.getRouteId()); + RouteOrder routeOrder = routeRepository.queryById(data.getRouteId()).reloadStatus(); if (routeOrder.getOrderStatus().equals(ORDER_STATUS_APPROVAL)) { String supplierName = data.getSupplierName(); routeOrder.setSupplierName(supplierName); @@ -85,9 +85,9 @@ public class LegEventServiceImpl implements LegEventService { routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( legEventFactory.creatLegEvent(command.getLegEventType()) )); - syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus()); //保存routeOrder的状态 routeRepository.save(routeOrder); + syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus()); } else { throw new CommandException("订单未提交审批"); } 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 9d9f86ea..c40cd2bb 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 @@ -8,10 +8,17 @@ import com.chint.domain.repository.LocationRepository; import com.chint.infrastructure.util.BaseContext; import com.chint.interfaces.rest.ctrip.CTripApprovalRequest; import com.chint.interfaces.rest.ctrip.dto.approval.ApprovalRequest; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; +import com.chint.interfaces.rest.ctrip.dto.approval.hotel.HotelEndorsementDetail; import com.chint.interfaces.rest.ctrip.dto.approval.quick.RankInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; + +import static com.chint.infrastructure.constant.Constant.LEG_TYPE_HOTEL; + @Component public class CTripOrderSyncAdapter implements SupplierOrderSync { @@ -26,13 +33,29 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync { @Override public void syncSupplierOrder(RouteOrder order) { -// User currentUser = BaseContext.getCurrentUser(); -// ApproveOrderNo approveOrderNo = order.getApproveOrderNo(); -// new RankInfo() -// ApprovalRequest.buildApproval(currentUser.getEmployeeNo(), approveOrderNo.getActualOrderNo(), ) -// -// approvalRequest.approval() -// -// System.out.println("开始同步协程订单"); + System.out.println("开始同步协程订单"); + User currentUser = BaseContext.getCurrentUser(); + ApproveOrderNo approveOrderNo = order.getApproveOrderNo(); + 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()) + ); + } + } + ); + ApprovalRequest approvalRequestParam = ApprovalRequest.buildApproval(String.valueOf(currentUser.getEmployeeNo()), approveOrderNo.getActualOrderNo(), rankInfo) + .withHotel(hotelList); + approvalRequest.approval(approvalRequestParam); } } 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 d65a3503..d4e9ad1d 100644 --- a/src/main/java/com/chint/domain/value_object/OrderQueryData.java +++ b/src/main/java/com/chint/domain/value_object/OrderQueryData.java @@ -6,4 +6,6 @@ import lombok.Data; @Data public class OrderQueryData extends BaseQuery { private Long routeId; + + private String billcode; } diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java index f7030788..f3af53cb 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java @@ -26,6 +26,7 @@ public class RouteRepositoryImpl implements RouteRepository { return jdbcRouteRepository.findByRouteId(orderId); } + @Override public RouteOrder findByFakeOrderNo(String fakeOrderNo) { return jdbcRouteRepository.findByApproveOrderNo_FakeOrderNo(fakeOrderNo); diff --git a/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java new file mode 100644 index 00000000..8c984e4a --- /dev/null +++ b/src/main/java/com/chint/infrastructure/util/DateTimeUtil.java @@ -0,0 +1,12 @@ +package com.chint.infrastructure.util; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class DateTimeUtil { + + public static String timeToStr(LocalDateTime input) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + return input.format(formatter); + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/PassengerDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/PassengerDetail.java index ac04c051..9927ced7 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/PassengerDetail.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/PassengerDetail.java @@ -1,7 +1,10 @@ package com.chint.interfaces.rest.ctrip.dto.approval; +import lombok.Data; + import java.util.List; +@Data public class PassengerDetail { // 姓名 - 必填 @@ -62,4 +65,10 @@ public class PassengerDetail { // Getters and setters for each field would be included below... + public static PassengerDetail of(String employeeNo) { + PassengerDetail passengerDetail = new PassengerDetail(); + passengerDetail.setEID(employeeNo); + return passengerDetail; + } + } \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelEndorsementDetail.java index 2451991e..68387183 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelEndorsementDetail.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelEndorsementDetail.java @@ -1,71 +1,103 @@ package com.chint.interfaces.rest.ctrip.dto.approval.hotel; +import com.chint.infrastructure.util.DateTimeUtil; import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; +import lombok.Data; +import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; + +@Data public class HotelEndorsementDetail { - + // 产品类型 private HotelProductTypeEnum productType; - + // 入住开始日期 - 格式: yyyy-MM-dd private String checkInDateBegin; - + // 入住结束日期 - 格式: yyyy-MM-dd private String checkInDateEnd; - + // 离店开始日期 - 格式: yyyy-MM-dd private String checkOutDateBegin; - + // 离店结束日期 - 格式: yyyy-MM-dd private String checkOutDateEnd; - + // 乘客列表 private List passengerList; - + // 入住国家ID列表 private List checkInCountryIds; - + // 入住国家代码列表 private List checkInCountryCodes; - + // 入住城市代码列表 private List checkInCityCodes; - + // 最高价格 private String maxPrice; - + // 最低价格 private String minPrice; - + // 货币类型 - 默认CNY private CurrencyType currency; - + // 最大星级 private String maxStarRating; - + // 最小星级 private String minStarRating; - + // 平均价格 private String averagePrice; - + // 房间数量 private int roomCount; - + // 跳过的字段位 - 用于标记不包含的字段 private long skipFields; - + // 总房晚数 private int totalRoomNightCount; - + // 房晚价格 private String roomNightPrice; - + // 预验证字段位 - 用于标记需要预验证的字段 private long preVerifyFields; // Getters and setters... + + public static HotelEndorsementDetail of(List cityCodes) { + HotelEndorsementDetail hotelEndorsementDetail = new HotelEndorsementDetail(); + hotelEndorsementDetail.setCheckInCityCodes(cityCodes); + return hotelEndorsementDetail; + } + + public HotelEndorsementDetail passenger(PassengerDetail passengerDetail) { + if (this.passengerList == null) { + this.passengerList = new ArrayList<>(); + } + this.passengerList.add(passengerDetail); + return this; + } + + public HotelEndorsementDetail starTime(LocalDateTime startTime) { + this.checkInDateBegin = DateTimeUtil.timeToStr(startTime); + this.checkOutDateBegin = DateTimeUtil.timeToStr(startTime); + return this; + } + + public HotelEndorsementDetail endTime(LocalDateTime endTime) { + this.checkInDateEnd = DateTimeUtil.timeToStr(endTime); + this.checkOutDateEnd = DateTimeUtil.timeToStr(endTime); + return this; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java index 08f9b334..11dd4320 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java +++ b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java @@ -47,8 +47,8 @@ public class UserHttpRequestImpl implements UserHttpRequest { level = level.substring(0, level.length() - 3) + "M0"; } TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level)); - user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE()); -// user.setRankCode("M0"); +// user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE()); + user.setRankCode("测试职级"); return user; }