修复数据回推时 ,出现可能找不到城市的异常
This commit is contained in:
parent
fe19500bc6
commit
9b89282394
|
@ -124,19 +124,12 @@ public class OrderDetailQuery {
|
|||
|
||||
List<OrderDetail> orderDetailList = orderDetailRepository.findByUpdateTimeBetween(targetTimeBegin, targetTimeEnd);
|
||||
|
||||
Stream<Object> orderDetailStream = orderDetailList.stream().map(orderDetail -> {
|
||||
switch (productType) {
|
||||
case 1:
|
||||
return processFlightOrderDetail(orderDetail, systemType);
|
||||
case 2:
|
||||
return processHotelOrderDetail(orderDetail, systemType);
|
||||
case 3:
|
||||
return processTrainOrderDetail(orderDetail, systemType);
|
||||
case 4:
|
||||
return processCarOrderDetail(orderDetail, systemType);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
Stream<Object> orderDetailStream = orderDetailList.stream().map(orderDetail -> switch (productType) {
|
||||
case 1 -> processFlightOrderDetail(orderDetail, systemType);
|
||||
case 2 -> processHotelOrderDetail(orderDetail, systemType);
|
||||
case 3 -> processTrainOrderDetail(orderDetail, systemType);
|
||||
case 4 -> processCarOrderDetail(orderDetail, systemType);
|
||||
default -> null;
|
||||
}).filter(Objects::nonNull);
|
||||
|
||||
List<Object> res = orderDetailStream.toList();
|
||||
|
@ -146,7 +139,7 @@ public class OrderDetailQuery {
|
|||
.limit(pageSize)
|
||||
.toList();
|
||||
|
||||
return Result.Success(SUCCESS, PageResult.totalPageNum((long) res.size(), paginatedResults));
|
||||
return Result.Success(SUCCESS, PageResult.totalPageNum(res.size(), paginatedResults));
|
||||
}
|
||||
|
||||
private Object processHotelOrderDetail(OrderDetail orderDetail, String systemType) {
|
||||
|
|
|
@ -3,22 +3,23 @@ package com.chint.domain.repository;
|
|||
import com.chint.application.dtos.LocationParam;
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LocationRepository {
|
||||
// List<Location> findByHot(List<LocationHot> locationHots);
|
||||
Location findByLocationId(Long locationId);
|
||||
|
||||
Location save(Location location);
|
||||
|
||||
PageResult<Location> pageQuery(LocationParam locationParam);
|
||||
|
||||
List<Location> findAll();
|
||||
|
||||
Location findByCityId(Long cityId,String shortName);
|
||||
Location findByCityId(Long cityId);
|
||||
|
||||
List<Location> findAllLevelThreeAndFour();
|
||||
|
||||
List<Location> findAllLeverThreeAndIsInternal();
|
||||
|
||||
Location findById(Long id);
|
||||
|
@ -31,6 +32,7 @@ public interface LocationRepository {
|
|||
|
||||
//这个方法需要实现根据城市类型,商品级别的筛选
|
||||
List<Location> findByName(LocationParam locationParam);
|
||||
|
||||
List<Location> findByName(String localName);
|
||||
|
||||
String locationPathByName(String localName);
|
||||
|
@ -41,14 +43,15 @@ public interface LocationRepository {
|
|||
|
||||
List<Location> findByNameList(List<Long> locationIds);
|
||||
|
||||
List<Location> findByCityNameAndLevelThree(String localName);
|
||||
List<Location> findListByCityName(String localName);
|
||||
|
||||
Location findByCityName(String localName);
|
||||
|
||||
Location findByDistrictShotName(String name);
|
||||
|
||||
List<Location> findChinaCityByLevel(String locationNames,Integer level);
|
||||
List<Location> findChinaCityByLevel(String locationNames, Integer level);
|
||||
|
||||
|
||||
List<Location> findNotChintCityByLevel(String locationNames,Integer level);
|
||||
List<Location> findNotChintCityByLevel(String locationNames, Integer level);
|
||||
|
||||
}
|
|
@ -56,10 +56,10 @@ public class CTripOrderDataAdapter implements OrderDataAdapter {
|
|||
if (hotelOrderInfoList != null && hotelOrderInfoList.size() == 1) {
|
||||
HotelOrderInfoEntity hotelOrderInfoEntity = hotelOrderInfoList.get(0);
|
||||
|
||||
Location byName = locationRepository.findByCityNameAndLevelThree(hotelOrderInfoEntity.getCityName()).get(0);
|
||||
Location byName = locationRepository.findByCityId(Long.valueOf(hotelOrderInfoEntity.getCityID()));
|
||||
|
||||
String currency = hotelOrderInfoEntity.getCurrency();
|
||||
if(currency == null){
|
||||
if (currency == null) {
|
||||
currency = CurrencyType.RENMINBI.getCode();
|
||||
}
|
||||
return builder.productType(LegConstant.LEG_TYPE_HOTEL)
|
||||
|
@ -83,11 +83,10 @@ public class CTripOrderDataAdapter implements OrderDataAdapter {
|
|||
if (flightOrderInfoList != null && flightOrderInfoList.size() == 1) {
|
||||
FlightOrderInfoEntity flightOrderInfo = flightOrderInfoList.get(0);
|
||||
FlightInfo flightInfo = flightOrderInfo.getFlightInfo().get(0);
|
||||
Location departCityName = locationRepository.findByCityNameAndLevelThree(flightInfo.getDCityName()).get(0);
|
||||
Location arriveCityName = locationRepository.findByCityNameAndLevelThree(flightInfo.getACityName()).get(0);
|
||||
|
||||
Location departCityName = locationRepository.findByCityId(Long.valueOf(flightInfo.getDCityCode()));
|
||||
Location arriveCityName = locationRepository.findByCityId(Long.valueOf(flightInfo.getACityName()));
|
||||
String currency = flightOrderInfo.getBasicInfo().getCurrency();
|
||||
if(currency == null){
|
||||
if (currency == null) {
|
||||
currency = CurrencyType.RENMINBI.getCode();
|
||||
}
|
||||
return builder.productType(LegConstant.LEG_TYPE_AIRPLANE)
|
||||
|
@ -122,8 +121,8 @@ public class CTripOrderDataAdapter implements OrderDataAdapter {
|
|||
CarQuickOrderInfoEntity carOrderInfo = carOrderInfoList.get(0);
|
||||
OrderProduct orderProduct = carOrderInfo.getOrderProduct();
|
||||
CarBasicInfo carBasicInfo = carOrderInfo.getBasicInfo();
|
||||
Location departCityName = locationRepository.findByCityNameAndLevelThree(orderProduct.getDepartAddress().getCityName()).get(0);
|
||||
Location arriveCityName = locationRepository.findByCityNameAndLevelThree(orderProduct.getArriveAddress().getCityName()).get(0);
|
||||
Location departCityName = locationRepository.findByCityId(Long.valueOf(orderProduct.getDepartAddress().getCityId()));
|
||||
Location arriveCityName = locationRepository.findByCityId(Long.valueOf(orderProduct.getArriveAddress().getCityId()));
|
||||
return builder.productType(LegConstant.LEG_TYPE_TAXI)
|
||||
.carOrderDetailData(carOrderInfo)
|
||||
.currencyCode(CurrencyType.RENMINBI.getCode())
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.chint.domain.aggregates.order.Location;
|
|||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.domain.value_object.OrderLegData;
|
||||
import com.chint.domain.value_object.SupplierCallbackData;
|
||||
import com.chint.interfaces.rest.ly.dto.carorderdatapushback.CarDetailResult;
|
||||
import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse;
|
||||
import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse;
|
||||
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
|
||||
|
@ -13,6 +12,7 @@ import com.chint.interfaces.rest.ly.tools.LYOrderUtil;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.LYConstant.*;
|
||||
|
@ -45,9 +45,21 @@ public class LYOrderDataAdapter implements OrderDataAdapter {
|
|||
TrainDetailResponse.TrainDetailData trainDetailData = (TrainDetailResponse.TrainDetailData) data;
|
||||
TrainDetailResponse.TravelData travelData = trainDetailData.getTravelData();
|
||||
String departCity = trainDetailData.getDepartCity();
|
||||
Location originLocation = locationRepository.findByCityNameAndLevelThree(departCity).get(0);
|
||||
String arriveCity = trainDetailData.getArriveCity();
|
||||
Location arriveLocation = locationRepository.findByCityNameAndLevelThree(arriveCity).get(0);
|
||||
Long originId;
|
||||
List<Location> listByCityName = locationRepository.findListByCityName(departCity);
|
||||
if (listByCityName == null || listByCityName.isEmpty()) {
|
||||
originId = null;
|
||||
} else {
|
||||
originId = listByCityName.get(0).getLocationId();
|
||||
}
|
||||
Long destinationId;
|
||||
List<Location> arriveCities = locationRepository.findListByCityName(arriveCity);
|
||||
if (arriveCities == null || arriveCities.isEmpty()) {
|
||||
destinationId = null;
|
||||
} else {
|
||||
destinationId = arriveCities.get(0).getLocationId();
|
||||
}
|
||||
return Optional.of(
|
||||
OrderLegData.builder()
|
||||
.productType(LEG_TYPE_TRAIN)
|
||||
|
@ -55,8 +67,8 @@ public class LYOrderDataAdapter implements OrderDataAdapter {
|
|||
.price(String.valueOf(trainDetailData.getTotalAmount()))
|
||||
.outOrderNo(trainDetailData.getOrderNo())
|
||||
.trainOrderDetailData(trainDetailData)
|
||||
.originId(originLocation.getLocationId())
|
||||
.destinationId(arriveLocation.getLocationId())
|
||||
.originId(originId)
|
||||
.destinationId(destinationId)
|
||||
.originName(departCity)
|
||||
.destinationName(arriveCity)
|
||||
.orderStatus(LYOrderUtil.mapTrainStatus(trainDetailData.getOrderStatus()))
|
||||
|
@ -73,7 +85,13 @@ public class LYOrderDataAdapter implements OrderDataAdapter {
|
|||
HotelDetailResponse.OrderInfo orderInfo = hotelDetailData.getOrderInfo();
|
||||
String travelApplyNo = hotelDetailData.getTravelData().getTravelApplyNo();
|
||||
String cityName = hotelDetailData.getHotelInfo().getCityName();
|
||||
Location originLocation = locationRepository.findByCityNameAndLevelThree(cityName).get(0);
|
||||
List<Location> listByCityName = locationRepository.findListByCityName(cityName);
|
||||
Long locationId;
|
||||
if (listByCityName == null || listByCityName.isEmpty()) {
|
||||
locationId = null;
|
||||
} else {
|
||||
locationId = listByCityName.get(0).getLocationId();
|
||||
}
|
||||
return Optional.of(
|
||||
OrderLegData.builder()
|
||||
.productType(LEG_TYPE_HOTEL)
|
||||
|
@ -86,9 +104,9 @@ public class LYOrderDataAdapter implements OrderDataAdapter {
|
|||
.endTime(orderInfo.getOriginalCheckOutDate())
|
||||
.orderStatus(supplierData.getSelfOrderStatus())
|
||||
.originOrderStatus(supplierData.getOutOrderStatus())
|
||||
.originId(originLocation.getLocationId())
|
||||
.originId(locationId)
|
||||
.originName(cityName)
|
||||
.destinationId(originLocation.getLocationId())
|
||||
.destinationId(locationId)
|
||||
.destinationName(cityName)
|
||||
.supplierName(SUPPLIER_L_Y)
|
||||
.build()
|
||||
|
@ -102,9 +120,23 @@ public class LYOrderDataAdapter implements OrderDataAdapter {
|
|||
CarDetailResponse.TravelDataInfo travelDataInfo = data.getTravelDataInfo();
|
||||
CarDetailResponse.OrderExtendInfo orderExtendInfo = data.getOrderExtendInfo();
|
||||
String startCityName = orderExtendInfo.getStartCityName();
|
||||
Location startLocation = locationRepository.findByCityNameAndLevelThree(startCityName).get(0);
|
||||
List<Location> listByCityName = locationRepository.findListByCityName(startCityName);
|
||||
Long originId;
|
||||
if (listByCityName == null || listByCityName.isEmpty()) {
|
||||
originId = null;
|
||||
} else {
|
||||
originId = listByCityName.get(0).getLocationId();
|
||||
}
|
||||
|
||||
Long destinationId;
|
||||
String endCityName = orderExtendInfo.getEndCityName();
|
||||
Location endLocation = locationRepository.findByCityNameAndLevelThree(endCityName).get(0);
|
||||
List<Location> arriveCities = locationRepository.findListByCityName(endCityName);
|
||||
if (arriveCities == null || arriveCities.isEmpty()) {
|
||||
destinationId = null;
|
||||
} else {
|
||||
destinationId = arriveCities.get(0).getLocationId();
|
||||
}
|
||||
|
||||
return Optional.of(
|
||||
OrderLegData.builder()
|
||||
.productType(LEG_TYPE_TAXI)
|
||||
|
@ -117,10 +149,10 @@ public class LYOrderDataAdapter implements OrderDataAdapter {
|
|||
.endTime(orderExtendInfo.getFinishTime())
|
||||
.orderStatus(supplierData.getSelfOrderStatus())
|
||||
.originOrderStatus(supplierData.getOutOrderStatus())
|
||||
.originId(startLocation.getLocationId())
|
||||
.originName(startLocation.getLocationName())
|
||||
.destinationId(endLocation.getLocationId())
|
||||
.destinationName(endLocation.getLocationName())
|
||||
.originId(originId)
|
||||
.originName(startCityName)
|
||||
.destinationId(destinationId)
|
||||
.destinationName(endCityName)
|
||||
.supplierName(SUPPLIER_L_Y)
|
||||
.build()
|
||||
);
|
||||
|
@ -132,13 +164,27 @@ public class LYOrderDataAdapter implements OrderDataAdapter {
|
|||
FlightOrderResponse.OrderDetails orderDetails = flightDetail.getOrderDetails();
|
||||
String travelApplyNo = flightDetail.getTravelData().getTravelApplyNo();
|
||||
|
||||
|
||||
// 检查 flightSegmentList 是否为空或者长度为 0
|
||||
if (flightDetail.getFlightSegmentList() == null || flightDetail.getFlightSegmentList().isEmpty()) {
|
||||
return Optional.empty(); // 或者你可以选择抛出一个异常
|
||||
}
|
||||
FlightOrderResponse.FlightSegment flightSegment = flightDetail.getFlightSegmentList().get(0);
|
||||
|
||||
String departCity = flightSegment.getDepartCity();
|
||||
Location originLocation = locationRepository.findByCityNameAndLevelThree(departCity).get(0);
|
||||
// 检查由 departCity 找到的位置列表是否为空或者长度为 0
|
||||
List<Location> originLocations = locationRepository.findListByCityName(departCity);
|
||||
if (originLocations == null || originLocations.isEmpty()) {
|
||||
return Optional.empty(); // 或者你可以选择抛出一个异常
|
||||
}
|
||||
Location originLocation = originLocations.get(0);
|
||||
|
||||
String arriveCity = flightSegment.getArriveCity();
|
||||
Location arriveLocation = locationRepository.findByCityNameAndLevelThree(arriveCity).get(0);
|
||||
// 检查由 arriveCity 找到的位置列表是否为空或者长度为 0
|
||||
List<Location> arriveLocations = locationRepository.findListByCityName(arriveCity);
|
||||
if (arriveLocations == null || arriveLocations.isEmpty()) {
|
||||
return Optional.empty(); // 或者你可以选择抛出一个异常
|
||||
}
|
||||
Location arriveLocation = arriveLocations.get(0);
|
||||
|
||||
return Optional.of(
|
||||
OrderLegData.builder()
|
||||
|
|
|
@ -64,8 +64,8 @@ public class LocationRepositoryImpl implements LocationRepository {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Location findByCityId(Long cityId, String shortName) {
|
||||
return jdbcLocationRepository.findByCityIdAndLocationShortName(cityId, shortName);
|
||||
public Location findByCityId(Long cityId) {
|
||||
return jdbcLocationRepository.findByCityId(cityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,8 +141,12 @@ public class LocationRepositoryImpl implements LocationRepository {
|
|||
|
||||
@Cacheable(value = "Location-findByCityNameAndLevelThree-localName", key = "#localName")
|
||||
@Override
|
||||
public List<Location> findByCityNameAndLevelThree(String localName) {
|
||||
return jdbcLocationRepository.findByLocationNameAndLevel(localName, 3);
|
||||
public List<Location> findListByCityName(String localName) {
|
||||
List<Location> byLocationNameAndLevel = jdbcLocationRepository.findByLocationNameContainingAndLevel(localName, 3);
|
||||
if (byLocationNameAndLevel == null || byLocationNameAndLevel.isEmpty()) {
|
||||
return jdbcLocationRepository.findByLocationNameContainingAndLevel(localName, 4);
|
||||
}
|
||||
return byLocationNameAndLevel;
|
||||
}
|
||||
|
||||
@Cacheable(value = "Location-findByCityName-localName", key = "#localName")
|
||||
|
@ -151,6 +155,7 @@ public class LocationRepositoryImpl implements LocationRepository {
|
|||
return jdbcLocationRepository.findByLocationNameAndLevelOrLocationNameAndLevel(localName, 3, localName, 4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Location findByDistrictShotName(String name) {
|
||||
return jdbcLocationRepository.findByLocationShortName(name);
|
||||
|
|
|
@ -13,8 +13,11 @@ import java.util.List;
|
|||
public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
|
||||
|
||||
Location findByCityIdAndLocationShortName(Long cityId, String locationShortName);
|
||||
|
||||
Location findByLocationId(Long locationId);
|
||||
|
||||
Location findByCityId(Long cityId);
|
||||
|
||||
Location findByLocationShortName(String locationShortName);
|
||||
|
||||
List<Location> findByLevelOrLevel(Integer level, Integer level2);
|
||||
|
@ -57,7 +60,7 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
|
|||
|
||||
List<Location> findByLocationPathNameInAndLevel(Collection<String> locationPathName, Integer level);
|
||||
|
||||
List<Location> findByLocationNameAndLevel(String locationName, Integer level);
|
||||
List<Location> findByLocationNameContainingAndLevel(String locationName, Integer level);
|
||||
|
||||
List<Location> findAllByLocationPathNotContainingAndLevel(String locationPath, Integer level);
|
||||
|
||||
|
|
|
@ -165,7 +165,6 @@ public class HotelOrderDetailDto implements Serializable {
|
|||
return null;
|
||||
}
|
||||
HotelOrderDetailDto hotelOrderDetailDto = BeanUtil.copyProperties(hotelOrderDetail, HotelOrderDetailDto.class);
|
||||
|
||||
return hotelOrderDetailDto;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,8 +307,8 @@ public class CommonController {
|
|||
FlyOkDTO freightDTO = new FlyOkDTO();
|
||||
ParamFly param = new ParamFly();
|
||||
param.setOrderSerialNo(orderSerialNo);
|
||||
changeFlightPush(freightDTO);
|
||||
freightDTO.setParam(param);
|
||||
changeFlightPush(freightDTO);
|
||||
//ruleViolate
|
||||
if (ruleViolate == 1 && subNotifyType == 9) {
|
||||
sendMsg(orderSerialNo);
|
||||
|
|
Loading…
Reference in New Issue