Compare commits

...

10 Commits

Author SHA1 Message Date
lulz1 fdad2e2bec 提交代码 2024-03-29 21:08:18 +08:00
dengwc 73f747fca9 结算明细字段映射调整 2024-03-29 16:49:18 +08:00
dengwc 7b94273155 流程不重复发起调整 2024-03-29 14:42:35 +08:00
dengwc 42eafa33d2 流程不重复发起调整 2024-03-29 12:59:27 +08:00
lulz1 c8d88f707c 添加部分结算代码 2024-03-29 10:51:22 +08:00
lulz1 3db25286ba Merge remote-tracking branch 'origin/dev' into dev 2024-03-29 10:50:25 +08:00
dengwc 63552f2727 Merge remote-tracking branch 'origin/dev' into dev 2024-03-29 10:23:15 +08:00
dengwc 4bee4a258d 流程不重复发起调整,同程火车改签bug处理 2024-03-29 10:22:45 +08:00
lulz1 c8e296a0c4 Merge branch 'dev' of http://47.97.21.20:3000/echo/route into dev 2024-03-29 09:25:50 +08:00
lulz1 3c14743c13 修改FSSC审批单跳转类型2的跳转方式 2024-03-29 09:22:35 +08:00
22 changed files with 777 additions and 228 deletions

View File

@ -95,6 +95,9 @@ public class FSSCController {
reDirectUrl = postRequest.getReDirectUrl(generateUrlPathFromDataBase(dataBaseUrl, employeeNo));
}
if (sysCode.getSystemCodeUrl().getRedirectType() == 2) {
reDirectUrl = dataBaseUrl;
}
return reDirectUrl;
}

View File

