修复部分携程单号由于非空判断导致回推数据无法保存

This commit is contained in:
lulz1 2024-03-12 18:19:24 +08:00
parent 236d0ba056
commit 56c92b5e7d
5 changed files with 113 additions and 96 deletions

View File

@ -3,8 +3,10 @@ package com.chint.application.dtos;
import com.chint.domain.value_object.BaseQuery;
import lombok.Data;
import java.util.List;
@Data
public class OrderDetailQueryParam extends BaseQuery {
private Long orderId;
private List<Integer> productTypes;
}

View File

@ -1,18 +1,14 @@
package com.chint.application.dtos.mapper;
import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.response.FLightExtensionField;
import com.chint.application.dtos.response.HotelExtensionField;
import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.application.dtos.response.TrainExtensionField;
import com.chint.domain.aggregates.order.FlightOrderDetail;
import com.chint.domain.aggregates.order.HotelOrderDetail;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.TrainOrderDetail;
import com.chint.application.dtos.response.*;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.exceptions.NotFoundException;
import org.springframework.stereotype.Component;
import static com.chint.infrastructure.constant.LegConstant.*;
public class OrderDetailMapper {
public static OrderDetailRes copyFromExtension(OrderDetail orderDetail) {
@ -34,12 +30,12 @@ public class OrderDetailMapper {
orderDetailRes.setHotelExtensionField(hotelExtensionField);
}
case LEG_TYPE_TAXI -> {
CarExtensionField carExtensionField = new CarExtensionField();
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
orderDetailRes.setCarExtensionField(carExtensionField);
}
default -> throw new NotFoundException("订单类型未知");
}
return orderDetailRes;
}

View File

