【update】修正消费明细数据来源为detail表

This commit is contained in:
nixj 2024-05-09 08:52:57 +08:00
parent 0bc1c47791
commit 881938047a
10 changed files with 143 additions and 29 deletions

View File

@ -48,6 +48,4 @@ public interface JdbcOrderCarRecordRepository extends CrudRepository<OrderCarRec
order by r1.create_time desc
""")
Integer countRecordByCustomFiled(String fieldName, Object fieldValue, String accountPeriod);
Page<OrderCarRecord> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
}

View File

@ -47,6 +47,4 @@ public interface JdbcOrderFlightRecordRepository extends CrudRepository<OrderFli
order by r1.create_time desc
""")
Integer countRecordByCustomFiled(String fieldName, Object fieldValue, String accountPeriod);
Page<OrderFlightRecord> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
}

View File

@ -49,5 +49,4 @@ public interface JdbcOrderHotelRecordRepository extends CrudRepository<OrderHote
""")
Integer countRecordByCustomFiled(String fieldName, Object fieldValue, String accountPeriod);
Page<OrderHotelRecord> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
}

View File

@ -46,7 +46,4 @@ public interface JdbcOrderTrainRecordRepository extends CrudRepository<OrderTrai
order by r1.create_time desc
""")
Integer countRecordByCustomFiled(String fieldName, Object fieldValue, String accountPeriod);
Page<OrderTrainRecord> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
}

View File

