数据回推状

This commit is contained in:
huangxh3 2024-02-24 10:59:06 +08:00
parent 4ca03517c9
commit b5d87bba90
31 changed files with 379 additions and 108 deletions

View File

@ -4,6 +4,7 @@ import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.LocationRepository; import com.chint.domain.repository.LocationRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.OrderDomainService; import com.chint.domain.service.OrderDomainService;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.ly.LYPostRequest; import com.chint.interfaces.rest.ly.LYPostRequest;
@ -29,6 +30,9 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
@Autowired @Autowired
private OrderDomainService orderDomainService; private OrderDomainService orderDomainService;
@Autowired
private UserRepository userRepository;
@Override @Override
public boolean syncSupplierOrder(RouteOrder order) { public boolean syncSupplierOrder(RouteOrder order) {
String supplierOrderSyncUrl = L_Y_BASE_URL + L_Y_ORDER_PATH;//请求地址 String supplierOrderSyncUrl = L_Y_BASE_URL + L_Y_ORDER_PATH;//请求地址
@ -86,7 +90,54 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
//作废状态2 //作废状态2
order.setStatus(2); order.setStatus(2);
System.out.println("开始取消同程订单"); System.out.println("开始取消同程订单");
return syncSupplierOrder(order); String supplierOrderSyncUrl = L_Y_BASE_URL + L_Y_ORDER_PATH;//请求地址
//1.设置订单参数
SupplierOrderParam param = new SupplierOrderParam();//参数
param.setOutEmployeeIdType(0);//外部员工ID类型默认为0
// param.setOutTravelApplyNo(order.getApproveOrderNo().getActualOrderNo());//审批订单号
param.setOutTravelApplyNo(order.getRouteOrderNo());//审批订单号
param.setTravelApplyType(1); //差旅类型1 普通差旅,2 福利差旅
param.setStatus(order.getStatus());//状态1通过2作废
//日期格式化
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
String applyTime = order.getCreateTime().format(formatter);
String updateTime = order.getUpdateTime().format(formatter);
param.setTravelApplyTime(applyTime);//开始创建时间
param.setTravelUpdateTime(updateTime);//最后更新时间
param.setOperationType(1);//1新增2更新
//获取用户信息
// User user = BaseContext.getCurrentUser();
User user = userRepository.findByUserEmployeeNo(order.getUserId());
param.setOutEmployeeId(String.valueOf(order.getUserId()));//用户id
param.setTravelDescription("同程订单");//描述信息
param.setBookableProducts("1,3,5");//1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车
//2.同程的行程节点集合
List<AOSItem> aosItems = getAosItems(order);
//3.差旅人信息
List<AOSPerson> aosPeople = new ArrayList<>();
AOSPerson aosPerson = new AOSPerson();
aosPerson.setName(user.getName());//用户名
aosPerson.setRelation(0);//0:内部员工1:配偶2:子女3:父母4:面试候选人5:实习生6:外部宾客
aosPerson.setPassengerType(0);//0:成人, 1:儿童, 2:婴儿
aosPerson.setOutEmployeeId(String.valueOf(order.getUserId()));//SF号(长工号)
aosPeople.add(aosPerson);
//4.前置差旅政策
List<AOSPreTravelPolicy> aosPreTravelPolicies = new ArrayList<>();
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
aosPreTravelPolicy.setPolicyCode("");//一般指客户经理提供的差旅政策标题
aosPreTravelPolicy.setProductTypeId(0);//产品ID 1国内机票2国际机票3国内酒店4海外酒店5火车票6用车
aosPreTravelPolicies.add(aosPreTravelPolicy);
param.setItemList(aosItems); // 同程节点内容
param.setPersonList(aosPeople);// 同程信息实际出行人
param.setPreTravelPolicyList(aosPreTravelPolicies);// 同程政策
param.setApproveRuleType(0);//审批规则
SupplierOrderSyncDto supplierOrderSyncDto = new SupplierOrderSyncDto();
supplierOrderSyncDto.setParam(param);
Result result = postRequest.post(supplierOrderSyncUrl, supplierOrderSyncDto, Result.class);
System.out.println("result = " + result);
String success = result.getSuccess();
return Boolean.parseBoolean(success);
} }
//同程Leg集合解析 //同程Leg集合解析

View File

@ -111,9 +111,11 @@ public class Constant {
public static final String LEG_OTHER_AMOUNT_BUS_EN_NAME = "CoachBus"; public static final String LEG_OTHER_AMOUNT_BUS_EN_NAME = "CoachBus";
//同程订单数据回推类型 //同程订单数据回推类型
public static final int PRODUCT_TYPE_TRAIN = 0; //火车 public static final int PRODUCT_TYPE_TRAIN = 5; //火车
public static final int PRODUCT_TYPE_FLY = 1; //飞机 public static final int PRODUCT_TYPE_FLY = 1; //飞机
public static final int PRODUCT_TYPE_TRAIN_CAR = 2; //用车 public static final int PRODUCT_TYPE_COMMON = 0; //通用推送
public static final int PRODUCT_TYPE_CHAILORDER = 4; //差旅单推送
public static final int PRODUCT_TYPE_TRAIN_CAR = 6; //用车
public static final int PRODUCT_TYPE_TRAIN_HOTEL = 3; //酒店 public static final int PRODUCT_TYPE_TRAIN_HOTEL = 3; //酒店
// 规划节点事件 // 规划节点事件
@ -228,6 +230,7 @@ public class Constant {
//同程 //同程
public static final String L_Y_BASE_URL = "https://api.qa.dttrip.cn/openapi"; public static final String L_Y_BASE_URL = "https://api.qa.dttrip.cn/openapi";
public static final String L_Y_STROKE_PUSH = "/api/TravelBizOrder/ExternalApproval";//行程推送外部审批
public static final String L_Y_TOKEN_PATH = "/api/OAuth/v2/GetAccessToken"; public static final String L_Y_TOKEN_PATH = "/api/OAuth/v2/GetAccessToken";
public static final String L_Y_ORDER_PATH = "/api/TravelApplyOrder/ApplyOrderSync"; public static final String L_Y_ORDER_PATH = "/api/TravelApplyOrder/ApplyOrderSync";
public static final String L_Y_USER_PATH = "/api/Employee/SyncEmployeeInfo"; public static final String L_Y_USER_PATH = "/api/Employee/SyncEmployeeInfo";

View File

@ -1,10 +1,12 @@
package com.chint.infrastructure.repository.jdbc; package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.location.CityEntity; import com.chint.domain.aggregates.location.CityEntity;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
public interface JdbcCityRepository extends CrudRepository<CityEntity,Long> { public interface JdbcCityRepository extends CrudRepository<CityEntity,Long> {
CityEntity findByCityName(String cityName); CityEntity findByCityName(String cityName);
} }

View File

@ -10,4 +10,5 @@ import java.util.List;
public interface JdbcRanksRepository extends CrudRepository<Ranks, Integer> { public interface JdbcRanksRepository extends CrudRepository<Ranks, Integer> {
Ranks findByCompanyCodeAndRankName(String companyCode, String rankName); Ranks findByCompanyCodeAndRankName(String companyCode, String rankName);
List<Ranks> findByCompanyCode(String companyCode); List<Ranks> findByCompanyCode(String companyCode);
} }

View File

@ -10,6 +10,5 @@ import org.springframework.web.bind.annotation.RequestMapping;
@NoArgsConstructor @NoArgsConstructor
public class CTripNoteResponse { public class CTripNoteResponse {
private String errorCode; private String errorCode;
private String errorMessage; private String errorMessage;
} }

View File

@ -0,0 +1,13 @@
package com.chint.interfaces.rest.ly;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LYNoteResponse {
private String resCode;
private String resMsg;
}

View File

@ -0,0 +1,17 @@
package com.chint.interfaces.rest.ly.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Notification {
public Object notifyData;
public int notifyType; //推送类型
public int subNotifyType; //推送子类型
public long notifyTime; //推送时间戳
public String sign; //推送签名
public String soleKey; // 推送唯一秘钥
}

View File

@ -1,5 +1,6 @@
package com.chint.interfaces.rest.ly.dto.carorderdatapushback; package com.chint.interfaces.rest.ly.dto.carorderdatapushback;
import com.chint.interfaces.rest.ly.dto.Notification;
import com.chint.interfaces.rest.ly.dto.ticketpush.NotifyData; import com.chint.interfaces.rest.ly.dto.ticketpush.NotifyData;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -8,11 +9,6 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class Notification { public class NotificationCar extends Notification {
private NotifyData notifyData; private NotifyData notifyData;
private int notifyType; //推送类型
private int subNotifyType; //推送子类型
private long notifyTime; //推送时间戳
private String sign; //推送签名
private String soleKey; // 推送唯一秘钥
} }

View File

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@ -12,4 +14,7 @@ public class NotifyData {
private OrderDriver orderDriver; private OrderDriver orderDriver;
private OrderExtend orderExtend; private OrderExtend orderExtend;
private TravelData travelData; private TravelData travelData;
private List<PriceDetail> priceDetailList;
private List<SubmitItem> submitItemList;
} }

View File

@ -1,18 +0,0 @@
package com.chint.interfaces.rest.ly.dto.flydatapushback;
import com.chint.interfaces.rest.ly.dto.ticketpush.NotifyData;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
@AllArgsConstructor
public class Notification {
private OrderDetails orderDetails;
private int notifyType; //推送类型
private int subNotifyType; //推送子类型
private long notifyTime; //推送时间戳
private String sign; //推送签名
private String soleKey; // 推送唯一秘钥
}

View File

@ -0,0 +1,13 @@
package com.chint.interfaces.rest.ly.dto.flydatapushback;
import com.chint.interfaces.rest.ly.dto.Notification;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
@AllArgsConstructor
public class NotificationFly extends Notification{
private OrderDetails orderDetails;
}

View File

@ -48,6 +48,9 @@ public class OrderDetails {
private Integer refId; private Integer refId;
private boolean ruleViolate; private boolean ruleViolate;
private RuleViolateDetail ruleViolateDetail; private RuleViolateDetail ruleViolateDetail;
private TravelData travelData;
private List<Passenger> passengerList;
private List<FlightSegment> flightSegmentList;
private String foulReason; private String foulReason;
private String foulReasonCode; private String foulReasonCode;
private String foulReasonNote; private String foulReasonNote;

View File

@ -1,18 +0,0 @@
package com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach;
import com.chint.interfaces.rest.ly.dto.ticketpush.NotifyData;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
@AllArgsConstructor
public class Notification {
private OrderInfo orderInfo;
private int notifyType; //推送类型
private int subNotifyType; //推送子类型
private long notifyTime; //推送时间戳
private String sign; //推送签名
private String soleKey; // 推送唯一秘钥
}

View File

@ -0,0 +1,13 @@
package com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach;
import com.chint.interfaces.rest.ly.dto.Notification;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
@AllArgsConstructor
public class NotificationHotel extends Notification {
private OrderInfo orderInfo;
}

View File

@ -47,6 +47,14 @@ public class OrderInfo {
private String supplierOrderCreateTime; private String supplierOrderCreateTime;
private boolean ruleViolate; private boolean ruleViolate;
private RuleViolateDetail ruleViolateDetail; private RuleViolateDetail ruleViolateDetail;
private HotelInfo hotelInfo;
private DayPrice dayPrice;
private List<String> residents;
private List<Resident> residentList;
private ContactPerson contactPerson;
private RefundInfo refundInfo;
private TravelData travelData;
private List<RoomList> roomList;
private String foulReason; private String foulReason;
private String foulReasonCode; private String foulReasonCode;
private String foulReasonNote; private String foulReasonNote;

View File

@ -0,0 +1,15 @@
package com.chint.interfaces.rest.ly.dto.strokepush;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Param {
private String travelBizOrderNo;
private Integer remarks;
private Integer approvalStatus;
private Integer externalApprovalNo;
}

View File

@ -0,0 +1,32 @@
package com.chint.interfaces.rest.ly.dto.strokepush;
import com.chint.interfaces.rest.base.PostRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.chint.infrastructure.constant.Constant.L_Y_BASE_URL;
import static com.chint.infrastructure.constant.Constant.L_Y_STROKE_PUSH;
@RestController
@RequestMapping("/public/stroke")
public class StrokeController {
@Autowired
private PostRequest postRequest;
private String strokeUrl = L_Y_BASE_URL + L_Y_STROKE_PUSH;
@PostMapping("/push")
public Integer strokePush(@RequestBody StrokePushDTO strokePushDTO){
Integer status = strokePushDTO.getParam().getApprovalStatus();
if (status == 1 || status == 2){
StrokePushResult postData = postRequest.post(strokeUrl, strokePushDTO.getParam(), StrokePushResult.class);
}
return status;
}
}

View File

@ -0,0 +1,13 @@
package com.chint.interfaces.rest.ly.dto.strokepush;
import com.chint.interfaces.rest.ly.dto.LYBaseRequest;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StrokePushDTO extends LYBaseRequest {
private Param param;
}

View File

@ -0,0 +1,16 @@
package com.chint.interfaces.rest.ly.dto.strokepush;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StrokePushResult {
private Boolean success;
private String errorCode;
private String errorMessage;
private String data;
private String errorType;
}

View File

@ -1,5 +1,6 @@
package com.chint.interfaces.rest.ly.dto.ticketpush; package com.chint.interfaces.rest.ly.dto.ticketpush;
import com.chint.interfaces.rest.ly.dto.carorderdatapushback.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;

View File

@ -1,18 +0,0 @@
package com.chint.interfaces.rest.ly.dto.trainorderdatapushback;
import com.chint.interfaces.rest.ly.dto.ticketpush.NotifyData;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
@AllArgsConstructor
public class Notification {
private NotifyData notifyData;
private int notifyType; //推送类型
private int subNotifyType; //推送子类型
private long notifyTime; //推送时间戳
private String sign; //推送签名
private String soleKey; // 推送唯一秘钥
}

View File

@ -0,0 +1,14 @@
package com.chint.interfaces.rest.ly.dto.trainorderdatapushback;
import com.chint.interfaces.rest.ly.dto.Notification;
import com.chint.interfaces.rest.ly.dto.trainorderdatapushback.NotifyData;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
@AllArgsConstructor
public class NotificationTrain extends Notification {
private NotifyData notifyData;
}

View File

@ -4,17 +4,47 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class NotifyData { public class NotifyData {
private String orderNo; private String orderNo;
private String outOrderNo; private String outOrderNo;
private String issueTime;
private String msgCode; private String msgCode;
private String msgInfo; private String msgInfo;
private String fromStationCode;
private String toStationCode;
private String departureTime;
private String arrivalTime;
private String trainNo;
private String ticketNo;
private String orderAmount;
private String fromStation;
private String toStation;
private String issueTime;
private String mailCharge;
private String msgDetail;
private String ticketGate; private String ticketGate;
private String fInfo; private List<Passenger> passengers;
private boolean isSelfToProxy;
private String isChangedOrder;
private String originalOrderNo; private String originalOrderNo;
private TravelData travelData; private String changedType;
private String serviceCharge;
private String changePriceDiff;
private String expirationTime;
private String directPayInfo;
private int waitFlag;
private int payType;
private int isNeedTransfer;
private String outEmployeeId;
private String outEnterpriseId;
private int bookingMethod;
private boolean ruleViolate;
private String foulReason;
private String foulReasonCode;
private String foulReasonNote;
private RuleViolateDetail ruleViolateDetail;
} }

View File

@ -0,0 +1,26 @@
package com.chint.interfaces.rest.ly.dto.trainorderdatapushback;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Passenger {
private String passengerName;
private String passengerType;
private String cardType;
private String cardNo;
private Integer itemId;
private String seatClass;
private String seatNo;
private String price;
private String pTicketNo;
private String serviceCharge;
private String insuranceCharge;
private String oldPassengerId;
private String outEmployeeId;
// Getters and Setters...
}

View File

@ -0,0 +1,17 @@
package com.chint.interfaces.rest.ly.dto.trainorderdatapushback;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Data
public class RuleViolateDetail {
private String policyName;
private List<Object> items;
// Getters and Setters...
}

View File

@ -4,13 +4,11 @@ import com.chint.application.commands.OrderStatusChangeCommand;
import com.chint.domain.service.supplier.SupplierService; import com.chint.domain.service.supplier.SupplierService;
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 com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse; import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; import com.chint.interfaces.rest.ly.LYNoteResponse;
import com.chint.interfaces.rest.ly.LYSearchRequest; import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.dto.carorderdatapushback.Notification; import com.chint.interfaces.rest.ly.dto.carorderdatapushback.NotificationCar;
import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse;
import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderDetail;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -34,8 +32,9 @@ public class CarBackController {
@PostMapping("/back") @PostMapping("/back")
public CTripNoteResponse carBack(@RequestBody Notification notification) {
String orderSerialNo = notification.getNotifyData().getOrderSerialNo(); public LYNoteResponse carBack(@RequestBody NotificationCar notificationCar) {
String orderSerialNo = notificationCar.getNotifyData().getOrderSerialNo();
if (orderSerialNo != null) { if (orderSerialNo != null) {
CarDetailResponse carDetailResponse = lySearchRequest.getCarDetailResponse(orderSerialNo); CarDetailResponse carDetailResponse = lySearchRequest.getCarDetailResponse(orderSerialNo);
String outEmployeeId = carDetailResponse.getData().getOutEmployeeId(); //外部员工id String outEmployeeId = carDetailResponse.getData().getOutEmployeeId(); //外部员工id
@ -48,13 +47,13 @@ public class CarBackController {
OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class) OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class)
.orderNo(serialNo) .orderNo(serialNo)
.outStatus(String.valueOf(notification.getSubNotifyType())); .outStatus(String.valueOf(notificationCar.getSubNotifyType()));
command.eventType(carStatus(notification.getSubNotifyType())); command.eventType(carStatus(notificationCar.getSubNotifyType()));
command.sendToQueue(); command.sendToQueue();
return new CTripNoteResponse("0", "成功收到消息"); return new LYNoteResponse("100", "成功收到消息");
} }
return new CTripNoteResponse("1", "未收到消息"); return new LYNoteResponse("200", "未收到消息");
} }
public Integer carStatus(Integer status) { public Integer carStatus(Integer status) {
return switch (status) { return switch (status) {

View File

@ -0,0 +1,44 @@
package com.chint.interfaces.rest.ly.in;
import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse;
import com.chint.interfaces.rest.ly.LYNoteResponse;
import com.chint.interfaces.rest.ly.dto.Notification;
import com.chint.interfaces.rest.ly.dto.carorderdatapushback.NotificationCar;
import com.chint.interfaces.rest.ly.dto.flydatapushback.NotificationFly;
import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.NotificationHotel;
import com.chint.interfaces.rest.ly.dto.trainorderdatapushback.NotificationTrain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/public/common")
public class CommonController {
@Autowired
private CarBackController carBackController;
@Autowired
private FlyBackController flyBackController;
@Autowired
private HotelBackController hotelBackController;
@Autowired
private TrainBackController trainBackController;
@PostMapping("/back")
public LYNoteResponse hotelBack(@RequestBody Notification notification) {
int notifyType = notification.getNotifyType();
return switch (notifyType){
case 1 -> flyBackController.ticketBack((NotificationFly) notification);
case 3 -> hotelBackController.hotelBack((NotificationHotel) notification);
case 5 -> trainBackController.trainBack((NotificationTrain) notification);
case 6-> carBackController.carBack((NotificationCar) notification);
default -> new LYNoteResponse("200", "失败");
};
}
}

View File

@ -4,12 +4,10 @@ import com.chint.application.commands.OrderStatusChangeCommand;
import com.chint.domain.service.supplier.SupplierService; import com.chint.domain.service.supplier.SupplierService;
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 com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse; import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; import com.chint.interfaces.rest.ly.LYNoteResponse;
import com.chint.interfaces.rest.ly.LYSearchRequest; import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.dto.flydatapushback.Notification; import com.chint.interfaces.rest.ly.dto.flydatapushback.NotificationFly;
import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderDetail; import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderDetail;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -35,8 +33,8 @@ public class FlyBackController {
//机票订单数据回推 //机票订单数据回推
@PostMapping("/back") @PostMapping("/back")
public CTripNoteResponse ticketBack(@RequestBody Notification notification) { public LYNoteResponse ticketBack(@RequestBody NotificationFly notificationFly) {
String orderSerialNo = notification.getOrderDetails().getOrderSerialNo(); String orderSerialNo = notificationFly.getOrderDetails().getOrderSerialNo();
if (orderSerialNo != null) { if (orderSerialNo != null) {
FlightOrderDetail flightOrderDetail = lySearchRequest.getFlightOrderDetail(orderSerialNo); FlightOrderDetail flightOrderDetail = lySearchRequest.getFlightOrderDetail(orderSerialNo);
String outEmployeeId = flightOrderDetail.getData().getOrderDetails().getOutEmployeeId();//外部员工id String outEmployeeId = flightOrderDetail.getData().getOrderDetails().getOutEmployeeId();//外部员工id
@ -48,12 +46,12 @@ public class FlyBackController {
supplierService.handleSupplierCallback(supplierCallbackData); supplierService.handleSupplierCallback(supplierCallbackData);
OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class) OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class)
.orderNo(serialNo) .orderNo(serialNo)
.outStatus(String.valueOf(notification.getSubNotifyType())); .outStatus(String.valueOf(notificationFly.getSubNotifyType()));
command.eventType(mapFlightStatus(notification.getSubNotifyType())); command.eventType(mapFlightStatus(notificationFly.getSubNotifyType()));
command.sendToQueue(); command.sendToQueue();
return new CTripNoteResponse("0", "成功收到消息"); return new LYNoteResponse("100", "成功收到消息");
} }
return new CTripNoteResponse("1", "未收到消息"); return new LYNoteResponse("200", "未收到消息");
} }
public Integer mapFlightStatus(Integer status) { public Integer mapFlightStatus(Integer status) {

View File

@ -6,11 +6,10 @@ import com.chint.domain.value_object.SupplierCallbackData;
import com.chint.infrastructure.echo_framework.command.Command; import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest; import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse; import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; import com.chint.interfaces.rest.ly.LYNoteResponse;
import com.chint.interfaces.rest.ly.LYSearchRequest; import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Notification; import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.NotificationHotel;
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -32,14 +31,12 @@ public class HotelBackController {
@Autowired @Autowired
private SupplierService supplierService; private SupplierService supplierService;
@Autowired
private CTripOrderSearchRequest cTripOrderSearchRequest;
@PostMapping("/back") @PostMapping("/back")
public CTripNoteResponse hotelBack(@RequestBody Notification notification) { public LYNoteResponse hotelBack(@RequestBody NotificationHotel notificationHotel) {
String orderSerialNo = notification.getOrderInfo().getOrderSerialNo(); String orderSerialNo = notificationHotel.getOrderInfo().getOrderSerialNo();
if (orderSerialNo != null) { if (orderSerialNo != null) {
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail(orderSerialNo); HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail(orderSerialNo);
String outEmployeeId = hotelOrderDetail.getData().getOrderInfo().getOutEmployeeId();//外部员工id String outEmployeeId = hotelOrderDetail.getData().getOrderInfo().getOutEmployeeId();//外部员工id
@ -52,13 +49,13 @@ public class HotelBackController {
supplierService.handleSupplierCallback(supplierCallbackData); supplierService.handleSupplierCallback(supplierCallbackData);
OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class) OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class)
.orderNo(serialNo) .orderNo(serialNo)
.outStatus(String.valueOf(notification.getSubNotifyType())); .outStatus(String.valueOf(notificationHotel.getSubNotifyType()));
//状态映射 //状态映射
command.eventType(mapHotelState(notification.getSubNotifyType())); command.eventType(mapHotelState(notificationHotel.getSubNotifyType()));
command.sendToQueue(); command.sendToQueue();
return new CTripNoteResponse("0", "成功收到消息"); return new LYNoteResponse("100", "成功收到消息");
} }
return new CTripNoteResponse("1", "未收到消息"); return new LYNoteResponse("200", "未收到消息");
} }

View File

@ -4,12 +4,11 @@ import com.chint.application.commands.OrderStatusChangeCommand;
import com.chint.domain.service.supplier.SupplierService; import com.chint.domain.service.supplier.SupplierService;
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 com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse; import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; import com.chint.interfaces.rest.ly.LYNoteResponse;
import com.chint.interfaces.rest.ly.LYSearchRequest; import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
import com.chint.interfaces.rest.ly.dto.trainorderdatapushback.Notification; import com.chint.interfaces.rest.ly.dto.trainorderdatapushback.NotificationTrain;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -32,8 +31,8 @@ public class TrainBackController {
private SupplierService supplierService; private SupplierService supplierService;
@PostMapping("/back") @PostMapping("/back")
public CTripNoteResponse trainBack(@RequestBody Notification notification) { public LYNoteResponse trainBack(@RequestBody NotificationTrain notificationTrain) {
String orderSerialNo = notification.getNotifyData().getOrderSerialNo(); String orderSerialNo = notificationTrain.getNotifyData().getOrderSerialNo();
if (orderSerialNo != null) { if (orderSerialNo != null) {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail(orderSerialNo); TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail(orderSerialNo);
String outEmployeeId = trainOrderDetail.getData().getOutEmployeeId();//外部员工id String outEmployeeId = trainOrderDetail.getData().getOutEmployeeId();//外部员工id
@ -45,13 +44,13 @@ public class TrainBackController {
supplierService.handleSupplierCallback(supplierCallbackData); supplierService.handleSupplierCallback(supplierCallbackData);
OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class) OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class)
.orderNo(serialNo) .orderNo(serialNo)
.outStatus(String.valueOf(notification.getSubNotifyType())); .outStatus(String.valueOf(notificationTrain.getSubNotifyType()));
command.eventType(mapTrainState(notification.getSubNotifyType())); command.eventType(mapTrainState(notificationTrain.getSubNotifyType()));
command.sendToQueue(); command.sendToQueue();
return new CTripNoteResponse("0", "成功收到消息"); return new LYNoteResponse("100", "成功收到消息");
} }
return new CTripNoteResponse("1", "未收到消息"); return new LYNoteResponse("200", "未收到消息");
} }
public Integer mapTrainState(Integer status) { public Integer mapTrainState(Integer status) {
return switch (status) { return switch (status) {