提交携程结算明细保存代码

This commit is contained in:
Superdandan 2024-03-27 22:39:43 +08:00
parent 28aa7bdac5
commit 90a1b6994e
16 changed files with 413 additions and 134 deletions

View File

@ -0,0 +1,48 @@
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.OrderCarResponse;
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;
@Data
@Table("c_trip_car_quick_info")
public class CTripCarQuickInfo implements Serializable {
@Serial
private static final long serialVersionUID = 2343214623512376645L;
@Id
private Long id;
private Long cTripCarRecordId;
private int BookingType;
private String UseTime;
private String DepartureCityId;
private String DepartureDistrictCode;
private String DepartureCityName;
private String DepartureAddressDetail;
private String ArrivalCityId;
private String ArrivalDistrictCode;
private String ArrivalCityName;
private String ArrivalAddressDetail;
private int VehicleId;
private String VehicleName;
private String NormalDistance;
private String NormalTime;
private String ServiceBeginTime;
private String ServiceEndTime;
private String SceneName;
private String StandardName;
// private List<OrderCarResponse.DestinationChangeInfoApi> DestinationChangeList;
private String VendorName;
// 如果StandardGeoInfo是标准地理信息类
// private OrderCarResponse.StandardGeoInfo StandardGeoInfo;
private String CancelTime;
public static CTripCarQuickInfo of(OrderCarResponse.CarOrderQuickProductInfo data) {
return BeanUtil.copyProperties(data, CTripCarQuickInfo.class);
}
}

View File

