diff --git a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java index 42403ce8..17e17d95 100644 --- a/src/main/java/com/chint/domain/aggregates/system/SystemCode.java +++ b/src/main/java/com/chint/domain/aggregates/system/SystemCode.java @@ -20,6 +20,7 @@ public class SystemCode implements Serializable { private String systemCode; private String bpmCode; private String redirectPath; + private Integer ifImmediateResponse; //是否立马回复审批结果,0不是,1是 @MappedCollection(idColumn = "system_id", keyColumn = "system_key") private List companyInfos; } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java index 92380b24..d2f3bcce 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java @@ -28,7 +28,7 @@ import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA; import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; @Component -public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { +public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { @Autowired diff --git a/src/main/java/com/chint/domain/service/SystemDomainService.java b/src/main/java/com/chint/domain/service/SystemDomainService.java index 5ea54d2e..dd355072 100644 --- a/src/main/java/com/chint/domain/service/SystemDomainService.java +++ b/src/main/java/com/chint/domain/service/SystemDomainService.java @@ -1,5 +1,6 @@ package com.chint.domain.service; +import com.chint.domain.aggregates.system.SystemCode; import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.SystemCodeRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -15,9 +16,18 @@ public class SystemDomainService { public boolean checkSystemCode(String sysCode) { boolean b = systemCodeRepository.findBySysCode(sysCode) != null; - if(!b){ + if (!b) { throw new NotFoundException(SYS_CODE_ERROR); } return b; } + + //是否返回结果 + public boolean ifImmediateResponse(String sysCode) { + SystemCode bySysCode = systemCodeRepository.findBySysCode(sysCode); + if (bySysCode == null) { + throw new NotFoundException(SYS_CODE_ERROR); + } + return bySysCode.getIfImmediateResponse() == 1; + } } diff --git a/src/main/java/com/chint/infrastructure/constant/LYConstant.java b/src/main/java/com/chint/infrastructure/constant/LYConstant.java index dc914e44..ec700c4f 100644 --- a/src/main/java/com/chint/infrastructure/constant/LYConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LYConstant.java @@ -3,6 +3,7 @@ package com.chint.infrastructure.constant; public class LYConstant { //同程 public static final String L_Y_STROKE_PUSH = "/api/TravelBizOrder/ExternalApproval";//行程推送外部审批 + public static final String L_Y_STROKE_PUSH_NEW = "/api/TravelBizOrder/ExternalApprovalNew";//行程推送外部审批 -新 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_USER_PATH = "/api/Employee/SyncEmployeeInfo"; diff --git a/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java index 22cf35c2..6c9c46e1 100644 --- a/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/SystemCodeRepositoryImpl.java @@ -5,8 +5,11 @@ import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.SystemCodeRepository; import com.chint.infrastructure.repository.jdbc.JdbcSystemCodeRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Repository; + import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; @Repository @@ -20,6 +23,7 @@ public class SystemCodeRepositoryImpl implements SystemCodeRepository { return jdbcSystemCodeRepository.save(systemCode); } + @Cacheable(value = "SystemCode", key = "#sysCode") @Override public SystemCode findBySysCode(String sysCode) { return jdbcSystemCodeRepository.findBySystemCode(sysCode); diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/tools/CTripUtils.java b/src/main/java/com/chint/interfaces/rest/ctrip/tools/CTripUtils.java index ecd0d8a7..bec44397 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/tools/CTripUtils.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/tools/CTripUtils.java @@ -2,6 +2,9 @@ package com.chint.interfaces.rest.ctrip.tools; import com.chint.infrastructure.constant.OrderConstant; +import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA; +import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_UNKNOWN; + public class CTripUtils { public static Integer mapFlightStatus(String status) { return switch (status) { @@ -35,13 +38,13 @@ public class CTripUtils { // "改签取消"可能需要新的状态常量,因为它没有直接映射 OrderConstant.ORDER_EVENT_PAYED; case "Paid" -> OrderConstant.ORDER_EVENT_PAYED; // "已支付"映射到已预定 - case "Approve_G" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approving" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approving2" -> OrderConstant.ORDER_EVENT_ETA; // 未知状态 - case "Approve_T" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_F" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_A" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_C" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_G" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approving" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approving2" -> ORDER_EVENT_ETA; // 未知状态 + case "Approve_T" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_F" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_A" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_C" -> ORDER_EVENT_UNKNOWN; // 未知状态 default -> // 处理未知或未映射的状态 -99; @@ -73,13 +76,13 @@ public class CTripUtils { case "submitFailed" -> // "提交失败"可能需要新的状态常量,因为它没有直接映射 OrderConstant.ORDER_EVENT_PREPARE; - case "Approve_G" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approving" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approving2" -> OrderConstant.ORDER_EVENT_ETA; // 未知状态 - case "Approve_T" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_F" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_A" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_C" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_G" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approving" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approving2" -> ORDER_EVENT_ETA; // 未知状态 + case "Approve_T" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_F" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_A" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_C" -> ORDER_EVENT_UNKNOWN; // 未知状态 default -> // 处理未知或未映射的状态 -99; @@ -105,13 +108,13 @@ public class CTripUtils { // "退票成功"可能最接近"已经退票",但具体映射取决于业务逻辑 OrderConstant.ORDER_EVENT_REFUND; // 使用退票状态作为近似映射 case "Paid" -> OrderConstant.ORDER_EVENT_PAYED; // "已支付"映射到已预定状态 - case "Approve_G" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approving" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approving2" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_T" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_F" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_A" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_C" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_G" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approving" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approving2" -> ORDER_EVENT_ETA; // 未知状态 + case "Approve_T" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_F" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_A" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_C" -> ORDER_EVENT_UNKNOWN; // 未知状态 default -> // 处理未知或未映射的状态 -99; @@ -148,13 +151,13 @@ public class CTripUtils { case "Canceling" -> // "取消中"可能表示订单正在取消过程中,但没有直接映射,可能需要新的状态常量 OrderConstant.ORDER_EVENT_REFUND; - case "Approve_G" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approving" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approving2" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_T" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_F" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_A" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 - case "Approve_C" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_G" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approving" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approving2" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_T" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_F" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_A" -> ORDER_EVENT_UNKNOWN; // 未知状态 + case "Approve_C" -> ORDER_EVENT_UNKNOWN; // 未知状态 default -> // 处理未知或未映射的状态 -99; diff --git a/src/main/java/com/chint/interfaces/rest/ly/LYNoteResponse.java b/src/main/java/com/chint/interfaces/rest/ly/LYNoteResponse.java index 6590e5f3..093d16bd 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/LYNoteResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ly/LYNoteResponse.java @@ -14,4 +14,8 @@ public class LYNoteResponse { public static LYNoteResponse success() { return new LYNoteResponse("100", "OK"); } + + public static LYNoteResponse error(String resMsg) { + return new LYNoteResponse("100", resMsg); + } } diff --git a/src/main/java/com/chint/interfaces/rest/ly/LyApprovalRequest.java b/src/main/java/com/chint/interfaces/rest/ly/LyApprovalRequest.java new file mode 100644 index 00000000..afb4bc03 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/LyApprovalRequest.java @@ -0,0 +1,35 @@ +package com.chint.interfaces.rest.ly; + +import com.chint.interfaces.rest.ly.dto.approval.ApprovalRequest; +import com.chint.interfaces.rest.ly.dto.approval.ApprovalResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import static com.chint.infrastructure.constant.LYConstant.L_Y_STROKE_PUSH_NEW; + +@Component +public class LyApprovalRequest { + + @Value("${ly.baseUrl}") + private String baseUrl; + + @Autowired + private LYPostRequest lyPostRequest; + + public ApprovalResponse pushApprovalSuccess(String approvalId) { + return pushApprovalRes(approvalId, 2); + } + + + public ApprovalResponse pushApprovalError(String approvalId) { + return pushApprovalRes(approvalId, 1); + } + + private ApprovalResponse pushApprovalRes(String approvalId, Integer approvalStatus) { + ApprovalRequest approvalRequest = ApprovalRequest.approvalOrder(approvalId, approvalStatus); + return lyPostRequest.post(baseUrl + L_Y_STROKE_PUSH_NEW, + approvalRequest, + ApprovalResponse.class); + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/approval/ApprovalRequest.java b/src/main/java/com/chint/interfaces/rest/ly/dto/approval/ApprovalRequest.java new file mode 100644 index 00000000..4070d210 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/approval/ApprovalRequest.java @@ -0,0 +1,26 @@ +package com.chint.interfaces.rest.ly.dto.approval; + +import com.chint.interfaces.rest.ly.dto.LYBaseRequest; +import lombok.Data; + +@Data +public class ApprovalRequest extends LYBaseRequest { + private ApprovalParam param; + + public static ApprovalRequest approvalOrder(String approvalId, Integer approvalStatus) { + ApprovalRequest approvalRequest = new ApprovalRequest(); + ApprovalParam param = new ApprovalParam(); + param.setApprovalId(approvalId); + param.setApprovalStatus(approvalStatus); + approvalRequest.setParam(param); + return approvalRequest; + } + + @Data + public static class ApprovalParam { + private String approvalId; + private Integer remarks; + private Integer approvalStatus; + private Integer outApprovalId; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/approval/ApprovalResponse.java b/src/main/java/com/chint/interfaces/rest/ly/dto/approval/ApprovalResponse.java new file mode 100644 index 00000000..d6ed046a --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/approval/ApprovalResponse.java @@ -0,0 +1,10 @@ +package com.chint.interfaces.rest.ly.dto.approval; + +import com.chint.interfaces.rest.ly.dto.LYBaseResponse; +import lombok.Data; + +@Data +public class ApprovalResponse extends LYBaseResponse { + private String data; + private Integer errorType; +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/eta/LyETAPush.java b/src/main/java/com/chint/interfaces/rest/ly/dto/eta/LyETAPush.java new file mode 100644 index 00000000..c0dd13c4 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/eta/LyETAPush.java @@ -0,0 +1,157 @@ +package com.chint.interfaces.rest.ly.dto.eta; + +import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightInfo; +import lombok.Data; + +import java.util.List; + +@Data +public class LyETAPush { + private NotifyData notifyData; + private int notifyType; + private int subNotifyType; + private long notifyTime; + private String sign; + private String soleKey; + private boolean isEncrypt; + + + @Data + public static class NotifyData { + private String ApprovalOrderId; + private String TravelApplyNo; + private String TravelOrderNo; + private List Employees; + private String BookEmpId; + private String BookEmpEmail; + private String CompanyCode; + private List OrderNos; + private OrderInfo OrderInfos; + } + + @Data + public static class Employee { + private String empId; + private String empEmail; + private String empName; + } + + @Data + public static class OrderInfo { + private List flightOrderInfos; + private List hotelOrderInfos; + private List trainOrderInfos; + } + + + @Data + public static class FlightOrderInfo { + private String orderNo; + private List businessTravelPolicies; + private double totalAmount; + private double originalAmount; + private double refundAmount; + private double changeAmount; + private List flightInfo; + } + @Data + public static class BusinessTravelPolicy { + private int isViolation; + private String passengerEmpId; + private String violationReasonCode; + private String violationReasonChinese; + private String violationReasonRemark; + private List policyDetails; + } + + + @Data + public static class PolicyDetail { + private String violationContent; + private String violationContentCode; + } + + @Data + public static class FlightInfo { + private String arrivalAirport; + private String arrivalCity; + private String arrivalDate; + private String cabin; + private String departureAirport; + private String departureCity; + private String departureDate; + private String flightCompany; + private String flight; + private String meal; + private String planeModel; + private double price; + private double tax; + private double oil; + private double amount; + private int flightNo; + } + + + //酒店订单信息 + @Data + public static class HotelOrderInfo { + private List businessTravelPolicies; + private String orderNo; + private AmountInfo amountInfo; + private List hotelInfos; + + // Getters and Setters + } + @Data + public static class AmountInfo { + private double totalAmount; + private String currency; + private String payType; + private double companyAmt; + private double personAmt; + + // Getters and Setters + } + + @Data + public static class HotelInfo { + private String clientName; + private String city; + private String startTime; + private String endTime; + private String quantity; + private String roomDays; + private String roomName; + private String roomNo; + private String meal; + private String stars; + private String hotelType; + } + + //火车订单信息 + @Data + class TrainOrderInfo { + private String orderNo; + private double totalAmount; + private double originalAmount; + private double changeAmount; + private double refundAmount; + private List trainInfos; + private List businessTravelPolicies; + } + + @Data + class TrainInfo { + private String passengerName; + private String trainNum; + private String seatType; + private String departureTime; + private String arriveTime; + private String dCityName; + private String aCityName; + private String dStationName; + private String aStationName; + private double price; + } +} + 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 new file mode 100644 index 00000000..ea494ffd --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java @@ -0,0 +1,44 @@ +package com.chint.interfaces.rest.ly.in; + +import com.chint.domain.service.SystemDomainService; +import com.chint.interfaces.rest.ly.LYNoteResponse; +import com.chint.interfaces.rest.ly.dto.eta.LyETAPush; +import lombok.extern.slf4j.Slf4j; +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; + + +@Slf4j +@RestController +@RequestMapping("/public/common") +public class LYETAController { + + @Autowired + private SystemDomainService systemDomainService; + + @PostMapping("/eta") + public LYNoteResponse noteByETA(@RequestBody LyETAPush lyETAPush) { + if (lyETAPush.getNotifyType() != 51) { + return LYNoteResponse.error("推送类型错误"); + } + + + String travelApplyNo = lyETAPush.getNotifyData().getTravelApplyNo(); + String[] split = travelApplyNo.split("-"); + if (split.length == 0) { + return LYNoteResponse.error("外部申请单格式错误"); + } + + //获取系统标识 + String sysCode = split[0]; + +// systemDomainService.ifImmediateResponse(sysCode) + + return null; + } + + +}