From 62590400ad9ff9cbf334a1f80bf042bfbd7fb2c8 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 19 Apr 2024 13:00:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=90=8C=E7=A8=8B=E8=B6=85=E6=A0=87=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=87=BA=E7=8E=B0=E4=B8=AD=E8=BD=AC=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/service/OrderDomainService.java | 27 ++--- .../value_object/SupplierCallbackData.java | 2 +- .../rest/ly/in/LYETAController.java | 108 ++++++++++-------- .../java/com/chint/RouteApplicationTests.java | 11 +- 4 files changed, 80 insertions(+), 68 deletions(-) diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index 1610b5a2..beb7f3e3 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -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); 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 59eb7c27..50287994 100644 --- a/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java +++ b/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java @@ -35,7 +35,7 @@ public class SupplierCallbackData { return this; } - public SupplierCallbackData extension(String daextensionta) { + public SupplierCallbackData extension(String extension) { this.extension = extension; return this; } diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java b/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java index d10b488f..703a6e0c 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java @@ -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 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 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 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 searchOrderDetailByProductType(LyETAPush.OrderInfo orderInfos, SupplierCallbackData supplierCallbackData, Integer productType) { + List res = new ArrayList<>(); switch (productType) { case LEG_TYPE_AIRPLANE -> { List 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 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 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 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; } diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 49aaa80b..4c83f326 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -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