Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
lulz1 2024-03-13 16:57:40 +08:00
commit a367f19002
3 changed files with 100 additions and 159 deletions

View File

@ -33,23 +33,15 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
@RequestMapping("/OrderDetail")
public class OrderDetailController {
// @Autowired
// private LocationRepository locationRepository;
//
// @Autowired
// private LocationDomainService locationDomainService;
@Autowired
private AuthenticateService authenticateService;
@Autowired
private ClientRepository clientRepository;
@Autowired
private RouteRepository routeRepository;
@Autowired
private OrderDetailRepository orderDetailRepository;
@ -71,14 +63,11 @@ public class OrderDetailController {
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ApiOperation("订单明细查询接口")
@PostMapping("/query")
public Result<PageResult<Object>> query(@RequestBody AuthenticationSignDto authenticationDto) {
// String orderNO = authenticationDto.getOrderNo();
Integer productType = authenticationDto.getProductType();
String systemType = authenticationDto.getSystemType();
String startTime = authenticationDto.getStartTime();
@ -87,96 +76,9 @@ public class OrderDetailController {
Integer pageNum = authenticationDto.getPageNum();
String orgsign = authenticationDto.getSign();
String sign = Digest.md5(+productType + systemType + startTime + endTime + pageSize + pageNum);
// String sign = Digest.md5(orderNO + productType + systemType + startTime + endTime + pageSize + pageNum);
System.out.println(sign);
if (StringUtils.isNotBlank(orgsign) && orgsign.equals(sign)) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter);
LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter);
List<OrderDetail> orderDetailList = orderDetailRepository.findByCreateTimeBetween(targetTimeBegin,
targetTimeEnd);
List<Object> orderDetailResList = new ArrayList<>();
for (OrderDetail orderDetail : orderDetailList) {
if (orderDetail.getProductType().equals(productType)) {
if (productType == 1) {
FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail();
if (flightOrderDetail != null) {
String receiptsNum = flightOrderDetail.getReceiptsNum();
if (receiptsNum != null){
flightOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (flightOrderDetail.getBelongSysType() != null && flightOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(flightOrderDetail);
} else {
orderDetailResList.add(flightOrderDetail);
}
}
}
if (productType == 2) {
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
if (hotelOrderDetail != null) {
String receiptsNum = hotelOrderDetail.getReceiptsNum();
if (receiptsNum != null){
hotelOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (hotelOrderDetail.getBelongSysType() != null && hotelOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(hotelOrderDetail);
} else {
orderDetailResList.add(hotelOrderDetail);
}
}
}
if (productType == 3) {
TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail();
if (trainOrderDetail != null) {
String receiptsNum = trainOrderDetail.getReceiptsNum();
if (receiptsNum != null){
trainOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (trainOrderDetail.getBelongSysType() != null && trainOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(trainOrderDetail);
} else {
orderDetailResList.add(trainOrderDetail);
}
}
}
if (productType == 4) {
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
if (carOrderDetail != null) {
String receiptsNum = carOrderDetail.getReceiptsNum();
if (receiptsNum != null){
carOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (carOrderDetail.getBelongSysType() != null && carOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(carOrderDetail);
} else {
orderDetailResList.add(carOrderDetail);
}
}
}
}
}
List<Object> newres2 = orderDetailResList.stream().skip((long) (pageNum - 1) * pageSize)
.limit(pageSize).toList();
return Result.Success(SUCCESS, PageResult.totalPageNum(Long.parseLong(
String.valueOf(orderDetailResList.size())
), newres2));
return orderDetailPageQuery.orderDetailInfoPageQuery(authenticationDto);
} else {
return Result.error("签名错误");
}
@ -189,10 +91,5 @@ public class OrderDetailController {
return Result.Success(SUCCESS, orderDetailResPageResult);
}
private String regetReceiptsNum(String receiptsNum){
String[] parts = receiptsNum.split("-");
String result = parts[1];
return result;
}
}

View File

@ -1,24 +1,29 @@
package com.chint.application.queryies;
import com.chint.application.dtos.AuthenticationSignDto;
import com.chint.application.dtos.OrderDetailQueryParam;
import com.chint.application.dtos.mapper.OrderDetailMapper;
import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Stream;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
@Component
public class OrderDetailQuery {
@ -29,6 +34,88 @@ public class OrderDetailQuery {
private RouteRepository routeRepository;
public Result<PageResult<Object>> orderDetailInfoPageQuery(AuthenticationSignDto authenticationDto) {
Integer productType = authenticationDto.getProductType();
String systemType = authenticationDto.getSystemType();
Integer pageSize = authenticationDto.getPageSize();
Integer pageNum = authenticationDto.getPageNum();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter);
LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter);
List<OrderDetail> orderDetailList = orderDetailRepository.findByCreateTimeBetween(targetTimeBegin,
targetTimeEnd);
List<Object> orderDetailResList = new ArrayList<>();
for (OrderDetail orderDetail : orderDetailList) {
if (orderDetail.getProductType().equals(productType)) {
if (productType == 1) {
FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail();
if (flightOrderDetail != null) {
String receiptsNum = flightOrderDetail.getReceiptsNum();
if (receiptsNum != null){
flightOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (flightOrderDetail.getBelongSysType() != null && flightOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(flightOrderDetail);
} else {
orderDetailResList.add(flightOrderDetail);
}
}
}
if (productType == 2) {
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
if (hotelOrderDetail != null) {
String receiptsNum = hotelOrderDetail.getReceiptsNum();
if (receiptsNum != null){
hotelOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (hotelOrderDetail.getBelongSysType() != null && hotelOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(hotelOrderDetail);
} else {
orderDetailResList.add(hotelOrderDetail);
}
}
}
if (productType == 3) {
TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail();
if (trainOrderDetail != null) {
String receiptsNum = trainOrderDetail.getReceiptsNum();
if (receiptsNum != null){
trainOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (trainOrderDetail.getBelongSysType() != null && trainOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(trainOrderDetail);
} else {
orderDetailResList.add(trainOrderDetail);
}
}
}
if (productType == 4) {
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
if (carOrderDetail != null) {
String receiptsNum = carOrderDetail.getReceiptsNum();
if (receiptsNum != null){
carOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum));
}
if (carOrderDetail.getBelongSysType() != null && carOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(carOrderDetail);
} else {
orderDetailResList.add(carOrderDetail);
}
}
}
}
}
List<Object> newres2 = orderDetailResList.stream().skip((long) (pageNum - 1) * pageSize)
.limit(pageSize).toList();
return Result.Success(SUCCESS, PageResult.totalPageNum(Long.parseLong(
String.valueOf(orderDetailResList.size())
), newres2));
}
public PageResult<OrderDetailRes> orderDetailPageQuery(OrderDetailQueryParam orderDetailQueryParam) {
Integer pageNum = orderDetailQueryParam.getPageNum();
Integer pageSize = orderDetailQueryParam.getPageSize();
@ -64,4 +151,14 @@ public class OrderDetailQuery {
.toList();
return new PageResult<>(total, OrderDetailResList);
}
private String regetReceiptsNum(String receiptsNum){
if (receiptsNum.contains("-")){
String[] parts = receiptsNum.split("-");
String result = parts[1];
return result;
}else {
return receiptsNum;
}
}
}

View File

@ -52,11 +52,8 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
@Override
public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) {
// 获取对象的Class对象
TrainDetailResponse.TrainDetailData trainDetailData = (TrainDetailResponse.TrainDetailData) trainOrderDetailData;
TrainOrderDetail convertTrain = convertTrainOrderDetail(trainDetailData);
return convertTrain;
}
@ -64,10 +61,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
public FlightOrderDetail createFlightOrderDetail(Object flightOrderDetailData) {
// 获取对象的Class对象
FlightOrderResponse.Data data = (FlightOrderResponse.Data) flightOrderDetailData;
FlightOrderDetail convertFlight = convertFlightOrderDetail(data);
return convertFlight;
}
@ -75,11 +69,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
public HotelOrderDetail createHotelOrderDetail(Object hotelOrderDetailData) {
HotelDetailResponse.Data data = (HotelDetailResponse.Data) hotelOrderDetailData;
// 获取对象的Class对象
// HotelOrderDetail convertHotel = convertHotel(hotelOrder, hotelDetailResponse);
HotelOrderDetail convertHotel = convertHotelOrderDetail(data);
return convertHotel;
}
@ -89,42 +79,31 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
}
private FlightOrderDetail convertFlightOrderDetail(FlightOrderResponse.Data data) {
FlightOrderResponse.OrderDetails orderDetails = data.getOrderDetails();
OrderDetail orderDetail = orderDetailRepository.findByOrderNo(orderDetails.getOrderSerialNo())
.orElseThrow(() -> new NotFoundException(NOT_FOUND));
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
FlightOrderDetail flightOrderDetail = new FlightOrderDetail();
if (approveOrderNo != null){
flightOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompanyCode());
flightOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
flightOrderDetail.setCostCenter(approveOrderNo.getCostCenter());
flightOrderDetail.setProjectOrderNo(approveOrderNo.getProjectName());
}
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
FlightOrderResponse.FlightSegment flightSegment = null;
if (!data.getFlightSegmentList().isEmpty()) {
flightSegment = data.getFlightSegmentList().get(0);
}
FlightOrderResponse.TravelData travelData = data.getTravelData();
FlightOrderResponse.Passenger passenger = null;
if (!data.getPassengerList().isEmpty()) {
passenger = data.getPassengerList().get(0);
}
// flightOrderDetail.setSupplier(SUPPLIER_L_Y_EXTENSION_NAME);
flightOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
if (sysCode != null) {
if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
@ -142,31 +121,25 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
}
}
String EmployeeNo = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(EmployeeNo);
if (user != null){
flightOrderDetail.setBookingUserCode(user.getEmployeeNo());
flightOrderDetail.setBookingName(user.getName());
flightOrderDetail.setBookingUserPhone(user.getPhoneNumber());
}
if (orderDetails != null) {
flightOrderDetail.setOrderNo(orderDetails.getOrderSerialNo());
flightOrderDetail.setDetailId(orderDetails.getOrderSerialNo());
flightOrderDetail.setOverStandard(String.valueOf(orderDetails.getRuleViolate()));
flightOrderDetail.setParentOrderNo(orderDetails.getParentOrderSerialNo());
flightOrderDetail.setOriginalOrderNo(orderDetails.getOriginalOrderNo());
Optional<OrderDetail> first1 = routeOrder
.getOrderDetails()
.stream()
.filter(it -> it.getOrderNo().equals(flightOrderDetail.getOrderNo()))
.findFirst();
first1.ifPresent(it ->{
OrderEvent lastEvent = it.getLastEvent();
if(lastEvent != null){
@ -175,14 +148,12 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
);
// flightOrderDetail.setScheduleNum(orderDetails.getTravelOrderNo());
flightOrderDetail.setChangedScheduleNum(orderDetails.getOriginalOrderNo());
FlightOrderResponse.FlightOrderRefundInfo flightOrderRefundInfo = orderDetails.getFlightOrderRefundInfo();
if (flightOrderRefundInfo!=null){
flightOrderDetail.setRefundFee(String.valueOf(flightOrderRefundInfo.getRefundFee()));
flightOrderDetail.setRefundAmount(String.valueOf(flightOrderRefundInfo.getRefundPrice())); //无refundPrice
}
flightOrderDetail.setCreateTime(orderDetails.getBookDate());
flightOrderDetail.setOrderAmount(String.valueOf(orderDetails.getTotalPrice()));
flightOrderDetail.setPreServiceFee(String.valueOf(orderDetails.getServicePrice()));
@ -191,9 +162,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
flightOrderDetail.setOverStandardReason(orderDetails.getFoulReason());
flightOrderDetail.setNotBookedLowestPriceReason(orderDetails.getFoulReason());
flightOrderDetail.setPaymentType(orderDetails.getPayType().toString()); //贵司都是公司支付所以为0
}
if (flightSegment != null) {
flightOrderDetail.setEndAirportName(flightSegment.getArriveAirport());
flightOrderDetail.setEndAirportCode(flightSegment.getArriveAirportCode());
@ -213,11 +182,8 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
flightOrderDetail.setEndCityName(flightSegment.getArriveCity());
flightOrderDetail.setFlightModel(flightSegment.getFlightNo());
flightOrderDetail.setStandard(flightSegment.getSeatName() + flightSegment.getSeatDiscount());
}
flightOrderDetail.setReceiptsNum(routeOrder.getRouteOrderNo());
if (passenger != null) {
flightOrderDetail.setFuelTax(passenger.getFuelTax().toString());
flightOrderDetail.setAirportTax(passenger.getAirportTax().toString());
@ -230,9 +196,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
flightOrderDetail.setUserCode(passenger.getOutEmployeeId());
flightOrderDetail.setPhone(passenger.getContractPhone());
flightOrderDetail.setInsuranceFee(passenger.getInsurancePrice().toString());
}
// flightOrderDetail.setBookingUserPhone(data.get); //
// flightOrderDetail.setEndCityCode(flightSegment.getarrivecit()); //
// FlightOrderResponse.FlightOrderRefundInfo flightOrderRefundInfo =
@ -243,28 +207,21 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
// flightOrderDetail.setBOOK_ORG_STRUCT_1(BOOK_ORG_STRUCT_1);
// flightOrderDetail.setBOOK_ORG_STRUCT_2(BOOK_ORG_STRUCT_2);
// flightOrderDetail.setBOOK_ORG_STRUCT_3(BOOK_ORG_STRUCT_3);
return flightOrderDetail;
}
private HotelOrderDetail convertHotelOrderDetail(HotelDetailResponse.Data data) {
HotelDetailResponse.OrderInfo orderInfo = data.getOrderInfo();
HotelDetailResponse.HotelInfo hotelInfo = data.getHotelInfo();
List<HotelDetailResponse.Room> roomList = data.getRoomList();
HotelDetailResponse.Room room = null;
if (!data.getRoomList().isEmpty()) {
room = roomList.get(0);
}
OrderDetail orderDetail = orderDetailRepository.findByOrderNo(orderInfo.getOrderSerialNo())
.orElseThrow(() -> new NotFoundException(NOT_FOUND));
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
String standardLevel = routeOrder.getStandardLevel();
// PriceQueryData priceQueryData = new PriceQueryData();
@ -274,10 +231,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
// HotelPriceData hotelPriceData = estimatePrice.queryHotelPrice(priceQueryData);
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
HotelOrderDetail hotelOrderDetail = new HotelOrderDetail();
hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
if (sysCode != null) {
if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
@ -285,7 +239,6 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
}
if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) {
hotelOrderDetail.setBelongSysType(BELONG_SYS_TYPE_H3BPM);
}
if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) {
hotelOrderDetail.setBelongSysType(BELONG_SYS_TYPE_XNFSSC);
@ -295,11 +248,9 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
}
}
String EmployeeNo = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(EmployeeNo);
if (orderInfo != null) {
hotelOrderDetail.setOrderNo(orderInfo.getOrderSerialNo())
.setDetailId(orderInfo.getOrderSerialNo())
// .setSupplier(SUPPLIER_L_Y_EXTENSION_NAME)
@ -340,20 +291,16 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
hotelOrderDetail.setBookingUserCode(user.getEmployeeNo());
hotelOrderDetail.setBookingName(user.getName());
hotelOrderDetail.setBookingUserPhone(user.getPhoneNumber());
}
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null){
// hotelOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompany());
hotelOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompanyCode());
hotelOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
hotelOrderDetail.setCostCenter(approveOrderNo.getCostCenter());
hotelOrderDetail.setProjectOrderNo(approveOrderNo.getProjectName());
}
Optional<OrderDetail> first1 = routeOrder
.getOrderDetails()
.stream()