fix:修复无法兼容同程超标推送出现中转的情况

This commit is contained in:
lulz1 2024-04-19 13:00:45 +08:00
parent ee3a7afd3a
commit 62590400ad
4 changed files with 80 additions and 68 deletions

View File

@ -3,30 +3,21 @@ package com.chint.domain.service;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.commands.*; import com.chint.application.commands.*;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.system.ProcessInitiationControl;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.exceptions.OrderException; import com.chint.domain.exceptions.OrderException;
import com.chint.domain.factoriy.leg_event.LegEventFactory; import com.chint.domain.factoriy.leg_event.LegEventFactory;
import com.chint.domain.factoriy.order.RouteOrderFactory; import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.factoriy.order_detail.OrderDetailFactory; import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
import com.chint.domain.repository.*; import com.chint.domain.repository.*;
import com.chint.domain.value_object.ApprovalSimpleData;
import com.chint.domain.value_object.ApproveRouteData; import com.chint.domain.value_object.ApproveRouteData;
import com.chint.domain.value_object.UserLoginParam; import com.chint.domain.value_object.UserLoginParam;
import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.constant.RouteConstant; import com.chint.infrastructure.constant.RouteConstant;
import com.chint.infrastructure.echo_framework.annotation.ListenTo; import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import com.chint.infrastructure.echo_framework.command.Command; import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcLegRepository; import com.chint.infrastructure.repository.jdbc.JdbcLegRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
import com.chint.infrastructure.repository.jdbc.JdbcProcessInitiationControlRepository;
import com.chint.infrastructure.util.DelayDispatch;
import com.chint.interfaces.rest.bpm.BPMParamFactory; import com.chint.interfaces.rest.bpm.BPMParamFactory;
import com.chint.interfaces.rest.bpm.BPMRequest; import com.chint.interfaces.rest.bpm.BPMRequest;
import com.chint.interfaces.rest.bpm.dto.ANExceedStandardDto;
import com.chint.interfaces.rest.bpm.dto.ExceedStandardDto;
import com.chint.interfaces.rest.bpm.dto.RescheduleDto;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest; import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity; import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
@ -44,23 +35,22 @@ import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailRespons
import com.chint.interfaces.rest.user.UserHttpRequest; import com.chint.interfaces.rest.user.UserHttpRequest;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import static com.chint.infrastructure.constant.BPMConstant.*;
import static com.chint.infrastructure.constant.BelongSystemConstant.BELONG_SYS_CODE_ANFSSC;
import static com.chint.infrastructure.constant.CommonMessageConstant.COMPANY_NAME_IN_BLACK_LIST; import static com.chint.infrastructure.constant.CommonMessageConstant.COMPANY_NAME_IN_BLACK_LIST;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.OrderConstant.*; import static com.chint.infrastructure.constant.OrderConstant.*;
import static com.chint.infrastructure.constant.RouteConstant.APPROVAL_EVENT_ING; import static com.chint.infrastructure.constant.RouteConstant.APPROVAL_EVENT_ING;
import static com.chint.infrastructure.constant.SupplierNameConstant.*; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y;
@Slf4j @Slf4j
@Service @Service
@ -220,6 +210,11 @@ public class OrderDomainService {
Integer orderEventType = command.getOrderEventType(); Integer orderEventType = command.getOrderEventType();
OrderEvent event = orderDetailFactory.createEvent(orderEventType, OrderEvent event = orderDetailFactory.createEvent(orderEventType,
outStatus); outStatus);
if (orderEventType.equals(ORDER_EVENT_ETA) ||
orderEventType.equals(ORDER_EVENT_CHANGE) ||
orderEventType.equals(ORDER_EVENT_REFUND)) {
event.setExtension(command.getExtension());
}
orderDetail.addOrderEvent(event); orderDetail.addOrderEvent(event);
orderDetailRepository.save(orderDetail); orderDetailRepository.save(orderDetail);

View File

@ -35,7 +35,7 @@ public class SupplierCallbackData {
return this; return this;
} }
public SupplierCallbackData extension(String daextensionta) { public SupplierCallbackData extension(String extension) {
this.extension = extension; this.extension = extension;
return this; return this;
} }

