diff --git a/src/main/java/com/chint/application/out/FSSCController.java b/src/main/java/com/chint/application/out/FSSCController.java index 680b588d..42e0bc7c 100644 --- a/src/main/java/com/chint/application/out/FSSCController.java +++ b/src/main/java/com/chint/application/out/FSSCController.java @@ -95,6 +95,9 @@ public class FSSCController { reDirectUrl = postRequest.getReDirectUrl(generateUrlPathFromDataBase(dataBaseUrl, employeeNo)); } + if (sysCode.getSystemCodeUrl().getRedirectType() == 2) { + reDirectUrl = dataBaseUrl; + } return reDirectUrl; } diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java index 158ae546..5eec9928 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java @@ -53,6 +53,7 @@ public class OrderCarRecord extends OrderBaseRecord { private String cancelCost; // 取消费 private String userName; // 用车人姓名 private String userCode; // 用车人code + private String ownPayAmt; // 个人统付金额 private String comyPayAmt; // 公司统付金额 private String bookOrgCode1; // 用车人组织架构信息1 private String bookOrgCode2; // 用车人组织架构信息2 @@ -61,4 +62,113 @@ public class OrderCarRecord extends OrderBaseRecord { private String projectOrderNo; // 项目订单号 private String offlineCcomyCode; // 成本中心 private String orderSource; // 预订来源:线上/线下 + + + //添加行程信息 + public OrderCarRecord loadTravelInfo(String startTime, + String arriveTime, + String fromCity, + String toCity + ) { + // 行程信息 + this.setFromCity(fromCity); + this.setToCity(toCity); + this.setStartTime(startTime); + this.setArriveTime(arriveTime); + return this; + } + + // 加载订单基本信息 + public OrderCarRecord loadBasicOrderInfo(String orderNo, + String orderStatus, + String createTime) { + this.setOrderNo(orderNo); + this.setOrderStatus(orderStatus); + this.setCreateTime(createTime); + return this; + } + + // 加载车型和运行信息 + public OrderCarRecord loadVehicleAndTravelInfo(String carType, + String runTime, + String miles) { + this.setCarType(carType); + this.setRunTime(runTime); + this.setMiles(miles); + return this; + } + + // 加载财务信息 + public OrderCarRecord loadFinancialInfo(String accountPeriod, + String billNo, + String orderAmount) { + this.setAccountPeriod(accountPeriod); + this.setBillNo(billNo); + this.setOrderAmount(orderAmount); + return this; + } + + // 加载费用细节, 未税金额,税费,服务费,取消费,额外费用,额外费用名称 + public OrderCarRecord loadFeeDetails(String noTaxAmt, + String taxAmt, + String serviceCost, + String cancelCost, + String highSpeedAmt, + String highSpeedName) { + this.setNoTaxAmt(noTaxAmt); + this.setTaxAmt(taxAmt); + this.setServiceCost(serviceCost); + this.setCancelCost(cancelCost); + this.setHighSpeedAmt(highSpeedAmt); + this.setHighSpeedName(highSpeedName); + return this; + } + + // 加载付款和项目信息 + public OrderCarRecord loadPayment(String paymentType, + String comyPayAmt, + String ownPayAmt) { + this.setPaymentType(paymentType); + this.setComyPayAmt(comyPayAmt); + this.setOwnPayAmt(ownPayAmt); + return this; + } + + // 加载组织架构信息 + public OrderCarRecord loadOrganizationalInfo(String bookOrgCode1, + String bookOrgCode2, + String bookOrgCode3) { + this.setBookOrgCode1(bookOrgCode1); + this.setBookOrgCode2(bookOrgCode2); + this.setBookOrgCode3(bookOrgCode3); + return this; + } + + // 加载来源和系统归属信息, 线上线下 + public OrderCarRecord loadSource(String orderSource) { + this.setOrderSource(orderSource); + return this; + } + + // 加载超标信息 + public OrderCarRecord loadComplianceInfo(String overStandard, + String overStandardReason) { + this.setOverStandard(overStandard); + this.setOverStandardReason(overStandardReason); + return this; + } + + // 加载关联订单信息 + public OrderCarRecord loadRelatedOrderInfo(Long orderDetailId, + String detailId, + String receiptsNum, + String parentOrderNo, + String originalOrderNo) { + this.setOrderDetailId(orderDetailId); + this.setDetailId(detailId); + this.setReceiptsNum(receiptsNum); + this.setParentOrderNo(parentOrderNo); + this.setOriginalOrderNo(originalOrderNo); + return this; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java index c18cdf3c..02b2fde8 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderFlightRecord.java @@ -75,4 +75,119 @@ public class OrderFlightRecord extends OrderBaseRecord{ private String bookOrgCode3; // 出行人组织架构信息3 private String projectOrderNo; // 项目订单号 private String offlineCcomyCode; // 成本中心 + + // 加载基础订单信息 + public OrderFlightRecord loadBasicOrderInfo(Long id, String orderNo, String orderStatus, String createTime) { + this.setId(id); + this.setOrderNo(orderNo); +// this.setOrderStatus(orderStatus); +// this.setCreateTime(createTime); + return this; + } + + // 加载航班信息 + public OrderFlightRecord loadFlightInfo(String flightNum, String startAirportName, String endAirportName, + String startCityName, String endCityName, String startTime, String endTime) { + this.setFlightNum(flightNum); + this.setStartAirportName(startAirportName); + this.setEndAirportName(endAirportName); + this.setStartCityName(startCityName); + this.setEndCityName(endCityName); + this.setStartTime(startTime); + this.setEndTime(endTime); + return this; + } + + // 加载预订与乘机人信息 + public OrderFlightRecord loadBookingAndPassengerInfo(String bookingUserCode, String bookingName, String userName, String userCode) { + this.setBookingUserCode(bookingUserCode); + this.setBookingName(bookingName); + this.setUserName(userName); + this.setUserCode(userCode); + return this; + } + + // 加载财务与价格信息 + public OrderFlightRecord loadFinancialAndPricingInfo(String accountCompanyId, String accountCompanyName, + String accountPeriod, String billNo, String orderAmount, + String facePrice, String noTaxAmt, String taxAmt) { + this.setAccountCompanyId(accountCompanyId); + this.setAccountCompanyName(accountCompanyName); + this.setAccountPeriod(accountPeriod); + this.setBillNo(billNo); + this.setOrderAmount(orderAmount); + this.setFacePrice(facePrice); + this.setNoTaxAmt(noTaxAmt); + this.setTaxAmt(taxAmt); + return this; + } + + // 加载额外费用信息 + public OrderFlightRecord loadExtraFeeInfo(String serviceFee, String airportTax, String fuelTax, + String changeFee, String refundFee) { + this.setPreServiceFee(serviceFee); + this.setAirportTax(airportTax); + this.setFuelTax(fuelTax); + this.setChangeFee(changeFee); + this.setRefundFee(refundFee); + return this; + } + + // 加载航班额外细节 + public OrderFlightRecord loadFlightExtraDetails(String ycabinFullPrice, String seatDiscount, String policyLowestPrice, + String issueTicketTime, String flightLowestPrice, String useStatus, + String upFee, String postServiceFee, String endAirportCode, String endTerminal) { + this.setYcabinFullPrice(ycabinFullPrice); + this.setSeatDiscount(seatDiscount); + this.setPolicyLowestPrice(policyLowestPrice); + this.setIssueTicketTime(issueTicketTime); + this.setFlightLowestPrice(flightLowestPrice); + this.setUseStatus(useStatus); + this.setUpFee(upFee); + this.setPostServiceFee(postServiceFee); + this.setEndAirportCode(endAirportCode); + this.setEndTerminal(endTerminal); + return this; + } + + // 加载组织架构与项目信息 + public OrderFlightRecord loadOrganizationalAndProjectInfo(String bookOrgCode1, String bookOrgCode2, String bookOrgCode3, + String projectOrderNo, String offlineCcomyCode) { + this.setBookOrgCode1(bookOrgCode1); + this.setBookOrgCode2(bookOrgCode2); + this.setBookOrgCode3(bookOrgCode3); + this.setProjectOrderNo(projectOrderNo); + this.setOfflineCcomyCode(offlineCcomyCode); + return this; + } + + // 加载来源和系统归属信息 + public OrderFlightRecord loadSourceAndSystemInfo(String trvaleSysType, String belongSysType, String orderSource) { + this.setTrvaleSysType(trvaleSysType); + this.setBelongSysType(belongSysType); + this.setOrderSource(orderSource); + return this; + } + + // 加载违规信息 + public OrderFlightRecord loadComplianceInfo(String overStandard, String overStandardReason) { + this.setOverStandard(overStandard); + this.setOverStandardReason(overStandardReason); + return this; + } + + // 加载航班细节 + public OrderFlightRecord loadFlightDetails(String seatPoint, String seatPointName, String distance, String flightCompName) { + this.setSeatPoint(seatPoint); + this.setSeatPointName(seatPointName); + this.setDistance(distance); + this.setFlightCompName(flightCompName); + return this; + } + + // 加载未预订最低价原因 + public OrderFlightRecord loadNotLowReason(String notLowReason) { + this.setNotLowReason(notLowReason); + return this; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderHotelRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderHotelRecord.java index 54fdf380..0af6af59 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderHotelRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderHotelRecord.java @@ -72,4 +72,132 @@ public class OrderHotelRecord extends OrderBaseRecord{ private String bookOrgCode3; // 入住人组织架构信息3 private String projectOrderNo; // 项目订单号 private String offlineCcomyCode; // 成本中心 + + // 加载基础订单信息 + public OrderHotelRecord loadBasicOrderInfo(Long id, String orderNo, String orderStatus, String createTime) { + this.setId(id); + this.setOrderNo(orderNo); +// this.setOrderStatus(orderStatus); +// this.setCreateTime(createTime); + return this; + } + + // 加载酒店和入住信息 + public OrderHotelRecord loadHotelAndStayInfo(String hotelName, String hotelAddress, String checkInDate, String departureDate, + int roomCount, String roomTypeName, String country, String province, String checkInCity) { + this.setHotelName(hotelName); + this.setHotelAddress(hotelAddress); + this.setCheckInDate(checkInDate); + this.setDepartureDate(departureDate); + this.setRoomCount(roomCount); + this.setRoomTypeName(roomTypeName); + this.setCountry(country); + this.setProvince(province); + this.setCheckInCity(checkInCity); + return this; + } + + // 加载预订人和入住人信息 + public OrderHotelRecord loadBookerAndGuestInfo(String bookingUserCode, String bookingName, String userName, String userCode) { + this.setBookingUserCode(bookingUserCode); + this.setBookingName(bookingName); + this.setUserName(userName); + this.setUserCode(userCode); + return this; + } + + // 加载财务信息 + public OrderHotelRecord loadFinancialInfo(String accountCompanyId, String accountCompanyName, String accountPeriod, String billNo, + String orderAmount, String noTaxAmt, String taxAmt, String companyAmount, String personalAmount) { + this.setAccountCompanyId(accountCompanyId); + this.setAccountCompanyName(accountCompanyName); + this.setAccountPeriod(accountPeriod); + this.setBillNo(billNo); + this.setOrderAmount(orderAmount); + this.setNoTaxAmt(noTaxAmt); + this.setTaxAmt(taxAmt); + this.setCompanyAmount(companyAmount); + this.setPersonalAmount(personalAmount); + return this; + } + + // 加载支付和服务费信息 + public OrderHotelRecord loadPaymentAndServiceFeeInfo(int paymentType, String unifiedPayAmt, String personalPayAmt) { + this.setPaymentType(paymentType); + this.setUnifiedPayAmt(unifiedPayAmt); + this.setPersonalPayAmt(personalPayAmt); + return this; + } + + // 加载酒店品牌和星级信息 + public OrderHotelRecord loadBrandAndStarRateInfo(String brandGroup, String brandName, String starRate) { + this.setBrandGroup(brandGroup); + this.setBrandName(brandName); + this.setStarRate(starRate); + return this; + } + + // 加载订单来源和系统归属信息 + public OrderHotelRecord loadSourceAndSystemInfo(String trvaleSysType, String belongSysType, String orderSource) { + this.setTrvaleSysType(trvaleSysType); + this.setBelongSysType(belongSysType); + this.setOrderSource(orderSource); + return this; + } + + // 加载违规信息 + public OrderHotelRecord loadComplianceInfo(int overStandard, String overStandardReason) { + this.setOverStandard(overStandard); + this.setOverStandardReason(overStandardReason); + return this; + } + + // 加载组织架构和项目信息 + public OrderHotelRecord loadOrganizationalAndProjectInfo(String bookOrgCode1, String bookOrgCode2, String bookOrgCode3, + String projectOrderNo, String offlineCcomyCode) { + this.setBookOrgCode1(bookOrgCode1); + this.setBookOrgCode2(bookOrgCode2); + this.setBookOrgCode3(bookOrgCode3); + this.setProjectOrderNo(projectOrderNo); + this.setOfflineCcomyCode(offlineCcomyCode); + return this; + } + + // 加载订单详情和结算信息 + public OrderHotelRecord loadOrderDetailAndSettlementInfo(Long orderDetailId, String detailId, String ticketClerk, + String receiptsNum, String parentOrderNo, String originalOrderNo) { + this.setOrderDetailId(orderDetailId); + this.setDetailId(detailId); + this.setTicketClerk(ticketClerk); + this.setReceiptsNum(receiptsNum); + this.setParentOrderNo(parentOrderNo); + this.setOriginalOrderNo(originalOrderNo); + return this; + } + + // 加载房间和早餐信息 + public OrderHotelRecord loadRoomAndBreakfastInfo(String includeAmount, int isAgreement, int roomNightCount, + int nightCount, String roomPrice, String roomRate) { + this.setIncludeAmount(includeAmount); + this.setIsAgreement(isAgreement); + this.setRoomNightCount(roomNightCount); + this.setNightCount(nightCount); + this.setRoomPrice(roomPrice); + this.setRoomRate(roomRate); + return this; + } + + // 加载发票和费用信息 + public OrderHotelRecord loadInvoiceAndFeeInfo(String invoiceType, String invoiceFee, String custodayFee, + String noTaxCusFee, String taxCusFee) { + this.setInvoiceType(invoiceType); + this.setInvoiceFee(invoiceFee); + this.setCustodayFee(custodayFee); + this.setNoTaxCusFee(noTaxCusFee); + this.setTaxCusFee(taxCusFee); + return this; + } + + + } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderTrainRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderTrainRecord.java index 5c50fd5a..3e68a3c7 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderTrainRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderTrainRecord.java @@ -71,4 +71,119 @@ public class OrderTrainRecord extends OrderBaseRecord{ private String passportType; // 乘客证件类型 private String trainTime; // 发车时间 yyyy-MM-dd HH:‌mm:ss private String yxId; // 影像比对ID + + // 加载基础订单信息 + public OrderTrainRecord loadBasicOrderInfo(Long id, String orderNo, String orderStatus, String createTime) { + this.setId(id); + this.setOrderNo(orderNo); +// this.setOrderStatus(orderStatus); +// this.setCreateTime(createTime); + return this; + } + + // 加载结算和账户信息 + public OrderTrainRecord loadSettlementAndAccountInfo(String detailId, String accountCompanyId, String accountCompanyName, + String accountPeriod, String billNo) { + this.setDetailId(detailId); + this.setAccountCompanyId(accountCompanyId); + this.setAccountCompanyName(accountCompanyName); + this.setAccountPeriod(accountPeriod); + this.setBillNo(billNo); + return this; + } + + // 加载行程和时间信息 + public OrderTrainRecord loadTravelAndTimeInfo(String startDate, String arriveDate, String fromCity, String toCity, + String fromStationName, String toStationName, String trainNo, String trainTime, String runTime) { + this.setStartDate(startDate); + this.setArriveDate(arriveDate); + this.setFromCity(fromCity); + this.setToCity(toCity); + this.setFromStationName(fromStationName); + this.setToStationName(toStationName); + this.setTrainNo(trainNo); + this.setTrainTime(trainTime); + this.setRunTime(runTime); + return this; + } + + // 加载预订人和出行人信息 + public OrderTrainRecord loadBookingAndTravelerInfo(String bookingUserCode, String bookingName, String userCode, + String userName, String travelUserPhone, String travelUserSex, + String travelUserType, String travelUserBirthday) { + this.setBookingUserCode(bookingUserCode); + this.setBookingName(bookingName); + this.setUserCode(userCode); + this.setUserName(userName); + this.setTravelUserPhone(travelUserPhone); + this.setTravelUserSex(travelUserSex); + this.setTravelUserType(travelUserType); + this.setTravelUserBirthday(travelUserBirthday); + return this; + } + + // 加载费用信息 + public OrderTrainRecord loadFeeInfo(String orderAmount, String noTaxAmt, String taxAmt, String bookFee, + String collFee, String noTaxFeeAmt, String taxFeeAmt) { + this.setOrderAmount(orderAmount); + this.setNoTaxAmt(noTaxAmt); + this.setTaxAmt(taxAmt); + this.setBookFee(bookFee); + this.setCollFee(collFee); + this.setNoTaxFeeAmt(noTaxFeeAmt); + this.setTaxFeeAmt(taxFeeAmt); + return this; + } + + // 加载变更和退款信息 + public OrderTrainRecord loadChangeAndRefundInfo(String changeAddAmount, String changeCost, String changeReturnAmount, + String returnCost, String returnRes, String returnFee) { + this.setChangeAddAmount(changeAddAmount); + this.setChangeCost(changeCost); + this.setChangeReturnAmount(changeReturnAmount); + this.setReturnCost(returnCost); + this.setReturnRes(returnRes); + this.setReturnFee(returnFee); + return this; + } + + // 加载乘客证件信息 + public OrderTrainRecord loadPassengerDocumentInfo(String passportNo, String passportType) { + this.setPassportNo(passportNo); + this.setPassportType(passportType); + return this; + } + + // 加载来源和系统归属信息 + public OrderTrainRecord loadSourceAndSystemInfo(String trvaleSysType, String belongSysType, String orderSource) { + this.setTrvaleSysType(trvaleSysType); + this.setBelongSysType(belongSysType); + this.setOrderSource(orderSource); + return this; + } + + // 加载组织架构和项目信息 + public OrderTrainRecord loadOrganizationalAndProjectInfo(String bookOrgCode1, String bookOrgCode2, String bookOrgCode3, + String projectOrderNo, String offlineCcomyCode) { + this.setBookOrgCode1(bookOrgCode1); + this.setBookOrgCode2(bookOrgCode2); + this.setBookOrgCode3(bookOrgCode3); + this.setProjectOrderNo(projectOrderNo); + this.setOfflineCcomyCode(offlineCcomyCode); + return this; + } + + // 加载违规信息 + public OrderTrainRecord loadComplianceInfo(String overStandard, String overStandardReason) { + this.setOverStandard(overStandard); + this.setOverStandardReason(overStandardReason); + return this; + } + + // 加载座位和额外信息 + public OrderTrainRecord loadSeatAndExtraInfo(String seatType, String yxId) { + this.setSeatType(seatType); + this.setYxId(yxId); + return this; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/system/ProcessInitiationControl.java b/src/main/java/com/chint/domain/aggregates/system/ProcessInitiationControl.java new file mode 100644 index 00000000..6bed6537 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/system/ProcessInitiationControl.java @@ -0,0 +1,41 @@ +package com.chint.domain.aggregates.system; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 流程发起管控表(ProcessInitiationControl)表实体类 + * + * @author dengweichao + * @since 2024-03-29 09:28:32 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Table("process_initiation_control") +@Accessors(chain = true) +public class ProcessInitiationControl implements Serializable { + + @Serial + private static final long serialVersionUID = 7383041462839869026L; + + //id + @Id + private Integer id; + + //订单号 + private String orderNo; + + //1:超标,2改签,3退票 + private Integer tag; + +} diff --git a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java index a11d292f..12ca6a8b 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java @@ -1,31 +1,108 @@ package com.chint.domain.factoriy.order_record; -import com.chint.domain.aggregates.order.CarOrderDetail; -import com.chint.domain.aggregates.order.FlightOrderDetail; -import com.chint.domain.aggregates.order.HotelOrderDetail; -import com.chint.domain.aggregates.order.TrainOrderDetail; +import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; +import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCarQuickInfo; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCarRecord; +import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCarRecordBase; +import com.chint.domain.repository.RouteRepository; import com.chint.domain.service.OrderDetailDomainService; import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFactory{ +public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFactory { @Autowired private OrderDetailDomainService orderDetailDomainService; @Autowired private JdbcCtripHotelOrderDetailRepository jdbcCtripHotelOrderDetailRepository; + @Autowired + private OrderRecordFactory orderRecordFactory; + + @Autowired + private RouteRepository routeRepository; @Override public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) { - CTripCarRecord orderCarRecord = (CTripCarRecord) orderCarRecordData; - return null; + CTripCarRecord cTripCarRecord = (CTripCarRecord) orderCarRecordData; + String routeOrderNo = cTripCarRecord.getRouteOrderNo(); + RouteOrder byOrderNo = routeRepository.findByOrderNo(routeOrderNo); + + OrderCarRecord orderCarRecord = orderRecordFactory + .buildWithRouteOrder(byOrderNo) + .carRecord(); + + CTripCarRecordBase cTripCarRecordBase = cTripCarRecord.getCTripCarRecordBase(); + CTripCarQuickInfo cTripCarQuickInfo = cTripCarRecord.getCTripCarQuickInfo(); + + //添加行程信息 + String startTime = cTripCarQuickInfo.getServiceBeginTime(); + String endTime = cTripCarQuickInfo.getServiceEndTime(); + if (startTime.isBlank() || startTime.isEmpty()) { + startTime = cTripCarRecordBase.getCreateTime(); + } + if (endTime.isBlank() || endTime.isEmpty()) { + endTime = cTripCarRecordBase.getCreateTime(); + } + orderCarRecord.loadTravelInfo(startTime, endTime, + cTripCarQuickInfo.getDepartureCityName(), + cTripCarQuickInfo.getArrivalCityName()); + + // 加载车型和运行信息,车类型,时间,里程 + orderCarRecord.loadVehicleAndTravelInfo(cTripCarQuickInfo.getVehicleName(), + cTripCarQuickInfo.getNormalTime(), + cTripCarQuickInfo.getNormalDistance()); + + // 加载财务信息,账期号,账单号,总金额 + String batchNo = cTripCarRecordBase.getBatchNoStartDate().substring(0, 6); + orderCarRecord.loadFinancialInfo(batchNo, + cTripCarRecordBase.getSubAccCheckBatchNo(), + String.valueOf(cTripCarRecordBase.getAmount())); + + // 加载费用细节, 未税金额,税费,服务费,取消费,额外费用,额外费用名称 , 携程马上用车产品没有税费和额外费用字段 + orderCarRecord.loadFeeDetails(String.valueOf(cTripCarRecordBase.getAmount()), + "", + String.valueOf(cTripCarRecordBase.getServerFee()), + String.valueOf(cTripCarRecordBase.getPenaltyFee()), + "", + ""); + + // 加载组织架构信息 + orderCarRecord.loadOrganizationalInfo(cTripCarRecordBase.getDept1(), + cTripCarRecordBase.getDept2(), + cTripCarRecordBase.getDept3()); + + // 加载付款 付款方式,公司付款金额, 个人付款金额 + String paymentType; + Double personAmount = cTripCarRecordBase.getPersonAmount(); + Double realAmountHasPost = cTripCarRecordBase.getRealAmountHasPost(); + if (personAmount > 0 && personAmount < realAmountHasPost) { + paymentType = "2"; + } else if (personAmount.equals(realAmountHasPost)) { + paymentType = "1"; + } else { + paymentType = "0"; + } + orderCarRecord.loadPayment(paymentType, + String.valueOf(realAmountHasPost - personAmount), + String.valueOf(personAmount)); + + if(cTripCarRecord.getRouteOrderNo() == null || + cTripCarRecord.getRouteOrderNo().isEmpty() || + cTripCarRecord.getRouteOrderNo().isBlank()){ + orderCarRecord.loadSource("N"); + } else { + orderCarRecord.loadSource("Y"); + } + + + + return orderCarRecord; } @Override diff --git a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordBasic.java b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordBasic.java index 91221ae4..7cd8c9a8 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordBasic.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordBasic.java @@ -33,6 +33,8 @@ public class OrderRecordBasic { private String bookingUserPhone; // 资源供应商 private String supplier; + // 是否超标 + private String overStandard; // 超标原因 private String overStandardReason; // 项目订单号 @@ -40,6 +42,24 @@ public class OrderRecordBasic { // 成本中心 private String offlineCcomyCode; + private String userName; + + private String userCode; + + // 加载用户和预订信息 + public OrderRecordBasic loadBookingInfo(String bookingUserCode, + String bookingName, + String bookingUserPhone, + String userName, + String userCode) { + this.setBookingUserPhone(bookingUserPhone); + this.setBookingUserCode(bookingUserCode); + this.setBookingName(bookingName); + this.setUserName(userName); + this.setUserCode(userCode); + return this; + } + public OrderCarRecord carRecord() { return BeanUtil.copyProperties(this, OrderCarRecord.class); } diff --git a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java index 17d7244f..384192a1 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java @@ -19,13 +19,16 @@ public class OrderRecordFactory { public OrderRecordBasic buildWithRouteOrder(RouteOrder routeOrder) { routeOrder.reloadStatus(); OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); + //完成身份信息 String userId = routeOrder.getUserId(); User user = userRepository.findByUserEmployeeNo(userId); + orderRecordBasic.loadBookingInfo(user.getEmployeeNo(), + user.getName(), + user.getPhoneNumber(), + user.getEmployeeNo(), + user.getPhoneNumber()); - orderRecordBasic.setBookingUserCode(user.getEmployeeNo()); - orderRecordBasic.setBookingName(user.getName()); - orderRecordBasic.setBookingUserPhone(user.getPhoneNumber()); //配置供应商信息 String supplierName = routeOrder.getSupplierName(); diff --git a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java new file mode 100644 index 00000000..fef11cf0 --- /dev/null +++ b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java @@ -0,0 +1,356 @@ +package com.chint.domain.service; + +import com.chint.application.commands.BPMAuditCommand; +import com.chint.domain.aggregates.order.Leg; +import com.chint.domain.aggregates.order.OrderDetail; +import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.aggregates.system.ProcessInitiationControl; +import com.chint.domain.exceptions.NotFoundException; +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.infrastructure.constant.CommonMessageConstant; +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; +import com.chint.interfaces.rest.ctrip.dto.search.flight.ChangeInfo; +import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity; +import com.chint.interfaces.rest.ly.LYSearchRequest; +import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse; +import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse; +import com.chint.interfaces.rest.user.UserHttpRequest; +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.format.DateTimeFormatter; +import java.util.List; +import java.util.Objects; + +import static com.chint.infrastructure.constant.BPMConstant.*; +import static com.chint.infrastructure.constant.BPMConstant.REFUND_TYPE_FLIGHT; +import static com.chint.infrastructure.constant.BelongSystemConstant.BELONG_SYS_CODE_ANFSSC; +import static com.chint.infrastructure.constant.LegConstant.*; +import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER; +import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CHANGE; +import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND; +import static com.chint.infrastructure.constant.SupplierNameConstant.*; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y_BPM_NAME; + +@Service +public class BPMOrderDomainService { + + @Autowired + private RouteRepository routeRepository; + + + @Autowired + private BPMParamFactory bpmParamFactory; + + @Autowired + private BPMRequest bpmRequest; + + + @Autowired + private CTripOrderSearchRequest cTripOrderSearchRequest; + + @Autowired + private LYSearchRequest lySearchRequest; + + @Autowired + private JdbcOrderDetailRepository jdbcOrderDetailRepository; + + @Autowired + private JdbcLegRepository jdbcLegRepository; + + @Autowired + private JdbcProcessInitiationControlRepository jdbcProcessInitiationControlRepository; + + //超标 + @Transactional + public void toBpmAuditETA(BPMAuditCommand command) { + OrderDetail orderDetail = command.getExtensionData(); + List byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 1); + //不为空表示已推动过超标,直接返回结果 + if (!byOrderNoAndTag.isEmpty()) { + return; + } + RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId()); + String sysCode = routeOrder.getApproveOrderNo().getSysCode(); + String employeeNo = orderDetail.getEmployeeNo();//用户id + String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany();//用户编号 + //获取公司编号 + //安能超标 + if (BELONG_SYS_CODE_ANFSSC.equals(sysCode)) { + ANExceedStandardDto anExceedStandardDto = switch (command.getProductType()) { + case LEG_TYPE_TRAIN -> bpmParamFactory.ANCreatAuditParamByTrain(orderDetail); + case LEG_TYPE_AIRPLANE -> bpmParamFactory.ANCreatAuditParamByFlight(orderDetail); + case LEG_TYPE_HOTEL -> bpmParamFactory.ANCreatAuditParamByHotel(orderDetail); + case LEG_TYPE_TAXI -> bpmParamFactory.ANCreatAuditParamByCar(orderDetail); + case LEG_TYPE_OTHER -> bpmParamFactory.ANCreatAuditParamByOther(orderDetail); + default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); + }; + Long legId = orderDetail.getLegId();//节点id + Leg leg = jdbcLegRepository.findByLegId(legId); + anExceedStandardDto.setApplyNo(routeOrder.getApproveOrderNo().getFakeOrderNo())//申请单号 + .setLegNo(leg == null ? "" : leg.getLegNo());//行程编号 + DelayDispatch.attemptToSend(() -> bpmRequest.ANExceedStandard(anExceedStandardDto).getSuccess(), + 0); + } else { + //其它 + ExceedStandardDto exceedStandardDto = switch (command.getProductType()) { + case LEG_TYPE_TRAIN -> bpmParamFactory.creatAuditParamByTrain(orderDetail); + case LEG_TYPE_AIRPLANE -> bpmParamFactory.creatAuditParamByFlight(orderDetail); + case LEG_TYPE_HOTEL -> bpmParamFactory.creatAuditParamByHotel(orderDetail); + case LEG_TYPE_TAXI -> bpmParamFactory.creatAuditParamByCar(orderDetail); + case LEG_TYPE_OTHER -> bpmParamFactory.creatAuditParamByOther(orderDetail); + default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); + }; + exceedStandardDto.setReason(command.getReason()); + DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto, sysCode, employeeNo, accountCompany).getSuccess(), + 0); + } + //结束保存推送信息 + ProcessInitiationControl processInitiationControl = new ProcessInitiationControl(); + processInitiationControl.setOrderNo(orderDetail.getOrderNo()) + .setTag(1); + jdbcProcessInitiationControlRepository.save(processInitiationControl); + } + + //改签 + @Transactional + public void toBpmReschedule(BPMAuditCommand command) { + OrderDetail orderDetail = command.getExtensionData(); + RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId()); + String sysCode = routeOrder.getApproveOrderNo().getSysCode(); + String reason = command.getReason(); + //创建改签对象 + RescheduleDto rescheduleDto = new RescheduleDto(); + rescheduleDto.setFee(orderDetail.getPrice() == null ? new BigDecimal(0) : new BigDecimal(orderDetail.getPrice()))//费用 + .setOrderNo(orderDetail.getOrderNo())//订单号 + .setReason(reason);//原因 + //携程 + if (orderDetail.getSupplierName().equals(SUPPLIER_C_TRIP)) { + //退票 + if (command.getOperationType().equals(ORDER_EVENT_REFUND)) { + List byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 3); + //不为空表示已推动过退票,直接返回结果 + if (!byOrderNoAndTag.isEmpty()) { + return; + } + } + Integer rebookId = null;//默认为空 + rescheduleDto.setOrderSource(SUPPLIER_C_TRIP_BPM_NAME);//携程商旅 + //查询订单明细 + SearchOrderResponse searchOrderResponse = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderDetail.getOrderNo()); + //机票改签 + if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) { + //设置改签原时间、改签后时间、改签原因 + rebookId = setCTripChangeFlight(rescheduleDto, searchOrderResponse); + rescheduleDto.setOrderType(RESCHEDULE_TYPE_FLIGHT); + //改签 + List byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo() + "-" + rebookId, 2); + //不为空表示已推动过改签,直接返回结果 + if (!byOrderNoAndTag.isEmpty()) { + return; + } + } + //机票退票 + if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_REFUND)) { + String refundResonDesc = ""; + try { + FlightOrderInfoEntity flightOrderInfoList = searchOrderResponse.getItineraryList().get(0).getFlightOrderInfoList().get(0); + refundResonDesc = flightOrderInfoList.getRefundInfo().get(0).getRefundResonDesc(); + rescheduleDto.setReason(StringUtils.isNotBlank(refundResonDesc) ? refundResonDesc : "计划有变,更改行程"); + } catch (Exception e) { + //如果越界标识没有值 + rescheduleDto.setReason("计划有变,更改行程"); + } + rescheduleDto.setOrderType(REFUND_TYPE_FLIGHT); + } + + String employeeNo = orderDetail.getEmployeeNo(); + String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany(); + //发送 + DelayDispatch.attemptToSend(() -> bpmRequest.reschedule(rescheduleDto, sysCode, employeeNo, accountCompany).getSuccess(), + 0); + + //结束保存推送信息 + ProcessInitiationControl processInitiationControl = new ProcessInitiationControl(); + if (command.getOperationType().equals(ORDER_EVENT_CHANGE)) { + processInitiationControl.setOrderNo(orderDetail.getOrderNo() + "-" + rebookId); + processInitiationControl.setTag(2); + } + if (command.getOperationType().equals(ORDER_EVENT_REFUND)) { + processInitiationControl.setOrderNo(orderDetail.getOrderNo()); + processInitiationControl.setTag(3); + } + jdbcProcessInitiationControlRepository.save(processInitiationControl); + } + + //同程 + if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) { + //改签 + if (command.getOperationType().equals(ORDER_EVENT_CHANGE)) { + List byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 2); + //不为空表示已推动过改签,直接返回结果 + if (!byOrderNoAndTag.isEmpty()) { + return; + } + } + //退票 + if (command.getOperationType().equals(ORDER_EVENT_REFUND)) { + List byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 3); + //不为空表示已推动过退票,直接返回结果 + if (!byOrderNoAndTag.isEmpty()) { + return; + } + } + rescheduleDto.setOrderSource(SUPPLIER_L_Y_BPM_NAME);//同程商旅 + //火车票改签 + if (orderDetail.getProductType().equals(LEG_TYPE_TRAIN) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) { + TrainDetailResponse trainDetailResponse = lySearchRequest.getTrainOrderDetail(orderDetail.getOrderNo()); + setLYChangeTrain(rescheduleDto, trainDetailResponse);//火车票只支持一次改签 + rescheduleDto.setOrderType(RESCHEDULE_TYPE_TRAIN); + } + + //火车票退票 + if (orderDetail.getProductType().equals(LEG_TYPE_TRAIN) && command.getOperationType().equals(ORDER_EVENT_REFUND)) { + rescheduleDto.setOrderType(REFUND_TYPE_TRAIN); + rescheduleDto.setReason("计划有变,更改行程");//目前没有原因 + } + //机票改签 + if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + // 将LocalDateTime对象格式化成字符串 + String rebookStartTime = orderDetail.getStartTime().format(formatter); + rescheduleDto.setRebookStartTime(rebookStartTime);//变更后时间 + + FlightOrderResponse flightOrderResponse = lySearchRequest.getFlightOrderDetail(orderDetail.getOrderNo()); + //原订单 + String parentOrderSerialNo = flightOrderResponse.getData().getOrderDetails().getParentOrderSerialNo(); + OrderDetail orderDetailOld = jdbcOrderDetailRepository.findFirstByOrderNo(parentOrderSerialNo); + String startTime = orderDetailOld.getStartTime().format(formatter); + rescheduleDto.setStartTime(startTime); + rescheduleDto.setOrderType(RESCHEDULE_TYPE_FLIGHT); + rescheduleDto.setReason("计划有变,更改行程");//目前没有原因 + } + + //机票退票 + if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_REFUND)) { + rescheduleDto.setOrderType(REFUND_TYPE_FLIGHT); + rescheduleDto.setReason("计划有变,更改行程"); + } + + String employeeNo = orderDetail.getEmployeeNo(); + String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany(); + //发送 + DelayDispatch.attemptToSend(() -> bpmRequest.reschedule(rescheduleDto, sysCode, employeeNo, accountCompany).getSuccess(), + 0); + + //结束保存推送信息 + ProcessInitiationControl processInitiationControl = new ProcessInitiationControl(); + processInitiationControl.setOrderNo(orderDetail.getOrderNo()); + if (command.getOperationType().equals(ORDER_EVENT_CHANGE)) { + processInitiationControl.setTag(2); + } + if (command.getOperationType().equals(ORDER_EVENT_REFUND)) { + processInitiationControl.setTag(3); + } + jdbcProcessInitiationControlRepository.save(processInitiationControl); + } + + } + + + //携程机票改签 + private Integer setCTripChangeFlight(RescheduleDto rescheduleDto, SearchOrderResponse searchOrderResponse) { + List itineraryList = searchOrderResponse.getItineraryList(); + try { + ItineraryEntity itineraryEntity = itineraryList.get(0); + FlightOrderInfoEntity flightOrderInfoList = itineraryEntity.getFlightOrderInfoList().get(0); + //改签前时间 + String createTime = flightOrderInfoList.getFlightInfo().get(0).getTakeoffTime(); + List changeInfoList = flightOrderInfoList.getPassengerInfo().get(0).getSequenceInfo().get(0).getChangeInfo(); + //多次改签 + if (changeInfoList.size() >= 2) { + ChangeInfo changeInfoOld = changeInfoList.get(changeInfoList.size() - 2); + String cTakeOffTimeOld = changeInfoOld.getCTakeOffTime();//前一次改签时间 + ChangeInfo changeInfoNew = changeInfoList.get(changeInfoList.size() - 1); + String cTakeOffTimeNew = changeInfoNew.getCTakeOffTime();//最后一次改签时间 + String rebookReasonDescNew = changeInfoNew.getRebookReasonDesc();//最后一次改签原因 + //设置值 + rescheduleDto.setStartTime(cTakeOffTimeOld) + .setRebookStartTime(cTakeOffTimeNew) + .setReason(rebookReasonDescNew); + return changeInfoNew.getRebookId(); + } else { + ChangeInfo changeInfo = changeInfoList.get(changeInfoList.size() - 1); + //改签后时间 + String cTakeOffTime = changeInfo.getCTakeOffTime(); + //改签原因 + String RebookReasonDesc = changeInfo.getRebookReasonDesc(); + rescheduleDto.setStartTime(createTime) + .setRebookStartTime(cTakeOffTime) + .setReason(RebookReasonDesc); + return changeInfo.getRebookId(); + } + } catch (Exception e) { + rescheduleDto.setStartTime("") + .setRebookStartTime("") + .setReason("计划有变,更改行程"); + return null; + } + } + + //火车票改签 + private void setLYChangeTrain(RescheduleDto rescheduleDto, TrainDetailResponse trainDetailResponse) { + TrainDetailResponse.TrainDetailData data = trainDetailResponse.getData(); + String trainNoOld = data.getTrainNo();//原车次 + String planBeginDateOld = data.getPlanBeginDate();//原时间 + rescheduleDto.setStartTime(planBeginDateOld) + .setTrainNumber(trainNoOld);//原车次 + if (!data.getItems().isEmpty()) { + TrainDetailResponse.Item item = data.getItems().get(0); + String seatClassOld = item.getSeatClass();//原席别 + TrainDetailResponse.ChangeInfo changeInfo = item.getChangeInfo(); + //如果是空表示是改签后订单 + if (Objects.isNull(changeInfo)) { + //获取原订单的changeInfo + String parentOrderSerialNo = data.getParentOrderSerialNo(); + TrainDetailResponse parentTrainDetailResponse = lySearchRequest.getTrainOrderDetail(parentOrderSerialNo); + if (parentTrainDetailResponse != null) { + changeInfo = parentTrainDetailResponse.getData().getItems().get(0).getChangeInfo(); + } + + } + String planBeginDateNew = ""; + String trainNoNew = ""; + String seatClassNew = ""; + //不为空 + if (!Objects.isNull(changeInfo)) { + planBeginDateNew = changeInfo.getPlanBeginDate();//改签后时间 + trainNoNew = changeInfo.getTrainNo();//改签后车次 + seatClassNew = changeInfo.getChangeItem().getSeatClass();//改签后席别 + } + //设置值 + rescheduleDto.setRebookStartTime(planBeginDateNew) + .setSeatingStandard(seatClassOld)//原席别 + .setRebookTrainNumber(trainNoNew)//改签后车次 + .setRebookSeatingStandard(seatClassNew)//改签后席别 + .setReason("计划有变,更改行程"); + } + } +} diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index 6836149d..ccaa5caf 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -3,6 +3,7 @@ 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; @@ -19,6 +20,7 @@ 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; @@ -45,14 +47,12 @@ 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.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; +import java.util.*; import static com.chint.infrastructure.constant.BPMConstant.*; import static com.chint.infrastructure.constant.BelongSystemConstant.BELONG_SYS_CODE_ANFSSC; @@ -113,6 +113,9 @@ public class OrderDomainService { @Autowired private JdbcLegRepository jdbcLegRepository; + @Autowired + private BPMOrderDomainService bpmOrderDomainService; + private Set companyBlackList = new HashSet<>(); public RouteOrder saveOrder(RouteOrder routeOrder) { @@ -162,7 +165,6 @@ public class OrderDomainService { } - @ListenTo(command = "OrderCreateCommand", order = 0) public RouteOrder createOrder(OrderCreateCommand command) { User user = command.getUser(); @@ -272,192 +274,12 @@ public class OrderDomainService { @ListenTo(command = "BPMAuditCommand", order = 0) public void toBpmAudit(BPMAuditCommand command) { if (command.getOperationType().equals(ORDER_EVENT_ETA)) { - toBpmAuditETA(command); + bpmOrderDomainService.toBpmAuditETA(command); } else if ( (command.getOperationType().equals(ORDER_EVENT_CHANGE) || command.getOperationType().equals(ORDER_EVENT_REFUND)) && (command.getProductType().equals(LEG_TYPE_TRAIN) || command.getProductType().equals(LEG_TYPE_AIRPLANE)) ) { - toBpmReschedule(command); - } - } - - private void toBpmAuditETA(BPMAuditCommand command) { - OrderDetail orderDetail = command.getExtensionData(); - RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId()); - String sysCode = routeOrder.getApproveOrderNo().getSysCode(); - String employeeNo = orderDetail.getEmployeeNo();//用户id - String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany();//用户编号 - //获取公司编号 - //安能超标 - if (BELONG_SYS_CODE_ANFSSC.equals(sysCode)) { - ANExceedStandardDto anExceedStandardDto = switch (command.getProductType()) { - case LEG_TYPE_TRAIN -> bpmParamFactory.ANCreatAuditParamByTrain(orderDetail); - case LEG_TYPE_AIRPLANE -> bpmParamFactory.ANCreatAuditParamByFlight(orderDetail); - case LEG_TYPE_HOTEL -> bpmParamFactory.ANCreatAuditParamByHotel(orderDetail); - case LEG_TYPE_TAXI -> bpmParamFactory.ANCreatAuditParamByCar(orderDetail); - case LEG_TYPE_OTHER -> bpmParamFactory.ANCreatAuditParamByOther(orderDetail); - default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); - }; - Long legId = orderDetail.getLegId();//节点id - Leg leg = jdbcLegRepository.findByLegId(legId); - anExceedStandardDto.setApplyNo(routeOrder.getApproveOrderNo().getFakeOrderNo())//申请单号 - .setLegNo(leg == null ? "" : leg.getLegNo());//行程编号 - DelayDispatch.attemptToSend(() -> bpmRequest.ANExceedStandard(anExceedStandardDto).getSuccess(), - 0); - } else { - //其它 - ExceedStandardDto exceedStandardDto = switch (command.getProductType()) { - case LEG_TYPE_TRAIN -> bpmParamFactory.creatAuditParamByTrain(orderDetail); - case LEG_TYPE_AIRPLANE -> bpmParamFactory.creatAuditParamByFlight(orderDetail); - case LEG_TYPE_HOTEL -> bpmParamFactory.creatAuditParamByHotel(orderDetail); - case LEG_TYPE_TAXI -> bpmParamFactory.creatAuditParamByCar(orderDetail); - case LEG_TYPE_OTHER -> bpmParamFactory.creatAuditParamByOther(orderDetail); - default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); - }; - exceedStandardDto.setReason(command.getReason()); - DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto, sysCode, employeeNo, accountCompany).getSuccess(), - 0); - } - } - - private void toBpmReschedule(BPMAuditCommand command) { - OrderDetail orderDetail = command.getExtensionData(); - RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId()); - String sysCode = routeOrder.getApproveOrderNo().getSysCode(); - String reason = command.getReason(); - //创建改签对象 - RescheduleDto rescheduleDto = new RescheduleDto(); - rescheduleDto.setFee(orderDetail.getPrice() == null ? new BigDecimal(0) : new BigDecimal(orderDetail.getPrice()))//费用 - .setOrderNo(orderDetail.getOrderNo())//订单号 - .setReason(reason);//原因 - //携程 - if (orderDetail.getSupplierName().equals(SUPPLIER_C_TRIP)) { - rescheduleDto.setOrderSource(SUPPLIER_C_TRIP_BPM_NAME);//携程商旅 - //查询订单明细 - SearchOrderResponse searchOrderResponse = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderDetail.getOrderNo()); - //机票改签 - if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) { - //设置改签原时间、改签后时间、改签原因 - setCTripChangeFlight(rescheduleDto, searchOrderResponse); - rescheduleDto.setOrderType(RESCHEDULE_TYPE_FLIGHT); - } - //机票退票 - if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_REFUND)) { - String refundResonDesc = ""; - try { - FlightOrderInfoEntity flightOrderInfoList = searchOrderResponse.getItineraryList().get(0).getFlightOrderInfoList().get(0); - refundResonDesc = flightOrderInfoList.getRefundInfo().get(0).getRefundResonDesc(); - rescheduleDto.setReason(StringUtils.isNotBlank(refundResonDesc) ? refundResonDesc : "计划有变,更改行程"); - } catch (Exception e) { - //如果越界标识没有值 - rescheduleDto.setReason("计划有变,更改行程"); - } - rescheduleDto.setOrderType(REFUND_TYPE_FLIGHT); - } - } - - //同程 - if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) { - rescheduleDto.setOrderSource(SUPPLIER_L_Y_BPM_NAME);//同程商旅 - //火车票改签 - if (orderDetail.getProductType().equals(LEG_TYPE_TRAIN) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) { - TrainDetailResponse trainDetailResponse = lySearchRequest.getTrainOrderDetail(orderDetail.getOrderNo()); - setLYChangeTrain(rescheduleDto, trainDetailResponse);//火车票只支持一次改签 - rescheduleDto.setOrderType(RESCHEDULE_TYPE_TRAIN); - } - - //火车票退票 - if (orderDetail.getProductType().equals(LEG_TYPE_TRAIN) && command.getOperationType().equals(ORDER_EVENT_REFUND)) { - rescheduleDto.setOrderType(REFUND_TYPE_TRAIN); - rescheduleDto.setReason("计划有变,更改行程");//目前没有原因 - } - //机票改签 - if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - // 将LocalDateTime对象格式化成字符串 - String rebookStartTime = orderDetail.getStartTime().format(formatter); - rescheduleDto.setRebookStartTime(rebookStartTime);//变更后时间 - - FlightOrderResponse flightOrderResponse = lySearchRequest.getFlightOrderDetail(orderDetail.getOrderNo()); - //原订单 - String parentOrderSerialNo = flightOrderResponse.getData().getOrderDetails().getParentOrderSerialNo(); - OrderDetail orderDetailOld = jdbcOrderDetailRepository.findFirstByOrderNo(parentOrderSerialNo); - String startTime = orderDetailOld.getStartTime().format(formatter); - rescheduleDto.setStartTime(startTime); - rescheduleDto.setOrderType(RESCHEDULE_TYPE_FLIGHT); - rescheduleDto.setReason("计划有变,更改行程");//目前没有原因 - } - - //机票退票 - if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_REFUND)) { - rescheduleDto.setOrderType(REFUND_TYPE_FLIGHT); - rescheduleDto.setReason("计划有变,更改行程"); - } - - } - String employeeNo = orderDetail.getEmployeeNo(); - String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany(); - //发送 - DelayDispatch.attemptToSend(() -> bpmRequest.reschedule(rescheduleDto, sysCode, employeeNo, accountCompany).getSuccess(), - 0); - } - - //携程机票改签 - private void setCTripChangeFlight(RescheduleDto rescheduleDto, SearchOrderResponse searchOrderResponse) { - List itineraryList = searchOrderResponse.getItineraryList(); - try { - ItineraryEntity itineraryEntity = itineraryList.get(0); - FlightOrderInfoEntity flightOrderInfoList = itineraryEntity.getFlightOrderInfoList().get(0); - //改签前时间 - String createTime = flightOrderInfoList.getFlightInfo().get(0).getTakeoffTime(); - List changeInfoList = flightOrderInfoList.getPassengerInfo().get(0).getSequenceInfo().get(0).getChangeInfo(); - //多次改签 - if (changeInfoList.size() >= 2) { - ChangeInfo changeInfoOld = changeInfoList.get(changeInfoList.size() - 2); - String cTakeOffTimeOld = changeInfoOld.getCTakeOffTime();//前一次改签时间 - ChangeInfo changeInfoNew = changeInfoList.get(changeInfoList.size() - 1); - String cTakeOffTimeNew = changeInfoNew.getCTakeOffTime();//最后一次改签时间 - String rebookReasonDescNew = changeInfoNew.getRebookReasonDesc();//最后一次改签原因 - //设置值 - rescheduleDto.setStartTime(cTakeOffTimeOld) - .setRebookStartTime(cTakeOffTimeNew) - .setReason(rebookReasonDescNew); - } else { - ChangeInfo changeInfo = changeInfoList.get(changeInfoList.size() - 1); - //改签后时间 - String cTakeOffTime = changeInfo.getCTakeOffTime(); - //改签原因 - String RebookReasonDesc = changeInfo.getRebookReasonDesc(); - rescheduleDto.setStartTime(createTime) - .setRebookStartTime(cTakeOffTime) - .setReason(RebookReasonDesc); - } - } catch (Exception e) { - rescheduleDto.setStartTime("") - .setRebookStartTime("") - .setReason("计划有变,更改行程"); - } - } - //火车票改签 - private void setLYChangeTrain(RescheduleDto rescheduleDto, TrainDetailResponse trainDetailResponse) { - TrainDetailResponse.TrainDetailData data = trainDetailResponse.getData(); - String trainNoOld = data.getTrainNo();//原车次 - String planBeginDateOld = data.getPlanBeginDate();//原时间 - rescheduleDto.setStartTime(planBeginDateOld) - .setTrainNumber(trainNoOld);//原车次 - if (!data.getItems().isEmpty()) { - TrainDetailResponse.Item item = data.getItems().get(0); - String seatClassOld = item.getSeatClass();//原席别 - TrainDetailResponse.ChangeInfo changeInfo = item.getChangeInfo(); - String planBeginDateNew = changeInfo.getPlanBeginDate();//改签后时间 - String trainNoNew = changeInfo.getTrainNo();//改签后车次 - String seatClassNew = changeInfo.getChangeItem().getSeatClass();//改签后席别 - //设置值 - rescheduleDto.setRebookStartTime(planBeginDateNew) - .setSeatingStandard(seatClassOld)//原席别 - .setRebookTrainNumber(trainNoNew)//改签后车次 - .setRebookSeatingStandard(seatClassNew)//改签后席别 - .setReason("计划有变,更改行程"); + bpmOrderDomainService.toBpmReschedule(command); } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcProcessInitiationControlRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcProcessInitiationControlRepository.java new file mode 100644 index 00000000..5ffaf5ae --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcProcessInitiationControlRepository.java @@ -0,0 +1,14 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity; +import com.chint.domain.aggregates.system.ProcessInitiationControl; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface JdbcProcessInitiationControlRepository extends CrudRepository { + + List findByOrderNoAndTag(String orderNo,Integer tag); +}