修改结算数据查询接口只返回上个月数据

This commit is contained in:
lulz1 2024-04-03 14:20:16 +08:00
parent 346ea697da
commit 00b61fd55b
18 changed files with 132 additions and 21 deletions

View File

@ -57,15 +57,12 @@ public class OrderDetailQuery {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter);
LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter);
//只获取账期号为上个月的结算数据
return switch (productType) {
case 1 -> orderFlightRecordRepository.findByUpdateDataTime(targetTimeBegin,
targetTimeEnd, pageSize, pageNum, systemType);
case 2 -> orderHotelRecordRepository.findByUpdateDataTime(targetTimeBegin,
targetTimeEnd, pageSize, pageNum, systemType);
case 3 -> orderTrainRecordRepository.findByUpdateDataTime(targetTimeBegin,
targetTimeEnd, pageSize, pageNum, systemType);
case 4 -> orderCarRecordRepository.findByUpdateDataTime(targetTimeBegin,
targetTimeEnd, pageSize, pageNum, systemType);
case 1 -> orderFlightRecordRepository.findBySystemTypeAndLastMonth(pageSize, pageNum, systemType);
case 2 -> orderHotelRecordRepository.findBySystemTypeAndLastMonth(pageSize, pageNum, systemType);
case 3 -> orderTrainRecordRepository.findBySystemTypeAndLastMonth(pageSize, pageNum, systemType);
case 4 -> orderCarRecordRepository.findBySystemTypeAndLastMonth(pageSize, pageNum, systemType);
default -> throw new NotFoundException("错误产品类型");
};
}

View File

@ -118,19 +118,20 @@ public class OrderFlightRecord extends OrderBaseRecord {
}
// 加载机票信息
public OrderFlightRecord loadTicketInfo(String issueTicketTime,
public OrderFlightRecord loadTicketInfo(
String ticketNo,
String facePrice,
String useStatus) {
this.setIssueTicketTime(issueTicketTime);
this.setTicketNo(ticketNo);
this.setFacePrice(facePrice);
this.setUseStatus(useStatus);
return this;
}
public OrderFlightRecord loadScheduleNum(String scheduleNum){
public OrderFlightRecord loadScheduleNum(String issueTicketTime,String scheduleNum){
this.setScheduleNum(scheduleNum);
this.setIssueTicketTime(issueTicketTime);
return this;
}

View File

@ -11,6 +11,7 @@ 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 com.chint.infrastructure.util.DateTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -46,6 +47,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripCarPassengerInfo.getCostCenter1());
orderRecordBasic.setAccountCompanyName(cTripCarPassengerInfo.getCostCenter2());
orderRecordBasic.setOfflineCcomyCode(cTripCarPassengerInfo.getCostCenter1());
orderRecordBasic.setProjectOrderNo(cTripCarPassengerInfo.getCostCenter5());
String sysCode = cTripCarPassengerInfo.getCostCenter3();
if (sysCode != null) {
@ -205,6 +207,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripFlightBaseInfo.getCostCenter());
orderRecordBasic.setAccountCompanyName(cTripFlightBaseInfo.getCostCenter2());
orderRecordBasic.setOfflineCcomyCode(cTripFlightBaseInfo.getCostCenter());
orderRecordBasic.setProjectOrderNo(cTripFlightBaseInfo.getCostCenter5());
String sysCode = cTripFlightBaseInfo.getCostCenter3();
if (sysCode != null) {
@ -279,17 +282,17 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
return b;
}
});
orderFlightRecord.loadScheduleNum(print.isPresent() ? print.get().getPrintNo() : "");
orderFlightRecord.loadScheduleNum(print.map(cTripFlightSegmentPrint -> DateTimeUtil.timeFromInstant(cTripFlightSegmentPrint.getPrintTime())).orElse(""),
print.isPresent() ? print.get().getPrintNo() : "");
}
// 加载机票信息
if (cTripFlightTripInfo != null) {
orderFlightRecord.loadTicketInfo(cTripFlightRecordBase.getCreateTime(),
orderFlightRecord.loadTicketInfo(cTripFlightTripInfo.getTicketNo(),
String.valueOf(cTripFlightRecordBase.getPrice()),
cTripFlightTripInfo.getTicketNo(),
cTripFlightTripInfo.getTicketNoStatusName());
} else {
orderFlightRecord.loadTicketInfo(cTripFlightRecordBase.getCreateTime(),
String.valueOf(cTripFlightRecordBase.getPrice()),
orderFlightRecord.loadTicketInfo(String.valueOf(cTripFlightRecordBase.getPrice()),
"",
"无机票信息");
}
@ -376,6 +379,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
orderRecordBasic.setAccountCompanyId(cTripHotelOrderDetail.getCostCenter());
orderRecordBasic.setAccountCompanyName(cTripHotelOrderDetail.getCostCenter2());
orderRecordBasic.setOfflineCcomyCode(cTripHotelOrderDetail.getCostCenter());
orderRecordBasic.setProjectOrderNo(cTripHotelOrderDetail.getCostCenter5());
String sysCode = cTripHotelOrderDetail.getCostCenter3();
if (sysCode != null) {

View File

@ -1,6 +1,7 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
import com.chint.infrastructure.util.PageResult;
import java.time.LocalDateTime;
@ -12,5 +13,9 @@ public interface OrderCarRecordRepository {
Optional<OrderCarRecord> findByDetailId(String detailId);
PageResult<OrderCarRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType);
PageResult<OrderCarRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime,
Integer pageSize, Integer pageNum ,String systemType);
PageResult<OrderCarRecord> findBySystemTypeAndLastMonth(Integer pageSize,
Integer pageNum,
String systemType);
}

View File

@ -17,4 +17,8 @@ public interface OrderFlightRecordRepository {
Integer pageSize,
Integer pageNum,
String systemType);
PageResult<OrderFlightRecord> findBySystemTypeAndLastMonth(Integer pageSize,
Integer pageNum,
String systemType);
}