View File

@ -1,6 +1,6 @@
package com.chint.interfaces.rest.ly.in; package com.chint.interfaces.rest.ly.in;
import com.alibaba.fastjson.JSON; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.commands.OrderStatusChangeCommand; import com.chint.application.commands.OrderStatusChangeCommand;
import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.OrderTravel; import com.chint.domain.aggregates.order.OrderTravel;
@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -85,11 +86,13 @@ public class LYETAController {
} }
SupplierCallbackData supplierCallbackData = handlerETACallBackData(lyETAPush); List<SupplierCallbackData> supplierCallbackDataList = handlerETACallBackData(lyETAPush);
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
for (SupplierCallbackData supplierCallbackData : supplierCallbackDataList) {
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId)); orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId));
if (supplierCallbackData.getExtension() != null) {
//发送超标事件 //发送超标事件
Command.of(OrderStatusChangeCommand.class) Command.of(OrderStatusChangeCommand.class)
.orderDetail(orderDetail) .orderDetail(orderDetail)
@ -98,6 +101,7 @@ public class LYETAController {
.eventType(ORDER_EVENT_ETA) .eventType(ORDER_EVENT_ETA)
.orderNo(orderDetail.getOrderNo()) .orderNo(orderDetail.getOrderNo())
.sendToQueue(); .sendToQueue();
}
int subNotifyType = lyETAPush.getSubNotifyType(); int subNotifyType = lyETAPush.getSubNotifyType();
if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) { if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) {
@ -110,12 +114,12 @@ public class LYETAController {
.orderNo(orderDetail.getOrderNo()) .orderNo(orderDetail.getOrderNo())
.sendToQueue(); .sendToQueue();
} }
}
return LYNoteResponse.success(); return LYNoteResponse.success();
} }
private SupplierCallbackData handlerETACallBackData(LyETAPush lyETAPush) { private List<SupplierCallbackData> handlerETACallBackData(LyETAPush lyETAPush) {
LyETAPush.NotifyData notifyData = lyETAPush.getNotifyDataObject(); LyETAPush.NotifyData notifyData = lyETAPush.getNotifyDataObject();
String bookEmpId = notifyData.getBookEmpId(); String bookEmpId = notifyData.getBookEmpId();
SupplierCallbackData supplierCallbackData = SupplierCallbackData supplierCallbackData =
@ -123,21 +127,21 @@ public class LYETAController {
LyETAPush.OrderInfo orderInfos = notifyData.getOrderInfos(); LyETAPush.OrderInfo orderInfos = notifyData.getOrderInfos();
//如果子类型是1 那么就要自己去找出是那种类型的 //如果子类型是1 那么就要自己去找出是那种类型的
if (lyETAPush.getSubNotifyType() == 1) { if (lyETAPush.getSubNotifyType() == 1) {
handleCommonETA(orderInfos, supplierCallbackData); return handleCommonETA(orderInfos, supplierCallbackData);
} else if (lyETAPush.getSubNotifyType() == 2) { } else if (lyETAPush.getSubNotifyType() == 2) {
//子类型为2代表机票改签超标 //子类型为2代表机票改签超标
searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_AIRPLANE); return searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_AIRPLANE);
} else if (lyETAPush.getSubNotifyType() == 4) { } else if (lyETAPush.getSubNotifyType() == 4) {
//子类型为4代表火车改签超标 //子类型为4代表火车改签超标
searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_TRAIN); return searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_TRAIN);
} else if (lyETAPush.getSubNotifyType() == 6) { } else if (lyETAPush.getSubNotifyType() == 6) {
//子类型为6代表酒店变更超标 //子类型为6代表酒店变更超标
searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_HOTEL); return searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_HOTEL);
} }
return supplierCallbackData; return List.of(supplierCallbackData);
} }
private SupplierCallbackData handleCommonETA(LyETAPush.OrderInfo orderInfos, SupplierCallbackData supplierCallbackData) { private List<SupplierCallbackData> handleCommonETA(LyETAPush.OrderInfo orderInfos, SupplierCallbackData supplierCallbackData) {
Integer productType = findProductType(orderInfos); Integer productType = findProductType(orderInfos);
if (productType == null) { if (productType == null) {
throw new NotFoundException(NOT_FOUND); throw new NotFoundException(NOT_FOUND);
@ -145,38 +149,48 @@ public class LYETAController {
return searchOrderDetailByProductType(orderInfos, supplierCallbackData, productType); return searchOrderDetailByProductType(orderInfos, supplierCallbackData, productType);
} }
private SupplierCallbackData searchOrderDetailByProductType(LyETAPush.OrderInfo orderInfos, SupplierCallbackData supplierCallbackData, Integer productType) { private List<SupplierCallbackData> searchOrderDetailByProductType(LyETAPush.OrderInfo orderInfos, SupplierCallbackData supplierCallbackData, Integer productType) {
List<SupplierCallbackData> res = new ArrayList<>();
switch (productType) { switch (productType) {
case LEG_TYPE_AIRPLANE -> { case LEG_TYPE_AIRPLANE -> {
List<LyETAPush.FlightOrderInfo> flightOrderInfos = orderInfos.getFlightOrderInfos(); List<LyETAPush.FlightOrderInfo> flightOrderInfos = orderInfos.getFlightOrderInfos();
if (flightOrderInfos != null && !flightOrderInfos.isEmpty()) { if (flightOrderInfos != null && !flightOrderInfos.isEmpty()) {
LyETAPush.FlightOrderInfo flightOrderInfo = flightOrderInfos.get(0); for (LyETAPush.FlightOrderInfo flightOrderInfo : flightOrderInfos) {
SupplierCallbackData copySupplierCallbackData = BeanUtil.copyProperties(supplierCallbackData, SupplierCallbackData.class);
FlightOrderResponse.Data data = lySearchRequest FlightOrderResponse.Data data = lySearchRequest
.getFlightOrderDetail(flightOrderInfo.getOrderNo()).getData(); .getFlightOrderDetail(flightOrderInfo.getOrderNo()).getData();
supplierCallbackData.data(data).extension(getETAReason(flightOrderInfo)).productType(L_Y_PRODUCT_TYPE_FLY); copySupplierCallbackData.data(data).extension(getETAReason(flightOrderInfo)).productType(L_Y_PRODUCT_TYPE_FLY);
res.add(copySupplierCallbackData);
}
} }
} }
case LEG_TYPE_TRAIN -> { case LEG_TYPE_TRAIN -> {
List<LyETAPush.TrainOrderInfo> trainOrderInfos = orderInfos.getTrainOrderInfos(); List<LyETAPush.TrainOrderInfo> trainOrderInfos = orderInfos.getTrainOrderInfos();
if (trainOrderInfos != null && !trainOrderInfos.isEmpty()) { if (trainOrderInfos != null && !trainOrderInfos.isEmpty()) {
LyETAPush.TrainOrderInfo trainOrderInfo = trainOrderInfos.get(0); for (LyETAPush.TrainOrderInfo trainOrderInfo : trainOrderInfos) {
SupplierCallbackData copySupplierCallbackData = BeanUtil.copyProperties(supplierCallbackData, SupplierCallbackData.class);
TrainDetailResponse.TrainDetailData data = lySearchRequest TrainDetailResponse.TrainDetailData data = lySearchRequest
.getTrainOrderDetail(trainOrderInfo.getOrderNo()).getData(); .getTrainOrderDetail(trainOrderInfo.getOrderNo()).getData();
supplierCallbackData.data(data).extension(getETAReason(trainOrderInfo)).productType(L_Y_PRODUCT_TYPE_TRAIN); copySupplierCallbackData.data(data).extension(getETAReason(trainOrderInfo)).productType(L_Y_PRODUCT_TYPE_TRAIN);
res.add(copySupplierCallbackData);
}
} }
} }
case LEG_TYPE_HOTEL -> { case LEG_TYPE_HOTEL -> {
List<LyETAPush.HotelOrderInfo> hotelOrderInfos = orderInfos.getHotelOrderInfos(); List<LyETAPush.HotelOrderInfo> hotelOrderInfos = orderInfos.getHotelOrderInfos();
if (hotelOrderInfos != null && !hotelOrderInfos.isEmpty()) { if (hotelOrderInfos != null && !hotelOrderInfos.isEmpty()) {
LyETAPush.HotelOrderInfo hotelOrderInfo = hotelOrderInfos.get(0); for (LyETAPush.HotelOrderInfo hotelOrderInfo : hotelOrderInfos) {
SupplierCallbackData copySupplierCallbackData = BeanUtil.copyProperties(supplierCallbackData, SupplierCallbackData.class);
HotelDetailResponse.Data data = lySearchRequest HotelDetailResponse.Data data = lySearchRequest
.getHotelOrderDetail(hotelOrderInfo.getOrderNo()).getData(); .getHotelOrderDetail(hotelOrderInfo.getOrderNo()).getData();
supplierCallbackData.data(data).extension(getETAReason(hotelOrderInfo)).productType(L_Y_PRODUCT_TYPE_HOTEL); copySupplierCallbackData.data(data).extension(getETAReason(hotelOrderInfo)).productType(L_Y_PRODUCT_TYPE_HOTEL);
res.add(copySupplierCallbackData);
}
} }
} }
default -> throw new NotFoundException(NOT_FOUND); default -> throw new NotFoundException(NOT_FOUND);
} }
return supplierCallbackData; return res;
} }
@ -200,8 +214,12 @@ public class LYETAController {
List<LyETAPush.BusinessTravelPolicy> businessTravelPolicies = baseOrderInfo.getBusinessTravelPolicies(); List<LyETAPush.BusinessTravelPolicy> businessTravelPolicies = baseOrderInfo.getBusinessTravelPolicies();
if (businessTravelPolicies != null && !businessTravelPolicies.isEmpty()) { if (businessTravelPolicies != null && !businessTravelPolicies.isEmpty()) {
LyETAPush.BusinessTravelPolicy businessTravelPolicy = businessTravelPolicies.get(0); LyETAPush.BusinessTravelPolicy businessTravelPolicy = businessTravelPolicies.get(0);
if (businessTravelPolicy.getViolationReasonChinese().equals("其他")) {
return businessTravelPolicy.getViolationReasonRemark();
} else {
return businessTravelPolicy.getViolationReasonChinese(); return businessTravelPolicy.getViolationReasonChinese();
} }
}
return null; return null;
} }
} }

View File

@ -278,9 +278,9 @@ class RouteApplicationTests {
// log.trace("trace"); // log.trace("trace");
} }
// @Test @Test
void loginSignProd() { void loginSignProd() {
String sfno = "231008023"; String sfno = "230701137";
String syscode = "FSSC"; String syscode = "FSSC";
String billcode = "CLSQ240225000099"; String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司"; String companycode = "正泰集团股份有限公司";
@ -1011,11 +1011,10 @@ class RouteApplicationTests {
pushUser.getUserSFDataFromOpenApiBatch(); pushUser.getUserSFDataFromOpenApiBatch();
} }
// @Test @Test
void deleteByOrderId() { void deleteByOrderId() {
orderDetailRepository.deleteById(1647L); orderDetailRepository.deleteById(2988L);
orderDetailRepository.deleteById(1648L); orderDetailRepository.deleteById(2990L);
} }
// @Test // @Test