@ -1,6 +1,7 @@
package com.chint.manage.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Builder;
import lombok.Data;
/**
@ -9,6 +10,7 @@ import lombok.Data;
* @Date2024/5/7 14:17
*/
@Data
@Builder
public class ConsumptionDetailExcel extends BaseExcel{
@ExcelProperty("出行人姓名")
private String userName;
@ -25,6 +27,6 @@ public class ConsumptionDetailExcel extends BaseExcel{
@ExcelProperty("到达站")
private String toStationName;
@ExcelProperty("订单总额(含前收服务费)")
private String payAmount;
private String orderAmount;
}

View File

@ -0,0 +1,13 @@
package com.chint.manage.mapper;
import com.chint.domain.aggregates.order.CarOrderDetail;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcCarOrderDetailRepository extends CrudRepository<CarOrderDetail, Long> {
Page<CarOrderDetail> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
}

View File

@ -0,0 +1,13 @@
package com.chint.manage.mapper;
import com.chint.domain.aggregates.order.FlightOrderDetail;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcFlightOrderDetailRepository extends CrudRepository<FlightOrderDetail, Long> {
Page<FlightOrderDetail> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
}

View File

@ -0,0 +1,14 @@
package com.chint.manage.mapper;
import com.chint.domain.aggregates.order.HotelOrderDetail;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcHotelOrderDetailRepository extends CrudRepository<HotelOrderDetail, Long> {
Page<HotelOrderDetail> findAllByBookingNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
}

View File

@ -0,0 +1,13 @@
package com.chint.manage.mapper;
import com.chint.domain.aggregates.order.TrainOrderDetail;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcTrainOrderDetailRepository extends CrudRepository<TrainOrderDetail, Long> {
Page<TrainOrderDetail> findAllByUserNameContainsAndOrderNoContaining(String userName, String orderNo, Pageable pageable);
}

View File

@ -1,13 +1,13 @@
package com.chint.manage.mapper.impl;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.order.order_record.*;
import com.chint.infrastructure.constant.LegConstant;
import com.chint.infrastructure.repository.jdbc.*;
import com.chint.infrastructure.util.PageResult;
import com.chint.manage.entity.ConsumptionDetailExcel;
import com.chint.manage.entity.dto.ConsumptionDetailDto;
import com.chint.manage.mapper.JdbcConsumptionDetailRepository;
import com.chint.manage.mapper.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,13 +32,13 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
private NamedParameterJdbcTemplate jdbcTemplate;
@Autowired
private JdbcOrderTrainRecordRepository jdbcOrderTrainRecordRepository;
private JdbcTrainOrderDetailRepository jdbcTrainOrderDetailRepository;
@Autowired
private JdbcOrderCarRecordRepository jdbcOrderCarRecordRepository;
private JdbcCarOrderDetailRepository jdbcCarOrderDetailRepository;
@Autowired
private JdbcOrderHotelRecordRepository jdbcOrderHotelRecordRepository;
private JdbcHotelOrderDetailRepository jdbcHotelOrderDetailRepository;
@Autowired
private JdbcOrderFlightRecordRepository jdbcOrderFlightRecordRepository;
private JdbcFlightOrderDetailRepository jdbcFlightOrderDetailRepository;
@Override
@ -74,27 +74,33 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
}
PageRequest pageRequest = PageRequest
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id"));
Page<? extends OrderBaseRecord> data=new PageImpl<>(Collections.emptyList());
Page<ConsumptionDetailExcel> data=new PageImpl<>(Collections.emptyList());
//todo 各类型数据处理 record换成detail表
switch (dto.getProductType()) {
case LEG_TYPE_TRAIN -> data=jdbcOrderTrainRecordRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getSupplierName(),dto.getOrderNo(),pageRequest);
case LEG_TYPE_AIRPLANE -> data=jdbcOrderFlightRecordRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getSupplierName(),dto.getOrderNo(),pageRequest);
case LEG_TYPE_HOTEL -> data=jdbcOrderHotelRecordRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getSupplierName(),dto.getOrderNo(),pageRequest);
case LEG_TYPE_TAXI -> data=jdbcOrderCarRecordRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getSupplierName(),dto.getOrderNo(),pageRequest);
case LEG_TYPE_TRAIN -> data=getOrderTrainRecord(jdbcTrainOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getSupplierName(),dto.getOrderNo(),pageRequest));
case LEG_TYPE_AIRPLANE -> data=getOrderFlightRecord(jdbcFlightOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getSupplierName(),dto.getOrderNo(),pageRequest));
case LEG_TYPE_HOTEL -> data=getOrderHotelRecord(jdbcHotelOrderDetailRepository.findAllByBookingNameContainsAndOrderNoContaining(dto.getSupplierName(),dto.getOrderNo(),pageRequest));
case LEG_TYPE_TAXI -> data=getOrderCarRecord(jdbcCarOrderDetailRepository.findAllByUserNameContainsAndOrderNoContaining(dto.getSupplierName(),dto.getOrderNo(),pageRequest));
}
//todo 数据处理
Page<ConsumptionDetailExcel> result=mapOrderTrainRecordToConsumptionDetailExcel(data);
return PageResult.totalPageNum(result.getTotalElements(), result.getContent());
return PageResult.totalPageNum(data.getTotalElements(), data.getContent());
}
public Page<ConsumptionDetailExcel> mapOrderTrainRecordToConsumptionDetailExcel(Page<? extends OrderBaseRecord> page) {
List<? extends OrderBaseRecord> orderRecords = page.getContent();
public Page<ConsumptionDetailExcel> getOrderTrainRecord(Page<TrainOrderDetail> page) {
List<TrainOrderDetail> orderRecords = page.getContent();
List<ConsumptionDetailExcel> consumptionDetailExcels = new ArrayList<>();
// 遍历 OrderBaseRecord将其转换为 ConsumptionDetailExcel
for (OrderBaseRecord orderRecord : orderRecords) {
ConsumptionDetailExcel consumptionDetailExcel = new ConsumptionDetailExcel();
// 使用 BeanUtils.copyProperties 进行属性拷贝
BeanUtils.copyProperties(orderRecord, consumptionDetailExcel);
for (TrainOrderDetail orderRecord : orderRecords) {
ConsumptionDetailExcel consumptionDetailExcel = ConsumptionDetailExcel.builder()
.userName(orderRecord.getUserName())
.startDate(orderRecord.getStartTime())
.arriveDate(orderRecord.getArriveTime())
.fromCity(orderRecord.getFromCity())
.toCity(orderRecord.getToCity())
.fromStationName(orderRecord.getFromStationName())
.toStationName(orderRecord.getToStationName())
.orderAmount(orderRecord.getOrderAmount())
.build();
// 添加到结果列表中
consumptionDetailExcels.add(consumptionDetailExcel);
}
@ -102,4 +108,65 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
// 构建一个新的 Page<ConsumptionDetailExcel> 对象并返回
return new PageImpl<>(consumptionDetailExcels, page.getPageable(), page.getTotalElements());
}
public Page<ConsumptionDetailExcel> getOrderFlightRecord(Page<FlightOrderDetail> page) {
List<FlightOrderDetail> orderRecords = page.getContent();
List<ConsumptionDetailExcel> consumptionDetailExcels = new ArrayList<>();
for (FlightOrderDetail orderRecord : orderRecords) {
ConsumptionDetailExcel consumptionDetailExcel = ConsumptionDetailExcel.builder()
.userName(orderRecord.getUserName())
.startDate(orderRecord.getStartTime())
.arriveDate(orderRecord.getArriveTime())
.fromCity(orderRecord.getStartCityName())
.toCity(orderRecord.getEndCityName())
.fromStationName(orderRecord.getStartAirportName())
.toStationName(orderRecord.getEndAirportName())
.orderAmount(orderRecord.getOrderAmount())
.build();
consumptionDetailExcels.add(consumptionDetailExcel);
}
// 构建一个新的 Page<ConsumptionDetailExcel> 对象并返回
return new PageImpl<>(consumptionDetailExcels, page.getPageable(), page.getTotalElements());
}
public Page<ConsumptionDetailExcel> getOrderHotelRecord(Page<HotelOrderDetail> page) {
List<HotelOrderDetail> orderRecords = page.getContent();
List<ConsumptionDetailExcel> consumptionDetailExcels = new ArrayList<>();
for (HotelOrderDetail orderRecord : orderRecords) {
ConsumptionDetailExcel consumptionDetailExcel = ConsumptionDetailExcel.builder()
.userName(orderRecord.getBookingName())
.startDate(orderRecord.getCheckInDate())
.orderAmount(orderRecord.getOrderAmount())
.build();
consumptionDetailExcels.add(consumptionDetailExcel);
}
// 构建一个新的 Page<ConsumptionDetailExcel> 对象并返回
return new PageImpl<>(consumptionDetailExcels, page.getPageable(), page.getTotalElements());
}
public Page<ConsumptionDetailExcel> getOrderCarRecord(Page<CarOrderDetail> page) {
List<CarOrderDetail> orderRecords = page.getContent();
List<ConsumptionDetailExcel> consumptionDetailExcels = new ArrayList<>();
// 遍历 OrderBaseRecord将其转换为 ConsumptionDetailExcel
for (CarOrderDetail orderRecord : orderRecords) {
ConsumptionDetailExcel consumptionDetailExcel = ConsumptionDetailExcel.builder()
.userName(orderRecord.getUserName())
.startDate(orderRecord.getStartTime())
.arriveDate(orderRecord.getArriveTime())
.fromCity(orderRecord.getFromCity())
.toCity(orderRecord.getToCity())
.fromStationName(orderRecord.getFromStationName())
.toStationName(orderRecord.getToStationName())
.orderAmount(orderRecord.getOrderAmount())
.build();
consumptionDetailExcels.add(consumptionDetailExcel);
}
// 构建一个新的 Page<ConsumptionDetailExcel> 对象并返回
return new PageImpl<>(consumptionDetailExcels, page.getPageable(), page.getTotalElements());
}
}