初始化代码
This commit is contained in:
parent
fb5c0d1e60
commit
3594267e0b
|
@ -11,6 +11,7 @@ import com.chint.interfaces.rest.ctrip.dto.search.train.TrainOrderInfoEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.Constant.*;
|
import static com.chint.infrastructure.constant.Constant.*;
|
||||||
|
|
||||||
|
@ -18,19 +19,24 @@ import static com.chint.infrastructure.constant.Constant.*;
|
||||||
@Component
|
@Component
|
||||||
public class CTripOrderDataAdapter implements OrderDataAdapter {
|
public class CTripOrderDataAdapter implements OrderDataAdapter {
|
||||||
@Override
|
@Override
|
||||||
public OrderLegData adapt(SupplierCallbackData supplierData) {
|
public Optional<OrderLegData> adapt(SupplierCallbackData supplierData) {
|
||||||
//这里的查询结果的订单查询 ,需要根据订单单号来进行查询的结果,因此只会返回一个订单信息和对应的行程规划单
|
//这里的查询结果的订单查询 ,需要根据订单单号来进行查询的结果,因此只会返回一个订单信息和对应的行程规划单
|
||||||
SearchOrderResponse searchOrderResponse = (SearchOrderResponse) supplierData.getData();
|
SearchOrderResponse searchOrderResponse = (SearchOrderResponse) supplierData.getData();
|
||||||
if (!searchOrderResponse.getItineraryList().isEmpty()) {
|
List<ItineraryEntity> itineraryList = searchOrderResponse.getItineraryList();
|
||||||
ItineraryEntity itineraryEntity = searchOrderResponse.getItineraryList().get(0);
|
if (!itineraryList.isEmpty()) {
|
||||||
|
ItineraryEntity itineraryEntity = itineraryList.get(0);
|
||||||
|
|
||||||
OrderLegData.Builder builder = OrderLegData.builder()
|
OrderLegData.Builder builder = OrderLegData.builder()
|
||||||
.actualOrderNo(itineraryEntity.getJourneyNO())
|
.actualOrderNo(itineraryEntity.getJourneyNO())
|
||||||
.supplierName(SUPPLIER_C_TRIP);
|
.supplierName(SUPPLIER_C_TRIP);
|
||||||
|
|
||||||
|
OrderLegData.Builder elementList = findSingleElementList(itineraryEntity, builder);
|
||||||
|
if (elementList == null) {
|
||||||
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return null;
|
return Optional.of(elementList.build());
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderLegData.Builder findSingleElementList(ItineraryEntity itineraryEntity,
|
private OrderLegData.Builder findSingleElementList(ItineraryEntity itineraryEntity,
|
||||||
|
|
|
@ -2,12 +2,48 @@ package com.chint.domain.service.supplier;
|
||||||
|
|
||||||
import com.chint.domain.value_object.OrderLegData;
|
import com.chint.domain.value_object.OrderLegData;
|
||||||
import com.chint.domain.value_object.SupplierCallbackData;
|
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 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
|
@Component
|
||||||
public class LYOrderDataAdapter implements OrderDataAdapter{
|
public class LYOrderDataAdapter implements OrderDataAdapter {
|
||||||
@Override
|
@Override
|
||||||
public OrderLegData adapt(SupplierCallbackData supplierData) {
|
public Optional<OrderLegData> adapt(SupplierCallbackData supplierData) {
|
||||||
return null;
|
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Optional<OrderLegData> 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<OrderLegData> 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()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.chint.domain.service.supplier;
|
||||||
import com.chint.domain.value_object.OrderLegData;
|
import com.chint.domain.value_object.OrderLegData;
|
||||||
import com.chint.domain.value_object.SupplierCallbackData;
|
import com.chint.domain.value_object.SupplierCallbackData;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface OrderDataAdapter {
|
public interface OrderDataAdapter {
|
||||||
OrderLegData adapt(SupplierCallbackData supplierData);
|
Optional<OrderLegData> adapt(SupplierCallbackData supplierData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.chint.domain.service.supplier;
|
package com.chint.domain.service.supplier;
|
||||||
|
|
||||||
import com.chint.application.commands.RouteAddOrderCommand;
|
import com.chint.application.commands.RouteAddOrderCommand;
|
||||||
import com.chint.domain.value_object.OrderLegData;
|
|
||||||
import com.chint.domain.value_object.SupplierCallbackData;
|
import com.chint.domain.value_object.SupplierCallbackData;
|
||||||
import com.chint.infrastructure.echo_framework.command.Command;
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -15,9 +14,10 @@ public class SupplierServiceImpl implements SupplierService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSupplierCallback(SupplierCallbackData callbackData) {
|
public void handleSupplierCallback(SupplierCallbackData callbackData) {
|
||||||
OrderLegData data = orderDataAdapterSelector
|
orderDataAdapterSelector
|
||||||
.of(callbackData.getSupplierName())
|
.of(callbackData.getSupplierName())
|
||||||
.adapt(callbackData);
|
.adapt(callbackData)
|
||||||
Command.of(RouteAddOrderCommand.class).data(data).sendToQueue();
|
.ifPresent(data ->
|
||||||
|
Command.of(RouteAddOrderCommand.class).data(data).sendToQueue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||||
public class SupplierCallbackData {
|
public class SupplierCallbackData {
|
||||||
private String supplierName;
|
private String supplierName;
|
||||||
private String employeeNo;
|
private String employeeNo;
|
||||||
|
private Integer productType; //用于区分同程搜索数据
|
||||||
private Object data;
|
private Object data;
|
||||||
|
|
||||||
public static SupplierCallbackData of(String supplierName) {
|
public static SupplierCallbackData of(String supplierName) {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.chint.interfaces.rest.ctrip.dto.search;
|
||||||
|
|
||||||
|
public class CarOrderInfoEntity {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.chint.interfaces.rest.ctrip.dto.search;
|
||||||
|
|
||||||
|
public class FlightOrderInfoEntity {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.chint.interfaces.rest.ctrip.dto.search;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class HotelOrderInfoEntity {
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.chint.interfaces.rest.ctrip.dto.search;
|
||||||
|
|
||||||
|
public class TrainOrderInfoEntity {
|
||||||
|
}
|
Loading…
Reference in New Issue