From d27131fc362d49931560fa3e4e71dc800bf370d5 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 15 May 2024 10:01:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B6=88=E8=B4=B9=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E8=AE=A2=E5=8D=95=E5=8F=B7?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dtos/AuthenticationSignDto.java | 2 +- .../out/OrderDetailController.java | 9 +++++- .../queryies/OrderDetailQuery.java | 28 +++++++++++++++---- .../repository/OrderDetailRepository.java | 7 ++++- .../repository/OrderDetailRepositoryImpl.java | 26 +++++++++++------ .../jdbc/JdbcOrderDetailRepository.java | 2 ++ .../interfaces/rest/ly/tools/LYOrderUtil.java | 3 +- src/test/java/com/chint/LYTest.java | 2 +- 8 files changed, 60 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/chint/application/dtos/AuthenticationSignDto.java b/src/main/java/com/chint/application/dtos/AuthenticationSignDto.java index 509c9d35..d8ef032f 100644 --- a/src/main/java/com/chint/application/dtos/AuthenticationSignDto.java +++ b/src/main/java/com/chint/application/dtos/AuthenticationSignDto.java @@ -6,7 +6,7 @@ import lombok.Data; @Data public class AuthenticationSignDto extends BaseQuery { -// private String orderNo; //订单号 + private String orderNo; //订单号 private Integer productType; //机票1 、酒店2、火车3、打车4 private String systemType; private String startTime; diff --git a/src/main/java/com/chint/application/out/OrderDetailController.java b/src/main/java/com/chint/application/out/OrderDetailController.java index 4a12b35d..9e7de692 100644 --- a/src/main/java/com/chint/application/out/OrderDetailController.java +++ b/src/main/java/com/chint/application/out/OrderDetailController.java @@ -142,6 +142,7 @@ public class OrderDetailController { } private boolean signCheck(AuthenticationSignDto authenticationDto) { + String orderNo = authenticationDto.getOrderNo(); Integer productType = authenticationDto.getProductType(); String systemType = authenticationDto.getSystemType(); String startTime = authenticationDto.getStartTime(); @@ -149,7 +150,13 @@ public class OrderDetailController { Integer pageSize = authenticationDto.getPageSize(); Integer pageNum = authenticationDto.getPageNum(); String orgsign = authenticationDto.getSign(); - String sign = Digest.md5(productType + systemType + startTime + endTime + pageSize + pageNum); + String input; + if (orderNo != null) { + input = orderNo + productType + systemType + startTime + endTime + pageSize + pageNum; + } else { + input = productType + systemType + startTime + endTime + pageSize + pageNum; + } + String sign = Digest.md5(input); return orgsign.equals(sign); } diff --git a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java index 6c41ec34..f036ebf9 100644 --- a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java @@ -41,6 +41,7 @@ import static com.chint.application.queryies.util.QueryUtil.reGetReceiptsNum; import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; import static com.chint.infrastructure.constant.FSSCConstant.FSSC_ORDER_STATUS_CANCEL; +import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y; @Component @@ -132,7 +133,6 @@ public class OrderDetailQuery { .ifPresentOrElse(record::setAccountCompanyName, () -> record.setAccountCompanyName(record.getAccountCompanyName())); record.setReceiptsNum(QueryUtil.reGetReceiptsNum(record.getReceiptsNum())); }); -// systemDomainService.generateRecordClerk(orderFlightRecordList); return orderFlightRecordList; } @@ -144,7 +144,6 @@ public class OrderDetailQuery { .ifPresentOrElse(record::setAccountCompanyName, () -> record.setAccountCompanyName(record.getAccountCompanyName())); record.setReceiptsNum(QueryUtil.reGetReceiptsNum(record.getReceiptsNum())); }); -// systemDomainService.generateRecordClerk(orderHotelRecordList); return orderHotelRecordList; } @@ -155,7 +154,6 @@ public class OrderDetailQuery { .ifPresentOrElse(record::setAccountCompanyName, () -> record.setAccountCompanyName(record.getAccountCompanyName())); record.setReceiptsNum(QueryUtil.reGetReceiptsNum(record.getReceiptsNum())); }); -// systemDomainService.generateRecordClerk(orderTrainRecordList); return orderTrainRecordList; } @@ -166,7 +164,6 @@ public class OrderDetailQuery { .ifPresentOrElse(record::setAccountCompanyName, () -> record.setAccountCompanyName(record.getAccountCompanyName())); record.setReceiptsNum(QueryUtil.reGetReceiptsNum(record.getReceiptsNum())); }); -// systemDomainService.generateRecordClerk(orderCarRecordList); return orderCarRecordList; } @@ -192,15 +189,25 @@ public class OrderDetailQuery { } private List queryOrderDetail(AuthenticationSignDto authenticationDto) { + Integer legType = translateProductTypeToLegType( + authenticationDto.getProductType() + ); 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 orderDetailRepository.findByUpdateTimeBetween(targetTimeBegin, targetTimeEnd); + List res; + if (authenticationDto.getOrderNo() != null && !authenticationDto.getOrderNo().isEmpty()) { + res = orderDetailRepository.findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(targetTimeBegin, + targetTimeEnd, legType, authenticationDto.getOrderNo()); + } else { + res = orderDetailRepository.findByCreateTimeBetweenAndProductType(targetTimeBegin, + targetTimeEnd, legType); + } + return res; } public File exportOrderDetailToFile(AuthenticationSignDto authenticationDto) { List orderDetailList = queryOrderDetail(authenticationDto).stream().filter(Objects::nonNull).toList(); - Integer productType = authenticationDto.getProductType(); return OrderDetailWriter.exportReport( switch (productType) { @@ -363,4 +370,13 @@ public class OrderDetailQuery { return new PageResult<>(total, OrderDetailResList); } + private Integer translateProductTypeToLegType(Integer productType) { + return switch (productType) { + case 1 -> LEG_TYPE_AIRPLANE; + case 2 -> LEG_TYPE_HOTEL; + case 3 -> LEG_TYPE_TRAIN; + case 4 -> LEG_TYPE_TAXI; + default -> 4; + }; + } } diff --git a/src/main/java/com/chint/domain/repository/OrderDetailRepository.java b/src/main/java/com/chint/domain/repository/OrderDetailRepository.java index ba94803c..96e2d88c 100644 --- a/src/main/java/com/chint/domain/repository/OrderDetailRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderDetailRepository.java @@ -2,7 +2,6 @@ package com.chint.domain.repository; import com.chint.application.dtos.OrderDetailQueryParam; import com.chint.domain.aggregates.order.OrderDetail; -import com.chint.domain.aggregates.order.RouteOrder; import org.springframework.data.domain.Page; import java.time.LocalDateTime; @@ -12,6 +11,7 @@ import java.util.Optional; public interface OrderDetailRepository { Page pageQuery(OrderDetailQueryParam orderDetailQueryParam); + OrderDetail findById(Long orderDetailId); List findByLegId(Long legId); @@ -23,4 +23,9 @@ public interface OrderDetailRepository { void deleteById(Long id); List findByUpdateTimeBetween(LocalDateTime createTimeStart, LocalDateTime createTimeEnd); + + List findByCreateTimeBetweenAndProductType(LocalDateTime createTimeStart, LocalDateTime createTimeEnd, Integer productType); + + List findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTimeStart, LocalDateTime createTimeEnd, Integer productType, String orderNo); + } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderDetailRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderDetailRepositoryImpl.java index 881486dd..ec13b79c 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderDetailRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderDetailRepositoryImpl.java @@ -22,7 +22,7 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; @Repository public class OrderDetailRepositoryImpl implements OrderDetailRepository { @Autowired - private JdbcOrderDetailRepository orderDetailRepository; + private JdbcOrderDetailRepository jdbcOrderDetailRepository; @Autowired private RouteCacheService routeCacheService; @@ -32,22 +32,22 @@ public class OrderDetailRepositoryImpl implements OrderDetailRepository { PageRequest pageRequest = PageRequest .of(orderDetailQueryParam.getPageNum() - 1, orderDetailQueryParam.getPageSize(), Sort.by("updateTime")); String employeeNo = BaseContext.getCurrentUser().getEmployeeNo(); - return orderDetailRepository.findByEmployeeNo(employeeNo, pageRequest); + return jdbcOrderDetailRepository.findByEmployeeNo(employeeNo, pageRequest); } @Override public OrderDetail findById(Long orderDetailId) { - return orderDetailRepository.findById(orderDetailId).orElseThrow(() -> new NotFoundException(NOT_FOUND)); + return jdbcOrderDetailRepository.findById(orderDetailId).orElseThrow(() -> new NotFoundException(NOT_FOUND)); } @Override public List findByLegId(Long legId) { - return orderDetailRepository.findByLegId(legId); + return jdbcOrderDetailRepository.findByLegId(legId); } @Override public Optional findByOrderNo(String orderNo) { - return Optional.ofNullable(orderDetailRepository.findByOrderNo(orderNo)); + return Optional.ofNullable(jdbcOrderDetailRepository.findByOrderNo(orderNo)); } @Override @@ -55,7 +55,7 @@ public class OrderDetailRepositoryImpl implements OrderDetailRepository { if (orderDetail.getRouteId() != null) { routeCacheService.invalidateRouteCache(orderDetail.getRouteId()); } - OrderDetail detail = orderDetailRepository.save(orderDetail); + OrderDetail detail = jdbcOrderDetailRepository.save(orderDetail); if (detail.getRouteId() != null) { routeCacheService.invalidateRouteCache(orderDetail.getRouteId()); } @@ -64,12 +64,22 @@ public class OrderDetailRepositoryImpl implements OrderDetailRepository { @Override public void deleteById(Long id) { - orderDetailRepository.deleteById(id); + jdbcOrderDetailRepository.deleteById(id); } @Override public List findByUpdateTimeBetween(LocalDateTime createTimeStart, LocalDateTime createTimeEnd) { - return orderDetailRepository.findByCreateTimeBetween(createTimeStart, createTimeEnd); + return jdbcOrderDetailRepository.findByCreateTimeBetween(createTimeStart, createTimeEnd); + } + + @Override + public List findByCreateTimeBetweenAndProductType(LocalDateTime createTimeStart, LocalDateTime createTimeEnd, Integer productType) { + return jdbcOrderDetailRepository.findByCreateTimeBetweenAndProductType(createTimeStart, createTimeEnd, productType); + } + + @Override + public List findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTimeStart, LocalDateTime createTimeEnd, Integer productType, String orderNo) { + return jdbcOrderDetailRepository.findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(createTimeStart, createTimeEnd, productType, orderNo); } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java index 659f7698..7788e531 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderDetailRepository.java @@ -22,5 +22,7 @@ public interface JdbcOrderDetailRepository extends CrudRepository findByEmployeeNo(String employeeNo, Pageable pageable); List findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); + List findByCreateTimeBetweenAndProductType(LocalDateTime createTime, LocalDateTime createTime2, Integer productType); + List findByCreateTimeBetweenAndProductTypeAndOrderNoContaining(LocalDateTime createTime, LocalDateTime createTime2, Integer productType, String orderNo); List findByUpdateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); } diff --git a/src/main/java/com/chint/interfaces/rest/ly/tools/LYOrderUtil.java b/src/main/java/com/chint/interfaces/rest/ly/tools/LYOrderUtil.java index 5b4f3809..60384968 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/tools/LYOrderUtil.java +++ b/src/main/java/com/chint/interfaces/rest/ly/tools/LYOrderUtil.java @@ -16,7 +16,7 @@ public class LYOrderUtil { case "E" -> ORDER_EVENT_ORDERED; //已申请出票 case "K" -> ORDER_EVENT_PREPARE; //抢票中 case "M" -> ORDER_EVENT_ORDERED; //已付款 - case "U" -> ORDER_EVENT_REFUND; //申请出差失败 + case "U" -> ORDER_EVENT_REFUND; //申请出票失败 case "J" -> ORDER_EVENT_CANCEL; //申请抢票失败 case "C" -> ORDER_EVENT_CANCEL; //订单已取消 case "F" -> ORDER_EVENT_ORDERED; //出票成功 @@ -34,6 +34,7 @@ public class LYOrderUtil { !"S".equals(status) && !"G".equals(status) && !"H".equals(status) && + !"U".equals(status) && !"B".equals(status) && !"A".equals(status) && !"O".equals(status) && diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index fc4b446d..6b9ea192 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -824,7 +824,7 @@ public class LYTest { @Test void searchTrain() { - TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24050872686468359"); + TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24050872678451149"); Gson gson = new Gson(); String json = gson.toJson(trainOrderDetail); System.out.println(json);