@ -22,6 +22,7 @@ import java.util.Optional;
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME;
@Data
@ -134,7 +135,7 @@ public class OrderDetail implements Serializable {
}
public OrderEvent getLastEvent() {
if(this.orderEventList == null){
if (this.orderEventList == null) {
return null;
}
return this.orderEventList.isEmpty() ? null : this.orderEventList.get(this.orderEventList.size() - 1);
@ -143,6 +144,16 @@ public class OrderDetail implements Serializable {
// .orElseThrow(() -> new NotFoundException(NOT_FOUND));
}
public Optional<OrderEvent> getETAEvent() {
if (this.orderEventList == null) {
return Optional.empty();
}
return this.orderEventList
.stream()
.filter(it -> it.getEventType().equals(ORDER_EVENT_ETA))
.findFirst();
}
public OrderDetail price(String price) {
this.price = price;
return this;

View File

@ -1,5 +1,7 @@
package com.chint.domain.aggregates.order.order_record;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.OrderEvent;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -7,6 +9,11 @@ import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA;
@Data
@Table("order_car_record")
@NoArgsConstructor
@ -53,6 +60,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,6 +69,7 @@ public class OrderCarRecord extends OrderBaseRecord {
private String projectOrderNo; // 项目订单号
private String offlineCcomyCode; // 成本中心
private String orderSource; // 预订来源线上/线下
private String payAmount;//支付总金额
//添加行程信息
@ -98,20 +107,18 @@ public class OrderCarRecord extends OrderBaseRecord {
}
// 加载财务信息
public OrderCarRecord loadFinancialInfo(String accountCompanyId,
String accountCompanyName,
String accountPeriod,
public OrderCarRecord loadFinancialInfo(String accountPeriod,
String billNo,
String orderAmount) {
this.setAccountCompanyId(accountCompanyId);
this.setAccountCompanyName(accountCompanyName);
String orderAmount,
String payAmount) {
this.setAccountPeriod(accountPeriod);
this.setBillNo(billNo);
this.setOrderAmount(orderAmount);
this.setPayAmount(payAmount);
return this;
}
// 加载费用细节
// 加载费用细节, 未税金额税费服务费取消费额外费用额外费用名称
public OrderCarRecord loadFeeDetails(String noTaxAmt,
String taxAmt,
String serviceCost,
@ -128,10 +135,12 @@ public class OrderCarRecord extends OrderBaseRecord {
}
// 加载付款和项目信息
public OrderCarRecord loadPaymentAndProjectInfo(String paymentType,
String comyPayAmt) {
public OrderCarRecord loadPayment(String paymentType,
String comyPayAmt,
String ownPayAmt) {
this.setPaymentType(paymentType);
this.setComyPayAmt(comyPayAmt);
this.setOwnPayAmt(ownPayAmt);
return this;
}
@ -146,16 +155,20 @@ public class OrderCarRecord extends OrderBaseRecord {
}
// 加载来源和系统归属信息, 线上线下
public OrderCarRecord loadSourceAndSystemInfo(String orderSource) {
public OrderCarRecord loadSource(String orderSource) {
this.setOrderSource(orderSource);
return this;
}
// 加载超标信息
public OrderCarRecord loadComplianceInfo(String overStandard,
String overStandardReason) {
this.setOverStandard(overStandard);
this.setOverStandardReason(overStandardReason);
public OrderCarRecord loadComplianceInfo(OrderDetail orderDetail) {
orderDetail.getETAEvent().ifPresentOrElse(it->{
this.setOverStandard("");
this.setOverStandardReason(overStandardReason);
},()->{
this.setOverStandard("");
this.setOverStandardReason("");
});
return this;
}

View File

@ -12,7 +12,7 @@ import org.springframework.data.relational.core.mapping.Table;
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class OrderHotelRecord extends OrderBaseRecord{
public class OrderHotelRecord extends OrderBaseRecord {
@Id
private Long id;
private Long orderDetailId;
@ -83,14 +83,19 @@ public class OrderHotelRecord extends OrderBaseRecord{
}
// 加载酒店和入住信息
public OrderHotelRecord loadHotelAndStayInfo(String hotelName, String hotelAddress, String checkInDate, String departureDate,
int roomCount, String roomTypeName, String country, String province, String checkInCity) {
public OrderHotelRecord loadHotelInfo(String hotelName, String hotelAddress, String checkInDate, String departureDate,
int roomCount, String roomTypeName) {
this.setHotelName(hotelName);
this.setHotelAddress(hotelAddress);
this.setCheckInDate(checkInDate);
this.setDepartureDate(departureDate);
this.setRoomCount(roomCount);
this.setRoomTypeName(roomTypeName);
return this;
}
// 加载地理信息位置
public OrderHotelRecord loadLocationInfo(String country, String province, String checkInCity) {
this.setCountry(country);
this.setProvince(province);
this.setCheckInCity(checkInCity);
@ -199,5 +204,4 @@ public class OrderHotelRecord extends OrderBaseRecord{
}
}

View File

@ -0,0 +1,107 @@
package com.chint.domain.aggregates.order.order_record.ctrip_order_record;
import cn.hutool.core.bean.BeanUtil;
import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
@Table("c_trip_hotel_order_detail")
public class CTripHotelOrderDetail implements Serializable {
@Serial
private static final long serialVersionUID = 1027124557206346513L;
@Id
private Long id;
private Long cTripHotelRecordId;
private Long OrderId;
private String EmployeeName;
private String EmployeeID;
private String WorkCity;
private String OrderDate;
private String RoomName;
private String RoomNameEN;
private Integer RoomQuantity;
private String ClientName;
private String StartTime;
private String EndTime;
private Double PostAmount;
private String IsHasSpecialInvoice;
private String ServerFrom;
private String LowPriceRC;
private String LowPriceRC_VV;
private String LowPriceRCInfo;
private String LowPriceRCInfoEN;
private String AgreementRC;
private String AgreementRC_VV;
private String AgreementRCInfo;
private String AgreementRCInfoEN;
private String CostCenter;
private String CostCenter2;
private String CostCenter3;
private String CostCenter4;
private String CostCenter5;
private String CostCenter6;
private String JourneyReason;
private String Project;
private String DefineTitleContent;
private String DefineTitleContent2;
private String HotelRelatedJourneyNo;
private String Remarks;
private String PayType;
private String BalanceType;
private String IsMixPayment;
private Double SettlementACCNTAmt;
private Double SettlementPersonAmt;
private Double CouponAmount;
private String Dept1;
private String Dept2;
private String Dept3;
private String Dept4;
private String Dept5;
private String Dept6;
private String Dept7;
private String Dept8;
private String Dept9;
private String Dept10;
private String MinPriceRC;
private String MinPriceRC_VV;
private String RankName;
private String RankNameEn;
private String ConfirmType;
private String ConfirmType2;
private String ConfirmPerson;
private String ConfirmPerson2;
private String ConfirmPersonCC;
private String ConfirmPersonCC2;
private String ConfirmPersonName;
private String ConfirmPersonName2;
private String ConfirmPersonCCName;
private String ConfirmPersonCCName2;
private Double TPMaxPrice;
private String RoomType;
private Integer MealType;
private String ProjectCode;
private String CancelReason;
private String CancelReasonDesc;
private String ContractRoomExistedFlag;
private String RefundTime;
private String RepeatBookingRC;
private String RepeatBookingDesc;
private String RepeatBookingRC_VV;
private String UserNamePinyin;
private String ConfigCurrency;
private Double ConfigExchangeToSettlement;
private Double TPConfigMinPrice;
private Double TPConfigMaxPrice;
private String ReservationType;
private String PreEmail;
public static CTripHotelOrderDetail of(OrderHotelResponse.SettlementOrderDetail data) {
return BeanUtil.copyProperties(data, CTripHotelOrderDetail.class);
}
}

View File

@ -20,12 +20,15 @@ public class CTripHotelRecord {
private CTripHotelRecordBase cTripHotelRecordBase;
@MappedCollection(idColumn = "c_trip_hotel_record_id")
private CTripHotelInfo cTripHotelInfo;
@MappedCollection(idColumn = "c_trip_hotel_record_id")
private CTripHotelOrderDetail cTripHotelOrderDetail;
public static CTripHotelRecord of(CTripHotelRecordBase cTripHotelRecordBase, CTripHotelInfo cTripHotelInfo) {
public static CTripHotelRecord of(CTripHotelRecordBase cTripHotelRecordBase, CTripHotelInfo cTripHotelInfo, CTripHotelOrderDetail cTripHotelOrderDetail) {
CTripHotelRecord cTripHotelRecord = new CTripHotelRecord();
cTripHotelRecord.setRecordId(String.valueOf(cTripHotelRecordBase.getRecordId()));
cTripHotelRecord.setCTripHotelRecordBase(cTripHotelRecordBase);
cTripHotelRecord.setCTripHotelInfo(cTripHotelInfo);
cTripHotelRecord.setCTripHotelOrderDetail(cTripHotelOrderDetail);
cTripHotelRecord.setCreateTime(DateTimeUtil.strToTimeMM(cTripHotelRecordBase.getCreateTime()));
return cTripHotelRecord;
}

View File

@ -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;
}

View File

@ -1,20 +1,27 @@
package com.chint.domain.factoriy.order_record;
import cn.hutool.core.bean.BeanUtil;
import com.chint.domain.aggregates.order.*;
import com.chint.application.dtos.response.LocationRes;
import com.chint.domain.aggregates.order.CarOrderDetail;
import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.OrderDetail;
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.CTripCarRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*;
import com.chint.domain.repository.LocationRepository;
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;
import java.util.List;
import java.util.Optional;
@Component
public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFactory{
public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFactory {
@Autowired
private OrderDetailDomainService orderDetailDomainService;
@ -22,21 +29,100 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFa
private JdbcCtripHotelOrderDetailRepository jdbcCtripHotelOrderDetailRepository;
@Autowired
private OrderRecordFactory orderRecordFactory;
@Autowired
private RouteRepository routeRepository;
@Autowired
private LocationRepository locationRepository;
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) {
CTripCarRecord cTripCarRecord = (CTripCarRecord) orderCarRecordData;
String routeOrderNo = cTripCarRecord.getRouteOrderNo();
RouteOrder byOrderNo = routeRepository.findByOrderNo(routeOrderNo);
OrderCarRecord orderCarRecord = orderRecordFactory
.buildWithRouteOrder(byOrderNo)
.carRecord();
CTripCarRecordBase cTripCarRecordBase = cTripCarRecord.getCTripCarRecordBase();
//携程的打车订单可以直接通过订单号获取对应的订单
Optional<OrderDetail> orderDetail = byOrderNo.getOrderDetails().stream().filter(it -> it.getOrderNo().equals(String.valueOf(
cTripCarRecordBase.getOrderId()
))).findFirst();
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()),
String.valueOf(cTripCarRecordBase.getRealAmountHasPost()));
// 加载费用细节, 未税金额税费服务费取消费额外费用额外费用名称 , 携程马上用车产品没有税费和额外费用字段
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");
}
// 加载超标信息, 加载订单关联信息 加载订单状态 单号创建时间等信息
orderDetail.ifPresent(it -> {
CarOrderDetail carOrderDetail = it.getCarOrderDetail();
orderCarRecord.loadComplianceInfo(it)
.loadRelatedOrderInfo(it.getOrderId(),
carOrderDetail.getDetailId(),
carOrderDetail.getReceiptsNum(),
carOrderDetail.getParentOrderNo(),
carOrderDetail.getOriginalOrderNo())
.loadBasicOrderInfo(carOrderDetail.getOrderNo(),
carOrderDetail.getOrderStatus(),
carOrderDetail.getCreateTime());
});
return orderCarRecord;
}
@ -55,6 +141,38 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFa
@Override
public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData) {
CTripHotelRecord cTripHotelRecord = (CTripHotelRecord) orderHotelRecordData;
CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail();
String routeOrderNo = cTripHotelRecord.getRouteOrderNo();
RouteOrder byOrderNo = routeRepository.findByOrderNo(routeOrderNo);
OrderHotelRecord orderHotelRecord = orderRecordFactory
.buildWithRouteOrder(byOrderNo)
.hotelRecord();
CTripHotelInfo cTripHotelInfo = cTripHotelRecord.getCTripHotelInfo();
// 加载酒店和入住信息
orderHotelRecord.loadHotelInfo(cTripHotelInfo.getHotelName(),
cTripHotelInfo.getHotelName(),
cTripHotelOrderDetail.getStartTime(),
cTripHotelOrderDetail.getEndTime(),
cTripHotelOrderDetail.getRoomQuantity(),
cTripHotelOrderDetail.getRoomName());
// 加载地理信息位置
Integer cityID = cTripHotelInfo.getCityID();
List<Location> locations = locationRepository.findByCityId(Long.valueOf(cityID));
if (locations != null && !locations.isEmpty()) {
Location location = locations.get(0);
LocationRes locationRes = LocationRes.copyFrom(location);
orderHotelRecord.loadLocationInfo(locationRes.getCountry(), locationRes.getProvince(), cTripHotelInfo.getCityName());
} else {
//如果找不到该地区那么只能先用空的
orderHotelRecord.loadLocationInfo("", "", cTripHotelInfo.getCityName());
}
// 加载酒店品牌和星级信息
// orderHotelRecord.loadBrandAndStarRateInfo()
return null;
}

View File

@ -131,6 +131,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.setBookOrgCode2(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息2
.setBookOrgCode3(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息3
.setOfflineCcomyCode(lyOrderFlightRecord.getPassengerCostCenter()) //成本中心
/* .setOrderStatus() //结算状态
.setExpenseOrderAmount() //订单金额
.setSettleOrderFlag() //订单对账状态
.setPayAmount() //支付金额
*/
;
}
@ -187,6 +192,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.setBookOrgCode2("") //入住人组织架构信息2
.setBookOrgCode3("") //入住人组织架构信息3
.setOfflineCcomyCode(lyOrderHotelRecord.getPassengerCostCenter()) //成本中心
/* .setOrderStatus() //结算状态
.setExpenseOrderAmount() //订单金额
.setSettleOrderFlag() //订单对账状态
.setPayAmount() //支付金额
*/
;
}
@ -234,14 +244,20 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.setBookOrgCode2("")//出行人组织架构信息2
.setBookOrgCode3("")//出行人组织架构信息3
.setOfflineCcomyCode(lyOrderTrainRecord.getPassengerCostCenter())//成本中心
.setTravelUserBirthday("")//生日
/* .setOrderStatus() //结算状态
.setExpenseOrderAmount() //订单金额
.setSettleOrderFlag() //订单对账状态
.setPayAmount() //支付金额
*/
/* .setTravelUserBirthday("")//生日
.setTravelUserPhone("") //出行人手机号
.setTravelUserSex("")//"性别0保密不展示 1男 2女"
.setTravelUserType("") //"乘客类型:成人(ADULT) 儿童(CHILDREN) 婴儿(BABY)"
.setPassportNo("")//乘客证件号
.setPassportType("")//乘客证件类型
.setTrainTime("")//发车时间 yyyy - MM - dd HH:mm:ss
.setYxId("")//影像比对ID
.setYxId("")//影像比对ID*/
;
}
@ -288,9 +304,10 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
.setPaymentType(String.valueOf(getPaymentType(lyOrderCarRecord.getPayType()))) //"付款方式0公司统付 1个人付 2混付"
.setOfflineCcomyCode(lyOrderCarRecord.getPassengerDepartment()) //成本中心
.setOrderSource(lyOrderCarRecord.getBookingPlat()) //预订来源线上/线下
// .setORDER_AMOUNT() //订单金额
// .setSETTLE_ORDER_FLAG() //订单对账状态
// .setpayAmount()// 支付金额
/* .setExpenseOrderAmount() //订单金额
.setSettleOrderFlag() //订单对账状态
.setPayAmount()// 支付金额*/
;
}

View File

@ -33,6 +33,8 @@ public class OrderRecordBasic {
private String bookingUserPhone;
// 资源供应商
private String supplier;
// 是否超标
private String overStandard;
// 超标原因
private String overStandardReason;
// 项目订单号
@ -46,10 +48,10 @@ public class OrderRecordBasic {
// 加载用户和预订信息
public OrderRecordBasic loadBookingInfo(String bookingUserCode,
String bookingName,
String bookingUserPhone,
String userName,
String userCode) {
String bookingName,
String bookingUserPhone,
String userName,
String userCode) {
this.setBookingUserPhone(bookingUserPhone);
this.setBookingUserCode(bookingUserCode);
this.setBookingName(bookingName);

View File

@ -21,6 +21,7 @@ public interface LocationRepository {
Location findByCityIdAndLevelFour(Long cityId);
List<Location> findByCityIdAndLocationType(Long cityId , Integer LocationType);
List<Location> findByCityId(Long cityId);
List<Location> findByLocationType(Integer LocationType);
List<Location> findAllLevelThreeAndFour();
@ -56,7 +57,6 @@ public interface LocationRepository {
List<Location> findChinaCityByLevel(String locationNames, Integer level);
List<Location> findNotChintCityByLevel(String locationNames, Integer level);
}

View File

@ -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<ProcessInitiationControl> 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<ProcessInitiationControl> 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<ProcessInitiationControl> 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<ProcessInitiationControl> byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 2);
//不为空表示已推动过改签直接返回结果
if (!byOrderNoAndTag.isEmpty()) {
return;
}
}
//退票
if (command.getOperationType().equals(ORDER_EVENT_REFUND)) {
List<ProcessInitiationControl> 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<ItineraryEntity> itineraryList = searchOrderResponse.getItineraryList();
try {
ItineraryEntity itineraryEntity = itineraryList.get(0);
FlightOrderInfoEntity flightOrderInfoList = itineraryEntity.getFlightOrderInfoList().get(0);
//改签前时间
String createTime = flightOrderInfoList.getFlightInfo().get(0).getTakeoffTime();
List<ChangeInfo> 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("计划有变,更改行程");
}
}
}

View File

@ -2,6 +2,7 @@ package com.chint.domain.service;
import com.chint.domain.aggregates.system.JTCompany;
import com.chint.domain.exceptions.AuthException;
import com.chint.domain.repository.JTCompanyRepository;
import com.chint.domain.repository.SystemCodeRepository;
import jakarta.annotation.PostConstruct;
@ -57,6 +58,9 @@ public class JTCompanyDomainService {
public String findSystemCodeByCompanyCode(String companyCode) {
JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(companyCode);
if(byCompanyCode == null){
throw new AuthException("用户所在公司不在实施范围内");
}
return systemCodeRepository.findById(byCompanyCode.getSystemCodeId()).getSystemCode();
}
}

View File

@ -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<String> 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<ItineraryEntity> itineraryList = searchOrderResponse.getItineraryList();
try {
ItineraryEntity itineraryEntity = itineraryList.get(0);
FlightOrderInfoEntity flightOrderInfoList = itineraryEntity.getFlightOrderInfoList().get(0);
//改签前时间
String createTime = flightOrderInfoList.getFlightInfo().get(0).getTakeoffTime();
List<ChangeInfo> 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);
}
}

View File

@ -8,6 +8,8 @@ import com.chint.infrastructure.echo_framework.command.EmptyCommand;
import com.chint.infrastructure.echo_framework.dispatch.ResultContainer;
import com.chint.infrastructure.echo_framework.queue.SimpleMessageQueue;
import lombok.Data;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
@ -59,13 +61,31 @@ public class EventManager implements ApplicationContextAware, BeanNameAware, Ini
String[] allBeanNames = context.getBeanDefinitionNames();
for (String beanName : allBeanNames) {
if (this.beanName.equals(beanName)) continue;
Object bean = context.getBean(beanName);
Object bean = context.getBean(beanName);//获取的可能是动态代理的类
scanAndRegister(bean);
}
}
private void scanAndRegister(Object bean) {
Method[] methods = bean.getClass().getDeclaredMethods();
Method[] methods = getTargetClassMethods(bean);
processAnnotation(methods, bean);
}
private Method[] getTargetClassMethods(Object bean) {
//判断是何种类型的代理,获取动态代理后的原类的自定义注解使其不会失效
if (AopUtils.isCglibProxy(bean)) {
return bean.getClass().getSuperclass().getDeclaredMethods();
} else if (AopUtils.isJdkDynamicProxy(bean)) {
Object target = AopProxyUtils.getSingletonTarget(bean);
if (target != null) {
return target.getClass().getDeclaredMethods();
}
}
return bean.getClass().getDeclaredMethods();
}
private void processAnnotation(Method[] methods, Object bean) {
for (Method method : methods) {
if (method.isAnnotationPresent(ListenTo.class)) {
ListenTo listenTo = method.getAnnotation(ListenTo.class);

View File

@ -4,6 +4,7 @@ import com.chint.domain.aggregates.system.JTCompany;
import com.chint.domain.repository.JTCompanyRepository;
import com.chint.infrastructure.repository.jdbc.JdbcJTCompanyRepositoryImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
@ -23,6 +24,7 @@ public class JTCompanyRepositoryImpl implements JTCompanyRepository {
return all;
}
@Cacheable(value = "JTCompanyByCompanyCode" , key = "#companyCode")
@Override
public JTCompany findByCompanyCode(String companyCode) {
return jdbcJTCompanyRepository.findByCompanyCode(companyCode);

View File

@ -80,6 +80,11 @@ public class LocationRepositoryImpl implements LocationRepository {
return jdbcLocationRepository.findByCityIdAndLocationType(cityId, LocationType);
}
@Override
public List<Location> findByCityId(Long cityId) {
return jdbcLocationRepository.findByCityId(cityId);
}
@Override
public List<Location> findByLocationType(Integer LocationType) {
return jdbcLocationRepository.findByLocationType(LocationType);

View File

@ -16,6 +16,7 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
List<Location> findByLocationType(Integer locationType);
List<Location> findByCityIdAndLocationType(Long cityId, Integer locationType);
List<Location> findByCityId(Long cityId);
Location findByLocationId(Long locationId);

View File

@ -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<ProcessInitiationControl, Long> {
List<ProcessInitiationControl> findByOrderNoAndTag(String orderNo,Integer tag);
}

View File

@ -72,7 +72,7 @@ public class CTripOrderRecordAutoSave {
String.valueOf(settlementDetail.getRecordId()));
if (record == null) {
record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail),
CTripHotelInfo.of(it.getHotelDetail()));
CTripHotelInfo.of(it.getHotelDetail()),CTripHotelOrderDetail.of(it.getOrderDetail()));
}
//补充额外的字段
OrderHotelResponse.SettlementOrderDetail orderDetail = it.getOrderDetail();

View File

@ -811,9 +811,9 @@ public class LYTest {
System.out.println(json);
}
// @Test
@Test
void searchTrain() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24032167537614664");
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DTC24032868398852849");
Gson gson = new Gson();
String json = gson.toJson(trainOrderDetail);
System.out.println(json);

View File

@ -1248,4 +1248,10 @@ class RouteApplicationTests {
void testInBlackList(){
orderDomainService.checkCompanyNameIfBlack("乐清正泰电器销售有限公司");
}
// @Test
void testSplid(){
String str = "20240301";
System.out.println(str.substring(0, 5));
}
}