@ -1,16 +1,31 @@
package com.chint.domain.aggregates.order.order_record.ctrip_order_record;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table;
@Table("c_trip_car_record")
public class CTripCarRecord {
import java.io.Serial;
import java.io.Serializable;
@Data
@Table("c_trip_car_record")
public class CTripCarRecord implements Serializable {
@Serial
private static final long serialVersionUID = 5553214622358970145L;
@Id
private Long id;
@MappedCollection(idColumn = "id")
private String recordId;
@MappedCollection(idColumn = "c_trip_car_record_id")
private CTripCarRecordBase cTripCarRecordBase;
@MappedCollection(idColumn = "c_trip_car_record_id")
private CTripCarQuickInfo cTripCarQuickInfo;
public static CTripCarRecord of(CTripCarRecordBase cTripCarRecordBase, CTripCarQuickInfo cTripCarQuickInfo) {
CTripCarRecord cTripCarRecord = new CTripCarRecord();
cTripCarRecord.setCTripCarQuickInfo(cTripCarQuickInfo);
cTripCarRecord.setCTripCarRecordBase(cTripCarRecordBase);
cTripCarRecord.setRecordId(String.valueOf(cTripCarRecordBase.getRecordId()));
return cTripCarRecord;
}
}

View File

@ -17,11 +17,11 @@ import java.io.Serializable;
@Data
@Table("c_trip_order_car_settlement_base_info")
public class CTripCarRecordBase implements Serializable {
@Serial
private static final long serialVersionUID = 4583214623558870145L;
@Id
private Long id;
private Long cTripCarRecordId;
private Long recordId;
private String batchNo;
private String createTime;

View File

@ -20,6 +20,7 @@ public class CTripFlightRecord {
CTripFlightRecord cTripFlightRecord = new CTripFlightRecord();
cTripFlightRecord.setCTripFlightRecordBase(cTripFlightRecordBase);
cTripFlightRecord.setCTripFlightInfo(cTripFlightInfo);
cTripFlightRecord.setRecordId(String.valueOf(cTripFlightRecordBase.getRecordId()));
return cTripFlightRecord;
}
}

View File

@ -0,0 +1,42 @@
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.OrderCarResponse;
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;
@Data
@Table("c_trip_hotel_info")
public class CTripHotelInfo implements Serializable {
@Serial
private static final long serialVersionUID = 4027343172340686513L;
@Id
private Long id;
private Long cTripHotelRecordId;
private String HotelName;
private String HotelNameEN;
private String CityName;
private String CityNameEN;
private Integer Star;
private boolean IsDomestic;
private String ISCU;
private Integer CityID;
private String DistrictCode;
private Integer DistrictID;
private String DistrictName;
private String BrandName;
private Integer ParentCityID;
private String ParentCityName;
private String ParentCityEnName;
private Integer HotelGroupId;
private String HotelGroupName;
public static CTripHotelInfo of(OrderHotelResponse.SettlementHotelDetail data) {
return BeanUtil.copyProperties(data, CTripHotelInfo.class);
}
}

View File

@ -13,5 +13,14 @@ public class CTripHotelRecord {
private String recordId;
@MappedCollection(idColumn = "c_trip_hotel_record_id")
private CTripHotelRecordBase cTripHotelRecordBase;
@MappedCollection(idColumn = "c_trip_hotel_record_id")
private CTripHotelInfo cTripHotelInfo;
public static CTripHotelRecord of(CTripHotelRecordBase cTripHotelRecordBase, CTripHotelInfo cTripHotelInfo) {
CTripHotelRecord cTripHotelRecord = new CTripHotelRecord();
cTripHotelRecord.setRecordId(String.valueOf(cTripHotelRecordBase.getRecordId()));
cTripHotelRecord.setCTripHotelRecordBase(cTripHotelRecordBase);
cTripHotelRecord.setCTripHotelInfo(cTripHotelInfo);
return cTripHotelRecord;
}
}

View File

@ -21,6 +21,7 @@ public class CTripHotelRecordBase implements Serializable {
private static final long serialVersionUID = 3087333171110684513L;
@Id
private Long id;
private Long cTripHotelRecordId;
private Long recordId;
private Long orderId;
private Integer accountId;
@ -69,10 +70,8 @@ public class CTripHotelRecordBase implements Serializable {
private BigDecimal averageRoomPrice;
public static CTripHotelRecordBase changeInfo(OrderHotelResponse.SettlementDetail SettlementDetail) {
CTripHotelRecordBase ctripHotelOrderDetail = new CTripHotelRecordBase();
if (SettlementDetail != null){
ctripHotelOrderDetail.setRecordId(SettlementDetail.getRecordId());
ctripHotelOrderDetail.setOrderId(SettlementDetail.getOrderID());
ctripHotelOrderDetail.setAccountId(SettlementDetail.getAccountId());
@ -121,7 +120,4 @@ public class CTripHotelRecordBase implements Serializable {
ctripHotelOrderDetail.setAverageRoomPrice(SettlementDetail.getAverageRoomPrice());
return ctripHotelOrderDetail;
}
return null;
}
}

View File

@ -0,0 +1,74 @@
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 com.chint.interfaces.rest.ctrip.dto.order.OrderTrainResponse;
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_train_info")
public class CTripTrainInfo implements Serializable {
@Serial
private static final long serialVersionUID = 3282323171110442253L;
@Id
private Long id;
private Long cTripTrainRecordId;
private long TicketInfoID;
private String TrainName;
private String FirstSeatTypeName;
private String TrainType;
private String DepartureCityName;
private String DepartureDate;
private String DepartureStationName;
private String DepartureStationEn;
private String ArrivalCityName;
private String ArrivalDate;
private String ArrivalStationName;
private String ArrivalStationEn;
private String ElectronicOrderNo;
private int CustomType;
private String CustomDetail;
private String TrainTicketType;
// private List<OrderTrainResponse.TrainData> TrainSeatPriceData;
private String ChangeStatus;
private double DealTicketPrice;
private double RebRefEstimateAmount;
private int DepartureCityID;
private String DepartureDistrictCode;
private int ArrivalCityID;
private String ArrivalDistrictCode;
private String ChangeCode;
private String DealSeatNo;
private String DealSeatName;
private long DepartureProvinceId;
private String DepartureProvinceName;
private long DepartureLocationId;
private String DepartureLocationName;
private int DepartureLocationCategoryId;
private long ArrivalProvinceId;
private String ArrivalProvinceName;
private long ArrivalLocationId;
private String ArrivalLocationName;
private int ArrivalLocationCategoryId;
private int Sequence;
private String RefundreasonCode;
private String RefundreasonCodeDesc;
private String IssueTicketTime;
private String RebookTicketSuccessTime;
private String RefundTicketSuccessTime;
private String ChangePreApprovalId;
private String RefundApprovalId;
// private OrderTrainResponse.StandardGeoInfo StandardGeoInfo;
private String ChangeDescription;
public static CTripTrainInfo of(OrderTrainResponse.CorpTrainSettlementTicketDetail data) {
return BeanUtil.copyProperties(data, CTripTrainInfo.class);
}
}

View File

@ -0,0 +1,31 @@
package com.chint.domain.aggregates.order.order_record.ctrip_order_record;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial;
import java.io.Serializable;
@Data
@Table("c_trip_train_record")
public class CTripTrainRecord implements Serializable {
@Serial
private static final long serialVersionUID = 4087333423450684513L;
@Id
private Long id;
private String recordId;
@MappedCollection(idColumn = "c_trip_train_record_id")
private CTripTrainRecordBase cTripTrainRecordBase;
@MappedCollection(idColumn = "c_trip_train_record_id")
private CTripTrainInfo cTripTrainInfo;
public static CTripTrainRecord of(CTripTrainRecordBase cTripTrainRecordBase, CTripTrainInfo cTripTrainInfo) {
CTripTrainRecord cTripTrainRecord = new CTripTrainRecord();
cTripTrainRecord.setRecordId(String.valueOf(cTripTrainRecordBase.getRecordId()));
cTripTrainRecord.setCTripTrainRecordBase(cTripTrainRecordBase);
cTripTrainRecord.setCTripTrainInfo(cTripTrainInfo);
return cTripTrainRecord;
}
}

View File

@ -21,6 +21,7 @@ public class CTripTrainRecordBase implements Serializable {
private static final long serialVersionUID = 1642492804808714974L;
@Id
private Long id;
private Long cTripTrainRecordId;
private Long recordId;
private Long orderId;
private String corpId;
@ -78,7 +79,7 @@ public class CTripTrainRecordBase implements Serializable {
public static CTripTrainRecordBase changeInfo(OrderTrainResponse.CorpTrainSettlementDetail trainSettlementDetail) {
CTripTrainRecordBase ctripTrainOrderDetail = new CTripTrainRecordBase();
if (trainSettlementDetail != null){
ctripTrainOrderDetail.setRecordId(trainSettlementDetail.getRecordID());
ctripTrainOrderDetail.setOrderId(trainSettlementDetail.getOrderID());
ctripTrainOrderDetail.setCorpId(trainSettlementDetail.getCorpId());
@ -135,8 +136,7 @@ public class CTripTrainRecordBase implements Serializable {
return ctripTrainOrderDetail;
// return BeanUtil.copyProperties(flightOrderSettlementBaseInfo,CtripFlightOrderDetail.class);
}
return null;
}
}

View File

@ -17,7 +17,6 @@ public interface CTripOrderDetailRepository {
CTripFlightRecord save(CTripFlightRecord cTripFlightRecord);
void saveAll(List<CTripFlightRecord> cTripFlightRecordList);
CTripFlightRecordBase findFlightByRecordId(Long id);
@ -38,4 +37,8 @@ public interface CTripOrderDetailRepository {
void saveAllCarRecord(List<CTripCarRecordBase> ctripCarOrderDetailList);
CTripCarRecordBase findCarByRecordId(Long id);
void saveAllCTripFlightRecord(List<CTripFlightRecord> cTripFlightRecordList);
void saveAllCTripHotelRecord(List<CTripHotelRecord> cTripHotelRecordList);
void saveAllCTripTrainRecord(List<CTripTrainRecord> cTripTrainRecordList);
void saveAllCTripCarRecord(List<CTripCarRecord> cTripCarRecordList);
}

View File

@ -35,6 +35,16 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
@Autowired
private JdbcCTripFlightRecordRepository jdbcCTripFlightRecordRepository;
@Autowired
private JdbcCTripCarRecordRepository jdbcCTripCarRecordRepository;
@Autowired
private JdbcCTripHotelRecordRepository jdbcCTripHotelRecordRepository;
@Autowired
private JdbcCTripTrainRecordRepository jdbcCTripTrainRecordRepository;
@Override
public CTripFlightRecordBase save(CTripFlightRecordBase ctripFlightOrderDetail) {
return jdbcCtripFlightOrderDetailRepository.save(ctripFlightOrderDetail);
@ -50,10 +60,6 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
return jdbcCTripFlightRecordRepository.save(cTripFlightRecord);
}
@Override
public void saveAll(List<CTripFlightRecord> cTripFlightRecordList) {
jdbcCTripFlightRecordRepository.saveAll(cTripFlightRecordList);
}
@Override
public CTripFlightRecordBase findFlightByRecordId(Long recordId) {
@ -107,6 +113,26 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
public CTripCarRecordBase findCarByRecordId(Long recordId) {
return jdbcCtripCarOrderDetailRepository.findByRecordId(recordId);
}
@Override
public void saveAllCTripFlightRecord(List<CTripFlightRecord> cTripFlightRecordList) {
jdbcCTripFlightRecordRepository.saveAll(cTripFlightRecordList);
}
@Override
public void saveAllCTripHotelRecord(List<CTripHotelRecord> cTripHotelRecordList) {
jdbcCTripHotelRecordRepository.saveAll(cTripHotelRecordList);
}
@Override
public void saveAllCTripTrainRecord(List<CTripTrainRecord> cTripTrainRecordList) {
jdbcCTripTrainRecordRepository.saveAll(cTripTrainRecordList);
}
@Override
public void saveAllCTripCarRecord(List<CTripCarRecord> cTripCarRecordList) {
jdbcCTripCarRecordRepository.saveAll(cTripCarRecordList);
}
//
// @Override
// public Client findByClientId(String clientId){

View File

@ -0,0 +1,11 @@
package com.chint.infrastructure.repository.jdbc;
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.aggregates.order.order_record.ctrip_order_record.CTripFlightRecordBase;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcCTripCarRecordRepository extends CrudRepository<CTripCarRecord,Long> {
}

View File

@ -0,0 +1,10 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecordBase;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcCTripHotelRecordRepository extends CrudRepository<CTripHotelRecord,Long> {
}

View File

@ -0,0 +1,10 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripTrainRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcCTripTrainRecordRepository extends CrudRepository<CTripTrainRecord,Long> {
}

View File

@ -44,7 +44,7 @@ public class CTripOrderRecordAutoSave {
), CTripFlightInfo.of(it.getOrderFlightInfo())
))
.toList();
cTripOrderDetailRepository.saveAll(cTripFlightRecords);
cTripOrderDetailRepository.saveAllCTripFlightRecord(cTripFlightRecords);
}
}
@ -53,12 +53,14 @@ public class CTripOrderRecordAutoSave {
OrderHotelResponse hotelOrder = cTripOrderDetailRequest.getHotelOrder();
List<OrderHotelResponse.HotelAccountSettlementInfo> lstHtlSettlement = hotelOrder.getLstHtlSettlement();
if (lstHtlSettlement != null && !lstHtlSettlement.isEmpty()) {
List<CTripHotelRecordBase> list = lstHtlSettlement.stream()
List<CTripHotelRecord> list = lstHtlSettlement.stream()
.flatMap(it -> it.getLstHotelSettlementDetail().stream())
.map(OrderHotelResponse.LstHotelSettlementDetail::getSettlementDetail)
.map(CTripHotelRecordBase::changeInfo)
.map(it ->
CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(it.getSettlementDetail()),
CTripHotelInfo.of(it.getHotelDetail()))
)
.toList();
cTripOrderDetailRepository.saveAllHotelRecord(list);
cTripOrderDetailRepository.saveAllCTripHotelRecord(list);
}
}
@ -67,27 +69,28 @@ public class CTripOrderRecordAutoSave {
OrderTrainResponse trainOrder = cTripOrderDetailRequest.getTrainOrder();
List<OrderTrainResponse.CorpTrainAccountSettlement> lstTrainSettlement = trainOrder.getLstTrainSettlement();
if (lstTrainSettlement != null && !lstTrainSettlement.isEmpty()) {
List<CTripTrainRecordBase> list = lstTrainSettlement.stream()
List<CTripTrainRecord> list = lstTrainSettlement.stream()
.flatMap(it -> it.getLstTrainSettlementDetail().stream())
.map(OrderTrainResponse.CorpTrainSettlementInfo::getTrainSettlementDetail)
.map(CTripTrainRecordBase::changeInfo)
.map(it ->
CTripTrainRecord.of(CTripTrainRecordBase.changeInfo(it.getTrainSettlementDetail()),
CTripTrainInfo.of(it.getTrainSettlementTicket()))
)
.toList();
cTripOrderDetailRepository.saveAllTrainRecord(list);
cTripOrderDetailRepository.saveAllCTripTrainRecord(list);
}
}
public void cTripCarRecordAutoSave() {
OrderCarResponse carOrder = cTripOrderDetailRequest.getCarOrder();
List<OrderCarResponse.CarOrderAccountSettlementDetail> settlementList = carOrder.getCarOrderAccountSettlementList();
if (settlementList != null && !settlementList.isEmpty()) {
List<CTripCarRecordBase> list = settlementList.stream()
List<CTripCarRecord> list = settlementList.stream()
.flatMap(it -> it.getCarSettlementDetailList().stream())
.map(OrderCarResponse.CarOrderSettlementDetail::getSettlementBaseInfo)
.map(CTripCarRecordBase::changeInfo)
.map(it -> CTripCarRecord.of(
CTripCarRecordBase.changeInfo(it.getSettlementBaseInfo()),
CTripCarQuickInfo.of(it.getOrderDetail().getQuickProductInfo())))
.toList();
cTripOrderDetailRepository.saveAllCarRecord(list);
cTripOrderDetailRepository.saveAllCTripCarRecord(list);
}
}
}