puzhibing
2026-04-16 46342ddcf5d52ccbf2ae8d8a9a0b14cc0d29b250
xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
@@ -7,21 +7,21 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaopeng.api.dto.account.GetUserCouponDto;
import com.xiaopeng.api.dto.map.OrderRouteAndFareDto;
import com.xiaopeng.api.dto.map.RouteAndFareDto;
import com.xiaopeng.api.dto.map.RouteStaleCheckDto;
import com.xiaopeng.api.dto.map.SelectNavigationRouteDto;
import com.xiaopeng.api.dto.operation.LonLatDto;
import com.xiaopeng.api.enums.RouteStrategyKind;
import com.xiaopeng.api.dto.pushMessage.SendMessageDTO;
import com.xiaopeng.api.feignClient.account.XpAppUserClient;
import com.xiaopeng.api.feignClient.account.XpAppUserCouponClient;
import com.xiaopeng.api.feignClient.map.XpMapClient;
import com.xiaopeng.api.feignClient.operation.XpPointClient;
import com.xiaopeng.api.feignClient.order.XpOrderClient;
import com.xiaopeng.api.feignClient.pushMessage.XpPushMessageClient;
import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient;
import com.xiaopeng.api.model.operation.*;
import com.xiaopeng.api.model.order.XpOrder;
import com.xiaopeng.api.model.vehicleConvoy.XpVehicle;
import com.xiaopeng.api.service.BootCommonService;
import com.xiaopeng.api.vo.account.UserCouponVo;
import com.xiaopeng.api.vo.operation.FareVo;
import com.xiaopeng.api.vo.operation.MultiRouteAndFareVo;
@@ -85,6 +85,8 @@
    private XpMapClient xpMapClient;
    @Resource
    private BootCommonService bootCommonService;
    @Resource
    private XpOpenCityMapper xpOpenCityMapper;
    @Resource
@@ -101,6 +103,8 @@
    @Resource
    private XpOrderClient xpOrderClient;
    @Resource
    private XpVehicleClient xpVehicleClient;
    @Resource
    private XpTradingStrategyMapper xpTradingStrategyMapper;
@@ -200,6 +204,17 @@
        return hour + "-" + (hour + 1);
    }
    public XpPricing getInfo(Long cityId,String vehicleModel){
        LambdaQueryWrapper<XpPricing> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(XpPricing::getDeleted, 0);
        queryWrapper.eq(XpPricing::getCityId, cityId);
        if(vehicleModel != null){
            queryWrapper.eq(XpPricing::getVehicleModel, vehicleModel);
        }
        return super.getOne(queryWrapper,true);
    }
    @Override
    public List<RouteAndFareVo> getRouteAndFare(RouteAndFareDto routeAndFareDto, String userId) {
@@ -213,7 +228,6 @@
//            RouteAndFareVo RouteAndFareVo = JSONObject.parseObject(jsonStr, RouteAndFareVo.class);
//            return (RouteAndFareVo);
//        }
        ArrayList<RouteAndFareVo> routeAndFareVos = new ArrayList<>(3);
        // 1. 基础数据查询
@@ -226,6 +240,15 @@
        if (openCities == null ) {
            throw new ServiceException("获取城市信息失败", I18nKeyConstant.CITY_NOT_FOUND);
        }
        //根据订单获取车型 获取定价策略
        String vehicleModel = bootCommonService.getVehicleModelId(routeAndFareDto.getOrderId());
        XpPricing xpPricing = this.getInfo(routeAndFareDto.getOpenCityId(),vehicleModel);
        if (xpPricing == null) {
            throw new ServiceException("当前区域未开通服务", I18nKeyConstant.NO_CURRENT_REGION);
        }
        XpOpenCity xpOpenCity = openCities;
        routeAndFareDto.setOpenCityId(xpOpenCity.getId());
        List<XpRoutePlan> xpRoutePlan = xpRoutePlanMapper.selectList(new LambdaQueryWrapper<XpRoutePlan>().eq(XpRoutePlan::getAuditStatus, 2).eq(XpRoutePlan::getCityCode, cityCode));
@@ -233,7 +256,6 @@
        // 找出用户偏好
        Object cacheObject = redisService.getCacheObject(CacheConstants.USER_ROUTE_PREFERENCE + userId);
        for (XpRoutePlan routePlan : xpRoutePlan) {
            if (xpRoutePlan != null) {
                routeAndFareDto.setRoutePlanRule(routePlan.getRoutePlanRule());
@@ -246,12 +268,6 @@
                    // keep city default
                }
            }
            XpPricing xpPricing = this.baseMapper.selectOne(new LambdaQueryWrapper<XpPricing>().eq(XpPricing::getCityId, routeAndFareDto.getOpenCityId()));
            if (xpPricing == null) {
                throw new ServiceException("当前区域未开通服务", I18nKeyConstant.NO_CURRENT_REGION);
            }
            // 算距离
            R<RouteVo> distanceAndDuration = xpMapClient.getDistanceAndDuration(routeAndFareDto);
@@ -409,7 +425,7 @@
            // 11. 生成订单ID并缓存
            String id = CacheConstants.ORD + System.currentTimeMillis() + "_" + UUID.randomUUID().toString().substring(0, 8);
            redisService.setCacheObject(CacheConstants.ORD + id + userId, xpPricingCardVo, 1l, TimeUnit.DAYS);
            redisService.setCacheObject(CacheConstants.ORD + id + userId, xpPricingCardVo, 1L, TimeUnit.DAYS);
            fareVo.setId(id);
            // 12. 设置费用信息
@@ -612,24 +628,23 @@
        xpOrder.setPlacementAddress(dto.getPlacementAddress());
        xpOrder.setCityId(dto.getOpenCityId());
        xpOrder.setXpElectronicFenceAreaId(dto.getXpElectronicFenceAreaId());
        xpOrder.setStartPointId(dto.getStartPointId());
        xpOrder.setStartLon(xpPoint.getPointLon());
        xpOrder.setStartLat(xpPoint.getPointLat());
        xpOrder.setBoardingLon(xpPoint.getPointLon());
        xpOrder.setBoardingLat(xpPoint.getPointLat());
        xpOrder.setBoardingAddress(xpPoint.getPointAddress());
        xpOrder.setStartAddress(xpPoint.getPointAddress());
        xpOrder.setStartPointName(xpPoint.getPointName());
        xpOrder.setEndPointId(dto.getEndPointId());
        xpOrder.setEndLon(endXpPoint.getPointLon());
        xpOrder.setEndLat(endXpPoint.getPointLat());
        xpOrder.setStartAddress(xpPoint.getPointAddress());
        xpOrder.setEndAddress(endXpPoint.getPointAddress());
        xpOrder.setXpElectronicFenceAreaId(dto.getXpElectronicFenceAreaId());
        xpOrder.setStartPointId(dto.getStartPointId());
        xpOrder.setEndPointId(dto.getEndPointId());
        xpOrder.setStartPointName(xpPoint.getPointName());
        xpOrder.setEndPointName(endXpPoint.getPointName());
        // 当前时段
        String currentTimeSlot = DateUtils.getCurrentTimeSlot();
@@ -732,7 +747,6 @@
                xpGeoQueryEntity.setStatus(0);
                xpGeoQueryEntity.setTimestamp(System.currentTimeMillis());
                geoQueryEntityService.save(xpGeoQueryEntity);
                return orderId.toString();
            }
        }
@@ -760,8 +774,8 @@
        return orderId.toString();
    }
    private Boolean isInOperationTime(String operationStrategy) {
    @Override
    public Boolean isInOperationTime(String operationStrategy) {
        JSONArray jsonArray = JSONArray.parseArray(operationStrategy);
        Integer holidayToday = holidayUtil.isHolidayToday();
        for (Object o : jsonArray) {