| | |
| | | import com.xiaopeng.operation.mapper.*; |
| | | import com.xiaopeng.operation.query.PricingPageListQuery; |
| | | import com.xiaopeng.operation.service.IXpGeoQueryEntityService; |
| | | import com.xiaopeng.operation.service.XpPointService; |
| | | import com.xiaopeng.operation.service.XpPricingService; |
| | | import com.xiaopeng.operation.utils.XpPricingUtil; |
| | | import com.xiaopeng.operation.utils.holiday.HolidayUtil; |
| | |
| | | import javax.annotation.PreDestroy; |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | import java.util.concurrent.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | |
| | | |
| | | |
| | | @Resource |
| | | private XpPointMapper xpPointMapper; |
| | | |
| | | @Resource |
| | | private XpWhitelistMapper xpWhitelistMapper; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Autowired |
| | | private XpElectronicFenceMapper xpElectronicFenceMapper; |
| | | |
| | | @Autowired |
| | | private XpPointService xpPointService; |
| | | |
| | | |
| | | // 自定义线程池用于并行执行任务 |
| | |
| | | // throw new ServiceException("当前区域未开通服务", I18nKeyConstant.NO_CURRENT_REGION); |
| | | // } |
| | | |
| | | // 2. 计算价格(需要在并行任务前完成,因为优惠券查询需要价格) |
| | | // 2. 计算价格(需要在并行任务前完成,因为优惠券查询需要价格) TODO 判断是动态还是一口价 |
| | | // XpPricingCardVo xpPricingCardVo = xpPricingUtil.calculationPrice( |
| | | // JSON.parseObject(xpPricing.getBasicPricingJson()), |
| | | // JSON.parseArray(xpPricing.getStartingFareJson()), |
| | |
| | | |
| | | // 8. 构建响应对象 |
| | | RouteAndFareVo routeAndFareVo = new RouteAndFareVo(); |
| | | // routeAndFareVo.setRoute(routeVo); |
| | | |
| | | // MOCK数据 |
| | | RouteVo routeVo = new RouteVo(); |
| | | routeVo.setDistance(3000); |
| | | routeVo.setDuration(5); |
| | | routeVo.setRouteID("1"); |
| | | List<LonLatDto> routePolyline = Arrays.asList( |
| | | // 起点:天府新谷 |
| | | new LonLatDto(104.05363, 30.58937), |
| | | |
| | | // 途经点1:府城大道与交子北二路交叉口附近 |
| | | new LonLatDto(104.05821, 30.58745), |
| | | |
| | | // 途经点2:交子大道与成汉南路交叉口 |
| | | new LonLatDto(104.06418, 30.58492), |
| | | |
| | | // 途经点3:交子大道与万象南路交叉口 |
| | | new LonLatDto(104.06975, 30.58321), |
| | | |
| | | // 途经点4:交子大道与益州大道交叉口 |
| | | new LonLatDto(104.07366, 30.58198), |
| | | |
| | | // 终点:金融城(地铁站附近) |
| | | new LonLatDto(104.076544, 30.581039) |
| | | ); |
| | | routeVo.setPolyline(routePolyline); |
| | | routeAndFareVo.setRoute(routeVo); |
| | | |
| | | |
| | | routeAndFareVo.setXpPricingCard(xpPricingCardVo); |
| | |
| | | |
| | | @Override |
| | | public Long saveOrder(XpOrderDto dto, String uid) { |
| | | |
| | | |
| | | |
| | | // 是否在运营区域时间内 |
| | | XpElectronicFenceArea xpElectronicFenceArea = xpElectronicFenceAreaMapper.selectById(dto.getXpElectronicFenceAreaId()); |
| | | XpElectronicFence xpElectronicFence = xpElectronicFenceMapper.selectById(xpElectronicFenceArea.getElectronicId()); |
| | |
| | | } |
| | | |
| | | // 获取起点经纬度 |
| | | XpPoint xpPoint = xpPointMapper.selectById(dto.getStartPointId()); |
| | | XpPoint xpPoint = xpPointService.getById(dto.getStartPointId()); |
| | | |
| | | // 终点 |
| | | XpPoint endXpPoint = xpPointMapper.selectById(dto.getStartPointId()); |
| | | XpPoint endXpPoint = xpPointService.getById(dto.getStartPointId()); |
| | | |
| | | // 判断点位是否在运营区域内 |
| | | LocalTime now = LocalTime.now(); |
| | | boolean inTime = xpPointService.getInTime(now, xpPoint.getEffectivePeriod(), xpPoint.getEffectiveTimePeriod()); |
| | | if(!inTime){ |
| | | throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION); |
| | | } |
| | | inTime = xpPointService.getInTime(now, endXpPoint.getEffectivePeriod(), endXpPoint.getEffectiveTimePeriod()); |
| | | if(!inTime){ |
| | | throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION); |
| | | } |
| | | |
| | | // 判断当天取消的次数 后台配置 redis 查询 |
| | | Object cancelOrder = redisService.getCacheObject("CANCEL_ORDER_" + uid); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | private Boolean isInOperationTime(String operationStrategy) { |
| | | JSONArray jsonArray = JSONArray.parseArray(operationStrategy); |
| | | Integer holidayToday = holidayUtil.isHolidayToday(); |