View File

@ -1,6 +1,7 @@
package com.chint.domain.repository;
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.infrastructure.util.PageResult;
@ -13,5 +14,10 @@ public interface OrderHotelRecordRepository {
Optional<OrderHotelRecord> findByDetailId(String detailId);
PageResult<OrderHotelRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType);
PageResult<OrderHotelRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime,
Integer pageSize, Integer pageNum ,String systemType);
PageResult<OrderHotelRecord> findBySystemTypeAndLastMonth(Integer pageSize,
Integer pageNum,
String systemType);
}

View File

@ -14,5 +14,10 @@ public interface OrderTrainRecordRepository {
Optional<OrderTrainRecord> findByDetailId(String detailId);
PageResult<OrderTrainRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType);
PageResult<OrderTrainRecord> findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime,
Integer pageSize, Integer pageNum ,String systemType);
PageResult<OrderTrainRecord> findBySystemTypeAndLastMonth(Integer pageSize,
Integer pageNum,
String systemType);
}

View File

@ -0,0 +1,23 @@
package com.chint.domain.service;
import com.chint.domain.repository.OrderCarRecordRepository;
import com.chint.domain.repository.OrderFlightRecordRepository;
import com.chint.domain.repository.OrderHotelRecordRepository;
import com.chint.domain.repository.OrderTrainRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class OrderRecordDomainService {
@Autowired
private OrderCarRecordRepository orderCarRecordRepository;
@Autowired
private OrderHotelRecordRepository orderHotelRecordRepository;
@Autowired
private OrderFlightRecordRepository orderFlightRecordRepository;
@Autowired
private OrderTrainRecordRepository orderTrainRecordRepository;
}

View File

@ -3,6 +3,7 @@ package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import com.chint.domain.repository.OrderCarRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderCarRecordRepository;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -44,4 +45,13 @@ public class OrderCarRecordRepositoryImpl implements OrderCarRecordRepository {
startTime, endTime, startTime, endTime, pageRequest);
return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent());
}
@Override
public PageResult<OrderCarRecord> findBySystemTypeAndLastMonth(Integer pageSize, Integer pageNum, String systemType) {
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending());
String lastMonth = DateTimeUtil.lastMonthStr();
Page<OrderCarRecord> res = orderCarRecordRepository.
findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(systemType, lastMonth, lastMonth, pageRequest);
return PageResult.totalPageNum(res.getTotalElements(), res.getContent());
}
}

View File

@ -3,6 +3,7 @@ package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.repository.OrderFlightRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderFlightRecordRepository;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -42,4 +43,12 @@ public class OrderFlightRecordRepositoryImpl implements OrderFlightRecordReposit
return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent());
}
@Override
public PageResult<OrderFlightRecord> findBySystemTypeAndLastMonth(Integer pageSize, Integer pageNum, String systemType) {
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending());
String lastMonth = DateTimeUtil.lastMonthStr();
Page<OrderFlightRecord> res = jdbcOrderFlightRecordRepository.
findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(systemType, lastMonth, lastMonth, pageRequest);
return PageResult.totalPageNum(res.getTotalElements(), res.getContent());
}
}

View File

@ -1,8 +1,10 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import com.chint.domain.repository.OrderHotelRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -41,4 +43,13 @@ public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepositor
startTime, endTime, startTime, endTime, pageRequest);
return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent());
}
@Override
public PageResult<OrderHotelRecord> findBySystemTypeAndLastMonth(Integer pageSize, Integer pageNum, String systemType) {
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending());
String lastMonth = DateTimeUtil.lastMonthStr();
Page<OrderHotelRecord> res = jdbcOrderHotelRecordRepository.
findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(systemType, lastMonth, lastMonth, pageRequest);
return PageResult.totalPageNum(res.getTotalElements(), res.getContent());
}
}

