diff --git a/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java index 22ad47fb..b1b0d141 100644 --- a/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java @@ -11,6 +11,7 @@ import com.chint.interfaces.rest.ctrip.dto.search.train.TrainOrderInfoEntity; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Optional; import static com.chint.infrastructure.constant.Constant.*; @@ -18,19 +19,24 @@ import static com.chint.infrastructure.constant.Constant.*; @Component public class CTripOrderDataAdapter implements OrderDataAdapter { @Override - public OrderLegData adapt(SupplierCallbackData supplierData) { + public Optional adapt(SupplierCallbackData supplierData) { //这里的查询结果的订单查询 ,需要根据订单单号来进行查询的结果,因此只会返回一个订单信息和对应的行程规划单 SearchOrderResponse searchOrderResponse = (SearchOrderResponse) supplierData.getData(); - if (!searchOrderResponse.getItineraryList().isEmpty()) { - ItineraryEntity itineraryEntity = searchOrderResponse.getItineraryList().get(0); + List itineraryList = searchOrderResponse.getItineraryList(); + if (!itineraryList.isEmpty()) { + ItineraryEntity itineraryEntity = itineraryList.get(0); OrderLegData.Builder builder = OrderLegData.builder() .actualOrderNo(itineraryEntity.getJourneyNO()) .supplierName(SUPPLIER_C_TRIP); - + OrderLegData.Builder elementList = findSingleElementList(itineraryEntity, builder); + if (elementList == null) { + return Optional.empty(); + } + return Optional.of(elementList.build()); } - return null; + return Optional.empty(); } private OrderLegData.Builder findSingleElementList(ItineraryEntity itineraryEntity, diff --git a/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java index 78d1089e..c0e126ce 100644 --- a/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java @@ -2,12 +2,48 @@ package com.chint.domain.service.supplier; import com.chint.domain.value_object.OrderLegData; import com.chint.domain.value_object.SupplierCallbackData; +import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderDetail; +import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse; import org.springframework.stereotype.Component; +import java.util.Optional; + +import static com.chint.infrastructure.constant.Constant.LEG_TYPE_TRAIN; +import static com.chint.infrastructure.constant.Constant.SUPPLIER_L_Y; + @Component -public class LYOrderDataAdapter implements OrderDataAdapter{ +public class LYOrderDataAdapter implements OrderDataAdapter { @Override - public OrderLegData adapt(SupplierCallbackData supplierData) { - return null; + public Optional adapt(SupplierCallbackData supplierData) { + + + return Optional.empty(); + } + + private Optional trainDataProcess(TrainDetailResponse trainDetailResponse) { + TrainDetailResponse.TrainDetailData data = trainDetailResponse.getData(); + return Optional.of( + OrderLegData.builder() + .productType(LEG_TYPE_TRAIN) + .orderNo(data.getOrderNo()) + .price(String.valueOf( data.getTotalAmount())) + .actualOrderNo(data.getOutOrderNo()) + .supplierName(SUPPLIER_L_Y) + .build() + ); + } + + + private Optional FlightDataProcess(FlightOrderDetail flightOrderDetail) { + FlightOrderDetail.Data data = flightOrderDetail.getData(); + return Optional.of( + OrderLegData.builder() + .productType(LEG_TYPE_TRAIN) +// .orderNo(data.get()) +// .price(String.valueOf( data.getTotalAmount())) +// .actualOrderNo(data.getOutOrderNo()) + .supplierName(SUPPLIER_L_Y) + .build() + ); } } diff --git a/src/main/java/com/chint/domain/service/supplier/OrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/OrderDataAdapter.java index 9dcf7ab2..f3844a56 100644 --- a/src/main/java/com/chint/domain/service/supplier/OrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/OrderDataAdapter.java @@ -3,6 +3,8 @@ package com.chint.domain.service.supplier; import com.chint.domain.value_object.OrderLegData; import com.chint.domain.value_object.SupplierCallbackData; +import java.util.Optional; + public interface OrderDataAdapter { - OrderLegData adapt(SupplierCallbackData supplierData); + Optional adapt(SupplierCallbackData supplierData); } diff --git a/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java b/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java index c9a56f07..34359d34 100644 --- a/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java +++ b/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java @@ -1,7 +1,6 @@ package com.chint.domain.service.supplier; import com.chint.application.commands.RouteAddOrderCommand; -import com.chint.domain.value_object.OrderLegData; import com.chint.domain.value_object.SupplierCallbackData; import com.chint.infrastructure.echo_framework.command.Command; import org.springframework.beans.factory.annotation.Autowired; @@ -15,9 +14,10 @@ public class SupplierServiceImpl implements SupplierService { @Override public void handleSupplierCallback(SupplierCallbackData callbackData) { - OrderLegData data = orderDataAdapterSelector + orderDataAdapterSelector .of(callbackData.getSupplierName()) - .adapt(callbackData); - Command.of(RouteAddOrderCommand.class).data(data).sendToQueue(); + .adapt(callbackData) + .ifPresent(data -> + Command.of(RouteAddOrderCommand.class).data(data).sendToQueue()); } } diff --git a/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java b/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java index 5ab905c2..73186919 100644 --- a/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java +++ b/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java @@ -6,6 +6,7 @@ import lombok.Data; public class SupplierCallbackData { private String supplierName; private String employeeNo; + private Integer productType; //用于区分同程搜索数据 private Object data; public static SupplierCallbackData of(String supplierName) { diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarOrderInfoEntity.java new file mode 100644 index 00000000..cd06a3de --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class CarOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/FlightOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/FlightOrderInfoEntity.java new file mode 100644 index 00000000..94169f44 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/FlightOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class FlightOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/HotelOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/HotelOrderInfoEntity.java new file mode 100644 index 00000000..65c01773 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/HotelOrderInfoEntity.java @@ -0,0 +1,7 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +import lombok.Data; + +@Data +public class HotelOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/TrainOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/TrainOrderInfoEntity.java new file mode 100644 index 00000000..ff8cdfee --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/TrainOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class TrainOrderInfoEntity { +}