@ -1,22 +1,19 @@
package com.chint.application.out;
import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.*;
import com.chint.application.dtos.response.LocationRes;
import com.chint.application.dtos.AuthenticationDto;
import com.chint.application.dtos.AuthenticationSignDto;
import com.chint.application.dtos.OrderDetailQueryParam;
import com.chint.application.dtos.OrderSearchResult;
import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.application.dtos.response.RouteOrderPageRes;
import com.chint.application.queryies.OrderDetailQuery;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.ClientRepository;
import com.chint.domain.repository.LocationRepository;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.service.LocationDomainService;
import com.chint.domain.service.auth.AuthenticateService;
import com.chint.domain.value_object.OrderQueryData;
import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.constant.RankConstant;
import com.chint.infrastructure.util.*;
import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,14 +23,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.chrono.ChronoLocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
@ -61,6 +53,9 @@ public class OrderDetailController {
@Autowired
private OrderDetailRepository orderDetailRepository;
@Autowired
private OrderDetailQuery orderDetailPageQuery;
@ApiOperation("订单明细认证接口")
@PostMapping("/pubilc/authentication")
public Result<OrderSearchResult> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
@ -108,50 +103,50 @@ public class OrderDetailController {
List<Object> orderDetailResList = new ArrayList<>();
for (OrderDetail orderDetail : orderDetailList) {
if (orderDetail.getProductType().equals(productType)){
if (productType == 1){
if (orderDetail.getProductType().equals(productType)) {
if (productType == 1) {
FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail();
if (flightOrderDetail!=null){
if (flightOrderDetail.getBelongSysType() != null && flightOrderDetail.getBelongSysType().equals(systemType)){
if (flightOrderDetail != null) {
if (flightOrderDetail.getBelongSysType() != null && flightOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(flightOrderDetail);
}else {
} else {
orderDetailResList.add(flightOrderDetail);
}
}
}
if (productType == 2){
if (productType == 2) {
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
if (hotelOrderDetail != null ){
if (hotelOrderDetail != null) {
// orderDetailResList.add(hotelOrderDetail);
if (hotelOrderDetail.getBelongSysType() != null && hotelOrderDetail.getBelongSysType().equals(systemType)){
if (hotelOrderDetail.getBelongSysType() != null && hotelOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(hotelOrderDetail);
}else {
} else {
orderDetailResList.add(hotelOrderDetail);
}
}
}
if (productType == 3){
if (productType == 3) {
TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail();
if (trainOrderDetail!=null ){
if (trainOrderDetail != null) {
// orderDetailResList.add(trainOrderDetail);
if (trainOrderDetail.getBelongSysType() != null && trainOrderDetail.getBelongSysType().equals(systemType)){
if (trainOrderDetail.getBelongSysType() != null && trainOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(trainOrderDetail);
}else {
} else {
orderDetailResList.add(trainOrderDetail);
}
}
}
if (productType == 4){
if (productType == 4) {
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
if (carOrderDetail != null){
if (carOrderDetail.getBelongSysType() != null && carOrderDetail.getBelongSysType().equals(systemType)){
if (carOrderDetail != null) {
if (carOrderDetail.getBelongSysType() != null && carOrderDetail.getBelongSysType().equals(systemType)) {
orderDetailResList.add(carOrderDetail);
}else {
} else {
orderDetailResList.add(carOrderDetail);
}
}
@ -168,22 +163,15 @@ public class OrderDetailController {
String.valueOf(orderDetailResList.size())
), newres2));
}
else {
} else {
return Result.error("签名错误");
}
}
@ApiOperation("查询我的订单")
@PostMapping("/query/page")
public Result<OrderDetailRes> query(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
User currentUser = BaseContext.getCurrentUser();
List<OrderDetail> details = routeRepository.findByEmployeeNo(currentUser.getEmployeeNo())
.stream()
.flatMap(it -> it.getOrderDetails().stream())
.sorted(Comparator.comparing(OrderDetail::getUpdateTime).reversed())
.toList();
return null;
public Result<PageResult<OrderDetailRes>> query(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
PageResult<OrderDetailRes> orderDetailResPageResult = orderDetailPageQuery.orderDetailPageQuery(orderDetailQueryParam);
return Result.Success(SUCCESS, orderDetailResPageResult);
}
}

View File

@ -2,21 +2,51 @@ package com.chint.application.queryies;
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.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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Stream;
@Component
public class OrderDetailQuery {
@Autowired
private OrderDetailRepository orderDetailRepository;
@Autowired
private RouteRepository routeRepository;
public PageResult<OrderDetailRes> orderDetailPageQuery(OrderDetailQueryParam orderDetailQueryParam) {
Integer pageNum = orderDetailQueryParam.getPageNum();
Integer pageSize = orderDetailQueryParam.getPageSize();
User currentUser = BaseContext.getCurrentUser();
Stream<OrderDetail> details = routeRepository.findByEmployeeNo(currentUser.getEmployeeNo())
.stream()
.flatMap(it -> it.getOrderDetails().stream());
return null;
List<Integer> productTypes = orderDetailQueryParam.getProductTypes();
if (productTypes != null) {
details = details.filter(it -> productTypes.contains(it.getProductType()));
}
List<OrderDetail> res = details.toList();
Integer total = res.size();
List<OrderDetailRes> OrderDetailResList = res.stream()
.sorted(Comparator.comparing(OrderDetail::getUpdateTime).reversed())
.skip((long) (pageNum - 1) * pageSize)
.limit(pageSize)
.map(OrderDetailMapper::copyFromExtension)
.toList();
return new PageResult<>(total, OrderDetailResList);
}
}

View File

@ -9,7 +9,6 @@ import com.chint.domain.repository.UserRepository;
import com.chint.interfaces.rest.ctrip.dto.search.flight.*;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.ClientInfo;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity;
import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -18,8 +17,8 @@ import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_DETAIL_STATUS_SUCCESS;
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP_EXTENSION_NAME;
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
@Component
public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
@ -61,12 +60,12 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
BasicInfo flightOrderBasicInfo = flightOrderInfoEntity.getBasicInfo();
FlightInfo flightInfo = null;
if (!flightOrderInfoEntity.getTripRecordInfoList().isEmpty()){
if (!flightOrderInfoEntity.getTripRecordInfoList().isEmpty()) {
flightInfo = flightOrderInfoEntity.getFlightInfo().get(0);
}
TripRecordInfo tripRecordInfo = null;
if (!flightOrderInfoEntity.getTripRecordInfoList().isEmpty()){
if (!flightOrderInfoEntity.getTripRecordInfoList().isEmpty()) {
tripRecordInfo = flightOrderInfoEntity.getTripRecordInfoList().get(0);
}
@ -74,14 +73,14 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
PassengerBasic passengerBasic = null;
SequenceInfo sequenceInfo = null;
ChangeInfo changeInfo = null;
if (!flightOrderInfoEntity.getPassengerInfo().isEmpty()){
if (!flightOrderInfoEntity.getPassengerInfo().isEmpty()) {
passengerInfo = flightOrderInfoEntity.getPassengerInfo().get(0);
passengerBasic = passengerInfo.getPassengerBasic();
if (!passengerInfo.getSequenceInfo().isEmpty()){
if (passengerInfo.getSequenceInfo() != null && !passengerInfo.getSequenceInfo().isEmpty()) {
sequenceInfo = passengerInfo.getSequenceInfo().get(0);
if (!sequenceInfo.getChangeInfo().isEmpty()){
if (!sequenceInfo.getChangeInfo().isEmpty()) {
changeInfo = sequenceInfo.getChangeInfo().get(0);
}
}
@ -90,12 +89,11 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
FlightRefundInfo flightRefundInfo = flightOrderInfoEntity.getRefundInfo();
FlightOrderFeeDetail flightOrderFeeDetail = null;
if (!flightOrderInfoEntity.getFlightOrderFeeDetailList().isEmpty()){
if (!flightOrderInfoEntity.getFlightOrderFeeDetailList().isEmpty()) {
flightOrderFeeDetail = flightOrderInfoEntity.getFlightOrderFeeDetailList().get(0);
}
String orderNo = flightOrderBasicInfo.getOrderID();
String journeyNo = flightOrderBasicInfo.getJourneyID();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo);
@ -113,37 +111,40 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
flightOrderDetail.setSupplier(SUPPLIER_C_TRIP_EXTENSION_NAME);
flightOrderDetail.setTrvaleSysType("XC");
if (sysCode != null){
if (sysCode.equals("FSSC")){
if (sysCode != null) {
if (sysCode.equals("FSSC")) {
flightOrderDetail.setBelongSysType("GF_FK");
}
if (sysCode.equals("H3BPM")){
if (sysCode.equals("H3BPM")) {
flightOrderDetail.setBelongSysType("JT_BPM");
}
if (sysCode.equals("XNFSSC")){
if (sysCode.equals("XNFSSC")) {
flightOrderDetail.setBelongSysType("XN_FK");
}
if (sysCode.equals("ANFSSC")){
if (sysCode.equals("ANFSSC")) {
flightOrderDetail.setBelongSysType("AN_FK");
}
}
flightOrderDetail.setOrderNo(orderNo);
first.ifPresent(orderDetail ->
flightOrderDetail.setOrderStatus(orderDetail.getLastEvent().mapToFlightOrderDetailStatus())
first.ifPresent(orderDetail ->{
OrderEvent lastEvent = orderDetail.getLastEvent();
if(lastEvent != null){
flightOrderDetail.setOrderStatus(lastEvent.mapToFlightOrderDetailStatus());
}}
);
if (flightOrderBasicInfo != null){
if (flightOrderBasicInfo != null) {
flightOrderDetail.setCreateTime(flightOrderBasicInfo.getCreateTime());
flightOrderDetail.setUserCode(flightOrderBasicInfo.getEmployeeID());
flightOrderDetail.setOrderAmount(String.valueOf(flightOrderBasicInfo.getAmount()));
flightOrderDetail.setPaymentType(flightOrderBasicInfo.getPrepayType());
//付款方式 ACCNT公司统付 其他类型个人支付
if (flightOrderBasicInfo.getPrepayType().equals("ACCNT")){
if (flightOrderBasicInfo.getPrepayType().equals("ACCNT")) {
flightOrderDetail.setPersonalPaymentAmount(String.valueOf(flightOrderBasicInfo.getAmount()));
}else {
} else {
flightOrderDetail.setPersonalPaymentAmount(String.valueOf(flightOrderBasicInfo.getAmount()));
}
flightOrderDetail.setProjectOrderNo(flightOrderBasicInfo.getCostCenter5());
@ -151,7 +152,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
flightOrderDetail.setCostCenter(flightOrderBasicInfo.getCostCenter6());
}
if (flightInfo != null){
if (flightInfo != null) {
flightOrderDetail.setOverStandard(flightInfo.getClassReasonDesc());
flightOrderDetail.setStartTime(flightInfo.getTakeoffTime());
flightOrderDetail.setArriveTime(flightInfo.getArrivalTime());
@ -180,21 +181,21 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
}
if (tripRecordInfo != null){
if (tripRecordInfo != null) {
flightOrderDetail.setStartTerminal(tripRecordInfo.getDPortBuilding());
flightOrderDetail.setEndTerminal(tripRecordInfo.getAPortBuilding());
flightOrderDetail.setTicketNo(tripRecordInfo.getTicketNo());
flightOrderDetail.setChangedTicketNo(tripRecordInfo.getTicketNo());
}
if (passengerBasic != null){
if (passengerBasic != null) {
flightOrderDetail.setUserName(passengerBasic.getPassengerName());
flightOrderDetail.setPhone(passengerBasic.getMobilePhone());
flightOrderDetail.setBOOK_ORG_STRUCT_1(passengerBasic.getDept1());
flightOrderDetail.setBOOK_ORG_STRUCT_2(passengerBasic.getDept2());
flightOrderDetail.setBOOK_ORG_STRUCT_3(passengerBasic.getDept3());
}
if (changeInfo != null){
if (changeInfo != null) {
flightOrderDetail.setChangeFee(String.valueOf(changeInfo.getDateChangeFee()));
flightOrderDetail.setUpFee(String.valueOf(changeInfo.getPriceDifferential()));
}
@ -202,7 +203,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null){
if (approveOrderNo != null) {
flightOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompany());
flightOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
flightOrderDetail.setReceiptsNum(journeyNo);
@ -219,12 +220,12 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
flightOrderDetail.setBookingName(user.getName());
flightOrderDetail.setBookingUserPhone(user.getPhoneNumber());
if (flightOrderFeeDetail != null){
if (flightOrderFeeDetail != null) {
flightOrderDetail.setRefundAmount(String.valueOf(flightOrderFeeDetail.getTransactionAmount()));
}
if (flightRefundInfo != null){
if (!flightRefundInfo.getRefundDetail().isEmpty()){
if (flightRefundInfo != null) {
if (!flightRefundInfo.getRefundDetail().isEmpty()) {
FlightRefundDetail refundDetail = flightRefundInfo.getRefundDetail().get(0);
flightOrderDetail.setRefundFee(String.valueOf(refundDetail.getRefundFee()));
}
@ -275,23 +276,23 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
hotelOrderDetail.setOrderStatus(ORDER_DETAIL_STATUS_SUCCESS);
hotelOrderDetail.setSupplier(SUPPLIER_C_TRIP_EXTENSION_NAME);
if(routeOrder != null){
if (routeOrder != null) {
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
approveOrderNo = routeOrder.getApproveOrderNo();
if (sysCode != null){
if (sysCode.equals("FSSC")){
if (sysCode != null) {
if (sysCode.equals("FSSC")) {
hotelOrderDetail.setBelongSysType("GF_FK");
}
if (sysCode.equals("H3BPM")){
if (sysCode.equals("H3BPM")) {
hotelOrderDetail.setBelongSysType("JT_BPM");
}
if (sysCode.equals("XNFSSC")){
if (sysCode.equals("XNFSSC")) {
hotelOrderDetail.setBelongSysType("XN_FK");
}
if (sysCode.equals("ANFSSC")){
if (sysCode.equals("ANFSSC")) {
hotelOrderDetail.setBelongSysType("AN_FK");
}
}
@ -305,7 +306,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
}
if (user != null){
if (user != null) {
hotelOrderDetail.setBookingUserCode(String.valueOf(user.getEmployeeNo()));
hotelOrderDetail.setBookingName(user.getName());
hotelOrderDetail.setBookingUserPhone(user.getPhoneNumber());
@ -319,20 +320,20 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
hotelOrderDetail.setCustomers(customers);
}
if (approveOrderNo != null){
if (approveOrderNo != null) {
hotelOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompany());
hotelOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
}
if (hotelOrderInfoEntity != null){
if (hotelOrderInfoEntity != null) {
hotelOrderDetail.setReceiptsNum(hotelOrderInfoEntity.getJourneyNo());
hotelOrderDetail.setOrderNo(hotelOrderInfoEntity.getOrderID()); //订单号
hotelOrderDetail.setCreateTime(hotelOrderInfoEntity.getOrderDate());
hotelOrderDetail.setCheckInCity(hotelOrderInfoEntity.getCityName());
hotelOrderDetail.setHotelName(hotelOrderInfoEntity.getHotelName());
hotelOrderDetail.setContactPhone(hotelOrderInfoEntity.getTelephone());
hotelOrderDetail.setHotelAddress(hotelOrderInfoEntity.getCountryName() + hotelOrderInfoEntity.getProvinceName()+hotelOrderInfoEntity.getCityName()+ hotelOrderInfoEntity.getDistrictName() + hotelOrderInfoEntity.getAddress());
hotelOrderDetail.setHotelAddress(hotelOrderInfoEntity.getCountryName() + hotelOrderInfoEntity.getProvinceName() + hotelOrderInfoEntity.getCityName() + hotelOrderInfoEntity.getDistrictName() + hotelOrderInfoEntity.getAddress());
hotelOrderDetail.setStarRate(hotelOrderInfoEntity.getStar());
hotelOrderDetail.setCheckInDate(hotelOrderInfoEntity.getStartTime()); //入住日期
hotelOrderDetail.setDepartureDate(hotelOrderInfoEntity.getEndTime()); //离店日期 "2022-09-10"
@ -370,10 +371,10 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
ClientInfo clientInfo = null;
if (!hotelOrderInfoEntity.getClientInfo().isEmpty()){
if (!hotelOrderInfoEntity.getClientInfo().isEmpty()) {
clientInfo = hotelOrderInfoEntity.getClientInfo().get(0);
}
if (clientInfo != null){
if (clientInfo != null) {
hotelOrderDetail.setBOOK_ORG_STRUCT_1(clientInfo.getDept1());
hotelOrderDetail.setBOOK_ORG_STRUCT_2(clientInfo.getDept2());
hotelOrderDetail.setBOOK_ORG_STRUCT_3(clientInfo.getDept3());