测试携程结算代码

This commit is contained in:
Superdandan 2024-04-01 11:11:39 +08:00
parent 16f4a64fd5
commit 89dfea7c3e
8 changed files with 103 additions and 17 deletions

View File

@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
import static com.chint.infrastructure.constant.BelongSystemConstant.*;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y;
@Component
public class OrderRecordFactory {
@ -16,6 +17,12 @@ public class OrderRecordFactory {
@Autowired
private UserRepository userRepository;
@Autowired
private CTripOrderRecordExtensionFactory cTripOrderRecordExtensionFactory;
@Autowired
private LyOrderRecordExtensionFactory lyOrderRecordExtensionFactory;
public OrderRecordBasic buildWithRouteOrder(RouteOrder routeOrder) {
routeOrder.reloadStatus();
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
@ -63,4 +70,12 @@ public class OrderRecordFactory {
}
return orderRecordBasic;
}
public OrderRecordExtensionFactory extensionFactoryOfSupplierName(String supplierName) {
return switch (supplierName) {
case SUPPLIER_C_TRIP -> cTripOrderRecordExtensionFactory;
case SUPPLIER_L_Y -> lyOrderRecordExtensionFactory;
default -> null;
};
}
}

View File

@ -2,6 +2,7 @@ package com.chint.domain.repository;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -37,14 +38,32 @@ public interface CTripOrderDetailRepository {
void saveAllCarRecord(List<CTripCarRecordBase> ctripCarOrderDetailList);
CTripCarRecordBase findCarByRecordId(Long id);
void saveAllCTripFlightRecord(List<CTripFlightRecord> cTripFlightRecordList);
CTripFlightRecord findFlightRecordById(Long id);
CTripFlightRecord findFlightRecordById(Long id);
CTripFlightRecord findFlightRecordByRecordId(String recordId);
void saveAllCTripHotelRecord(List<CTripHotelRecord> cTripHotelRecordList);
CTripHotelRecord findHotelRecordById(Long id);
CTripHotelRecord findHotelRecordById(Long id);
CTripHotelRecord findHotelRecordByRecordId(String recordId);
void saveAllCTripTrainRecord(List<CTripTrainRecord> cTripTrainRecordList);
CTripTrainRecord findTrainRecordByRecordId(String recordId);
void saveAllCTripCarRecord(List<CTripCarRecord> cTripCarRecordList);
CTripCarRecord findCarRecordByRecordId(String recordId);
List<CTripHotelRecord> findHotelRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime);
List<CTripFlightRecord> findFlightRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime);
List<CTripCarRecord> findCarRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime);
List<CTripTrainRecord> findTrainRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime);
}

View File

@ -5,29 +5,41 @@ 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.CTripFlightRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
import com.chint.domain.factoriy.order_record.CTripOrderRecordExtensionFactory;
import com.chint.domain.factoriy.order_record.OrderRecordExtensionFactory;
import com.chint.domain.factoriy.order_record.OrderRecordFactory;
import com.chint.domain.repository.CTripOrderDetailRepository;
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.time.LocalDateTime;
import java.util.List;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@Component
public class CTripOrderRecordDomainService implements OrderRecordDomainService{
public class CTripOrderRecordDomainService implements OrderRecordDomainService {
@Autowired
private CTripOrderRecordExtensionFactory cTripOrderRecordExtensionFactory;
@Autowired
private OrderDetailDomainService orderDetailDomainService;
@Autowired
private CTripOrderDetailRepository cTripOrderDetailRepository;
@Autowired
private OrderRecordFactory orderRecordFactory;
@Override
public List<OrderHotelRecord> generateHotelRecord(OrderRecordGenerateCommand command) {
return null;
List<CTripHotelRecord> records = cTripOrderDetailRepository.findHotelRecordByCreateTime(command.getStartTime(), command.getEndTime());
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
List<OrderHotelRecord> list = records.stream().map(orderRecordExtensionFactory::createHotelOrderRecord).toList();
return orderDetailDomainService.saveHotelOrderRecordBatch(list);
}
@Override
@ -38,13 +50,17 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService{
@Override
public List<OrderFlightRecord> generateFlightRecord(OrderRecordGenerateCommand command) {
return null;
List<CTripFlightRecord> records = cTripOrderDetailRepository.findFlightRecordByCreateTime(command.getStartTime(), command.getEndTime());
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
List<OrderFlightRecord> list = records.stream().map(orderRecordExtensionFactory::createFlightOrderRecord).toList();
return orderDetailDomainService.saveFlightOrderRecordBatch(list);
}
@Override
public List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command) {
return null;
List<CTripCarRecord> records = cTripOrderDetailRepository.findCarRecordByCreateTime(command.getStartTime(), command.getEndTime());
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
List<OrderCarRecord> list = records.stream().map(orderRecordExtensionFactory::createCarOrderRecord).toList();
return orderDetailDomainService.saveCarOrderRecordBatch(list);
}
}

View File

@ -6,6 +6,7 @@ import com.chint.infrastructure.repository.jdbc.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -120,7 +121,7 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
}
@Override
public CTripFlightRecord findFlightRecordById(Long id) {
public CTripFlightRecord findFlightRecordById(Long id) {
return jdbcCTripFlightRecordRepository.findById(id).get();
}
@ -163,11 +164,25 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
public CTripCarRecord findCarRecordByRecordId(String recordId) {
return jdbcCTripCarRecordRepository.findByRecordId(recordId);
}
//
// @Override
// public Client findByClientId(String clientId){
// return jdbcClientRepository.findByClientId(clientId);
// }
@Override
public List<CTripHotelRecord> findHotelRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime) {
return jdbcCTripHotelRecordRepository.findByCreateTimeBetween(startTime, endTime);
}
@Override
public List<CTripFlightRecord> findFlightRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime) {
return jdbcCTripFlightRecordRepository.findByCreateTimeBetween(startTime, endTime);
}
@Override
public List<CTripCarRecord> findCarRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime) {
return jdbcCTripCarRecordRepository.findByCreateTimeBetween(startTime, endTime);
}
@Override
public List<CTripTrainRecord> findTrainRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime) {
return jdbcCTripTrainRecordRepository.findByCreateTimeBetween(startTime, endTime);
}
}

View File

@ -3,10 +3,16 @@ 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 com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List;
@Repository
public interface JdbcCTripCarRecordRepository extends CrudRepository<CTripCarRecord,Long> {
CTripCarRecord findByRecordId(String recordId);
List<CTripCarRecord> findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2);
}

View File

@ -1,11 +1,16 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripFlightRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List;
@Repository
public interface JdbcCTripFlightRecordRepository extends CrudRepository<CTripFlightRecord,Long> {
CTripFlightRecord findByRecordId(String recordId);
List<CTripFlightRecord> findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2);
}

View File

@ -5,7 +5,12 @@ import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHo
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List;
@Repository
public interface JdbcCTripHotelRecordRepository extends CrudRepository<CTripHotelRecord,Long> {
CTripHotelRecord findByRecordId(String recordId);
List<CTripHotelRecord> findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2);
}

View File

@ -5,7 +5,12 @@ import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripTr
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List;
@Repository
public interface JdbcCTripTrainRecordRepository extends CrudRepository<CTripTrainRecord,Long> {
CTripTrainRecord findByRecordId(String recordId);
List<CTripTrainRecord> findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2);
}