View File

@ -3,6 +3,7 @@ package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
import com.chint.domain.repository.OrderTrainRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderTrainRecordRepository;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -40,4 +41,13 @@ public class OrderTrainRecordRepositoryImpl implements OrderTrainRecordRepositor
startTime, endTime, startTime, endTime, pageRequest);
return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent());
}
@Override
public PageResult<OrderTrainRecord> findBySystemTypeAndLastMonth(Integer pageSize, Integer pageNum, String systemType) {
PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending());
String lastMonth = DateTimeUtil.lastMonthStr();
Page<OrderTrainRecord> res = jdbcOrderTrainRecordRepository.
findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(systemType, lastMonth, lastMonth, pageRequest);
return PageResult.totalPageNum(res.getTotalElements(), res.getContent());
}
}

View File

@ -15,5 +15,8 @@ public interface JdbcOrderCarRecordRepository extends CrudRepository<OrderCarRec
Optional<OrderCarRecord> findByDetailId(String detailId);
Page<OrderCarRecord> findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable);
Page<OrderCarRecord> findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable);
Page<OrderCarRecord> findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, LocalDateTime updateDataTime3, LocalDateTime updateDataTime4, Pageable pageable);
}

View File

@ -14,5 +14,7 @@ public interface JdbcOrderFlightRecordRepository extends CrudRepository<OrderFli
Optional<OrderFlightRecord> findByDetailId(String detailId);
Page<OrderFlightRecord> findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable);
Page<OrderFlightRecord> findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable);
Page<OrderFlightRecord> findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, LocalDateTime updateDataTime3, LocalDateTime updateDataTime4, Pageable pageable);
}

View File

@ -1,6 +1,5 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@ -16,5 +15,8 @@ public interface JdbcOrderHotelRecordRepository extends CrudRepository<OrderHote
Optional<OrderHotelRecord> findByDetailId(String detailId);
Page<OrderHotelRecord> findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable);
Page<OrderHotelRecord> findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable);
Page<OrderHotelRecord> findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, LocalDateTime updateDataTime3, LocalDateTime updateDataTime4, Pageable pageable);
}

View File

@ -14,6 +14,7 @@ public interface JdbcOrderTrainRecordRepository extends CrudRepository<OrderTrai
Optional<OrderTrainRecord> findByDetailId(String detailId);
Page<OrderTrainRecord> findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable);
Page<OrderTrainRecord> findByBelongSysTypeAndAccountPeriodOrBelongSysTypeIsNullAndAccountPeriod(String belongSysType, String accountPeriod, String accountPeriod2, Pageable pageable);
Page<OrderTrainRecord> findByBelongSysTypeAndUpdateDataTimeBetweenOrBelongSysTypeIsNullAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, LocalDateTime updateDataTime3, LocalDateTime updateDataTime4, Pageable pageable);
}

View File

@ -1,7 +1,9 @@
package com.chint.infrastructure.util;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
public class DateTimeUtil {
@ -14,6 +16,11 @@ public class DateTimeUtil {
private final static DateTimeFormatter formatterDateYYYYMMDD = DateTimeFormatter.ofPattern("yyyyMMdd");
public static String timeFromInstant(Long instant) {
LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(instant), ZoneId.systemDefault());
return formatter.format(localDateTime);
}
public static String timeToStr(LocalDateTime input) {
return input.format(formatterDate);
}
@ -53,4 +60,13 @@ public class DateTimeUtil {
return yearMonth.atEndOfMonth().atTime(23, 59, 59);
}
public static String lastMonthStr() {
// 获取当前日期和时间
LocalDateTime currentDateTime = LocalDateTime.now();
// 获取上个月的同一时间
LocalDateTime lastMonthDateTime = currentDateTime.minusMonths(1);
// 指定所需格式
// 格式化日期时间
return lastMonthDateTime.format(formatterDateYYYYMM);
}
}

View File

@ -55,6 +55,7 @@ import java.util.*;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.LocationConstant.*;
import static com.chint.infrastructure.util.DateTimeUtil.lastMonthStr;
@Slf4j
@SpringBootTest
@ -1249,9 +1250,10 @@ class RouteApplicationTests {
orderDomainService.checkCompanyNameIfBlack("乐清正泰电器销售有限公司");
}
// @Test
@Test
void testSplid(){
String str = "20240301";
System.out.println(str.substring(0, 5));
System.out.println(lastMonthStr());
}
}