【update】修正消费明细数据来源为detail表
This commit is contained in:
parent
0bc1c47791
commit
881938047a
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
|||
* @Date:2024/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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue