| | |
| | | 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; |
| | |
| | | private XpMapClient xpMapClient; |
| | | |
| | | @Resource |
| | | private BootCommonService bootCommonService; |
| | | @Resource |
| | | private XpOpenCityMapper xpOpenCityMapper; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private XpOrderClient xpOrderClient; |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | |
| | | @Resource |
| | | private XpTradingStrategyMapper xpTradingStrategyMapper; |
| | |
| | | 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) { |
| | |
| | | // RouteAndFareVo RouteAndFareVo = JSONObject.parseObject(jsonStr, RouteAndFareVo.class); |
| | | // return (RouteAndFareVo); |
| | | // } |
| | | |
| | | ArrayList<RouteAndFareVo> routeAndFareVos = new ArrayList<>(3); |
| | | |
| | | // 1. 基础数据查询 |
| | |
| | | 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)); |
| | |
| | | // 找出用户偏好 |
| | | Object cacheObject = redisService.getCacheObject(CacheConstants.USER_ROUTE_PREFERENCE + userId); |
| | | for (XpRoutePlan routePlan : xpRoutePlan) { |
| | | |
| | | |
| | | if (xpRoutePlan != null) { |
| | | routeAndFareDto.setRoutePlanRule(routePlan.getRoutePlanRule()); |
| | |
| | | // 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); |
| | |
| | | |
| | | // 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. 设置费用信息 |
| | |
| | | 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(); |
| | |
| | | xpGeoQueryEntity.setStatus(0); |
| | | xpGeoQueryEntity.setTimestamp(System.currentTimeMillis()); |
| | | geoQueryEntityService.save(xpGeoQueryEntity); |
| | | |
| | | return orderId.toString(); |
| | | } |
| | | } |
| | |
| | | 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) { |