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 com.chint.application.commands.*;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.system.ProcessInitiationControl;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.exceptions.OrderException;
import com.chint.domain.factoriy.leg_event.LegEventFactory;
import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
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.UserLoginParam;
import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.constant.RouteConstant;
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcLegRepository;
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.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.dto.search.ItineraryEntity;
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 jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
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.LegConstant.*;
import static com.chint.infrastructure.constant.OrderConstant.*;
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
@Service
@ -220,6 +210,11 @@ public class OrderDomainService {
Integer orderEventType = command.getOrderEventType();
OrderEvent event = orderDetailFactory.createEvent(orderEventType,
outStatus);
if (orderEventType.equals(ORDER_EVENT_ETA) ||
orderEventType.equals(ORDER_EVENT_CHANGE) ||
orderEventType.equals(ORDER_EVENT_REFUND)) {
event.setExtension(command.getExtension());
}
orderDetail.addOrderEvent(event);
orderDetailRepository.save(orderDetail);

View File

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

View File

@ -1,6 +1,6 @@
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.domain.aggregates.order.OrderDetail;
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.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@ -85,37 +86,40 @@ public class LYETAController {
}
SupplierCallbackData supplierCallbackData = handlerETACallBackData(lyETAPush);
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
List<SupplierCallbackData> supplierCallbackDataList = handlerETACallBackData(lyETAPush);
orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId));
for (SupplierCallbackData supplierCallbackData : supplierCallbackDataList) {
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId));
//发送超标事件
Command.of(OrderStatusChangeCommand.class)
.orderDetail(orderDetail)
.outStatus("超标")
.extension(supplierCallbackData.getExtension())
.eventType(ORDER_EVENT_ETA)
.orderNo(orderDetail.getOrderNo())
.sendToQueue();
if (supplierCallbackData.getExtension() != null) {
//发送超标事件
Command.of(OrderStatusChangeCommand.class)
.orderDetail(orderDetail)
.outStatus("超标")
.extension(supplierCallbackData.getExtension())
.eventType(ORDER_EVENT_ETA)
.orderNo(orderDetail.getOrderNo())
.sendToQueue();
}
int subNotifyType = lyETAPush.getSubNotifyType();
if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) {
//如果推送类是2,4,6还要触发改签事件
Command.of(OrderStatusChangeCommand.class)
.orderDetail(orderDetail)
.outStatus("改签")
.extension(supplierCallbackData.getExtension())
.eventType(ORDER_EVENT_CHANGE)
.orderNo(orderDetail.getOrderNo())
.sendToQueue();
int subNotifyType = lyETAPush.getSubNotifyType();
if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) {
//如果推送类是2,4,6还要触发改签事件
Command.of(OrderStatusChangeCommand.class)
.orderDetail(orderDetail)
.outStatus("改签")
.extension(supplierCallbackData.getExtension())
.eventType(ORDER_EVENT_CHANGE)
.orderNo(orderDetail.getOrderNo())
.sendToQueue();
}
}
return LYNoteResponse.success();
}
private SupplierCallbackData handlerETACallBackData(LyETAPush lyETAPush) {
private List<SupplierCallbackData> handlerETACallBackData(LyETAPush lyETAPush) {
LyETAPush.NotifyData notifyData = lyETAPush.getNotifyDataObject();
String bookEmpId = notifyData.getBookEmpId();
SupplierCallbackData supplierCallbackData =
@ -123,21 +127,21 @@ public class LYETAController {
LyETAPush.OrderInfo orderInfos = notifyData.getOrderInfos();
//如果子类型是1 那么就要自己去找出是那种类型的
if (lyETAPush.getSubNotifyType() == 1) {
handleCommonETA(orderInfos, supplierCallbackData);
return handleCommonETA(orderInfos, supplierCallbackData);
} else if (lyETAPush.getSubNotifyType() == 2) {
//子类型为2代表机票改签超标
searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_AIRPLANE);
return searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_AIRPLANE);
} else if (lyETAPush.getSubNotifyType() == 4) {
//子类型为4代表火车改签超标
searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_TRAIN);
return searchOrderDetailByProductType(orderInfos, supplierCallbackData, LEG_TYPE_TRAIN);
} else if (lyETAPush.getSubNotifyType() == 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);
if (productType == null) {
throw new NotFoundException(NOT_FOUND);
@ -145,38 +149,48 @@ public class LYETAController {
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) {
case LEG_TYPE_AIRPLANE -> {
List<LyETAPush.FlightOrderInfo> flightOrderInfos = orderInfos.getFlightOrderInfos();
if (flightOrderInfos != null && !flightOrderInfos.isEmpty()) {
LyETAPush.FlightOrderInfo flightOrderInfo = flightOrderInfos.get(0);
FlightOrderResponse.Data data = lySearchRequest
.getFlightOrderDetail(flightOrderInfo.getOrderNo()).getData();
supplierCallbackData.data(data).extension(getETAReason(flightOrderInfo)).productType(L_Y_PRODUCT_TYPE_FLY);
for (LyETAPush.FlightOrderInfo flightOrderInfo : flightOrderInfos) {
SupplierCallbackData copySupplierCallbackData = BeanUtil.copyProperties(supplierCallbackData, SupplierCallbackData.class);
FlightOrderResponse.Data data = lySearchRequest
.getFlightOrderDetail(flightOrderInfo.getOrderNo()).getData();
copySupplierCallbackData.data(data).extension(getETAReason(flightOrderInfo)).productType(L_Y_PRODUCT_TYPE_FLY);
res.add(copySupplierCallbackData);
}
}
}
case LEG_TYPE_TRAIN -> {
List<LyETAPush.TrainOrderInfo> trainOrderInfos = orderInfos.getTrainOrderInfos();
if (trainOrderInfos != null && !trainOrderInfos.isEmpty()) {
LyETAPush.TrainOrderInfo trainOrderInfo = trainOrderInfos.get(0);
TrainDetailResponse.TrainDetailData data = lySearchRequest
.getTrainOrderDetail(trainOrderInfo.getOrderNo()).getData();
supplierCallbackData.data(data).extension(getETAReason(trainOrderInfo)).productType(L_Y_PRODUCT_TYPE_TRAIN);
for (LyETAPush.TrainOrderInfo trainOrderInfo : trainOrderInfos) {
SupplierCallbackData copySupplierCallbackData = BeanUtil.copyProperties(supplierCallbackData, SupplierCallbackData.class);
TrainDetailResponse.TrainDetailData data = lySearchRequest
.getTrainOrderDetail(trainOrderInfo.getOrderNo()).getData();
copySupplierCallbackData.data(data).extension(getETAReason(trainOrderInfo)).productType(L_Y_PRODUCT_TYPE_TRAIN);
res.add(copySupplierCallbackData);
}
}
}
case LEG_TYPE_HOTEL -> {
List<LyETAPush.HotelOrderInfo> hotelOrderInfos = orderInfos.getHotelOrderInfos();
if (hotelOrderInfos != null && !hotelOrderInfos.isEmpty()) {
LyETAPush.HotelOrderInfo hotelOrderInfo = hotelOrderInfos.get(0);
HotelDetailResponse.Data data = lySearchRequest
.getHotelOrderDetail(hotelOrderInfo.getOrderNo()).getData();
supplierCallbackData.data(data).extension(getETAReason(hotelOrderInfo)).productType(L_Y_PRODUCT_TYPE_HOTEL);
for (LyETAPush.HotelOrderInfo hotelOrderInfo : hotelOrderInfos) {
SupplierCallbackData copySupplierCallbackData = BeanUtil.copyProperties(supplierCallbackData, SupplierCallbackData.class);
HotelDetailResponse.Data data = lySearchRequest
.getHotelOrderDetail(hotelOrderInfo.getOrderNo()).getData();
copySupplierCallbackData.data(data).extension(getETAReason(hotelOrderInfo)).productType(L_Y_PRODUCT_TYPE_HOTEL);
res.add(copySupplierCallbackData);
}
}
}
default -> throw new NotFoundException(NOT_FOUND);
}
return supplierCallbackData;
return res;
}
@ -200,7 +214,11 @@ public class LYETAController {
List<LyETAPush.BusinessTravelPolicy> businessTravelPolicies = baseOrderInfo.getBusinessTravelPolicies();
if (businessTravelPolicies != null && !businessTravelPolicies.isEmpty()) {
LyETAPush.BusinessTravelPolicy businessTravelPolicy = businessTravelPolicies.get(0);
return businessTravelPolicy.getViolationReasonChinese();
if (businessTravelPolicy.getViolationReasonChinese().equals("其他")) {
return businessTravelPolicy.getViolationReasonRemark();
} else {
return businessTravelPolicy.getViolationReasonChinese();
}
}
return null;
}

View File

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