| | |
| | | |
| | | @Override |
| | | public RouteAndFareVo getRouteAndFare(RouteAndFareDto routeAndFareDto, String userId) { |
| | | // 判断是否5分钟内进行了查询 相同站点的起始点 并且是同时段 |
| | | String key = "xp-map-query-" + routeAndFareDto.getOpenCityId() |
| | | + "-" + routeAndFareDto.getOrigin().getLongitude() + "-" + routeAndFareDto.getOrigin().getLatitude() |
| | | + "-" + routeAndFareDto.getDestination().getLongitude() + "-" + routeAndFareDto.getDestination().getLatitude() + "-" + getCurrentTimeSlot() + "-" + userId+routeAndFareDto.getUserCouponId(); |
| | | |
| | | if (redisService.hasKey(key)) { |
| | | String jsonStr = Objects.requireNonNull(redisService.getCacheObject(key)).toString(); |
| | | RouteAndFareVo RouteAndFareVo = JSONObject.parseObject(jsonStr, RouteAndFareVo.class); |
| | | return (RouteAndFareVo); |
| | | } |
| | | // // 判断是否5分钟内进行了查询 相同站点的起始点 并且是同时段 |
| | | // String key = "xp-map-query-" + routeAndFareDto.getOpenCityId() |
| | | // + "-" + routeAndFareDto.getOrigin().getLongitude() + "-" + routeAndFareDto.getOrigin().getLatitude() |
| | | // + "-" + routeAndFareDto.getDestination().getLongitude() + "-" + routeAndFareDto.getDestination().getLatitude() + "-" + getCurrentTimeSlot() + "-" + userId+routeAndFareDto.getUserCouponId(); |
| | | // |
| | | // if (redisService.hasKey(key)) { |
| | | // String jsonStr = Objects.requireNonNull(redisService.getCacheObject(key)).toString(); |
| | | // RouteAndFareVo RouteAndFareVo = JSONObject.parseObject(jsonStr, RouteAndFareVo.class); |
| | | // return (RouteAndFareVo); |
| | | // } |
| | | |
| | | // 1. 基础数据查询 |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(routeAndFareDto.getOrigin().getLongitude().toString(), routeAndFareDto.getOrigin().getLatitude().toString()); |
| | |
| | | routeAndFareVo.getXpPricingCard().setFinalFareStr(fareVo.getFinalFareStr()); |
| | | |
| | | |
| | | String voJsonStr = JSONObject.toJSONString(routeAndFareVo); |
| | | // 进行缓存 |
| | | redisService.setCacheObject(key, voJsonStr, 5l, TimeUnit.MINUTES); |
| | | // String voJsonStr = JSONObject.toJSONString(routeAndFareVo); |
| | | // 进行缓存 |
| | | // redisService.setCacheObject(key, voJsonStr, 5l, TimeUnit.MINUTES); |
| | | //缓存导航数据,用于下单后推送导航给车端和乘客端 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_END_DATA:" + userId, JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | return routeAndFareVo; |
| | |
| | | |
| | | |
| | | @Override |
| | | @Deprecated |
| | | public RouteAndFareVo getRouteAndFare(RouteAndFareDto routeAndFareDto, String userId) { |
| | | |
| | | |
| | |
| | | List<FareBreakdownDetailVo> longDistance = new ArrayList<>(); |
| | | XpOrder order = this.getById(orderId); |
| | | |
| | | Long orderAppUserId = order.getAppUserId(); |
| | | if (order == null) { |
| | | throw new RuntimeException("订单不存在"); |
| | | } |
| | |
| | | |
| | | com.alibaba.fastjson.JSONObject basicPricingJson = com.alibaba.fastjson.JSONObject.parseObject(pricing.getBasicPricingJson()); |
| | | |
| | | XpPricingCardVo xpPricingCardVo = xpPricingUtil.calculationFixedPrice(orderAppUserId.toString(), basicPricingJson, null, mileageKilometers, duration1, 0, 0.0, pricing.getIsDynamicPrice(), order.getCityId(), pricing.getDynamicPricingJson()); |
| | | XpPricingCardVo xpPricingCardVo = xpPricingUtil.calculationFixedPrice(uid, basicPricingJson, null, mileageKilometers, duration1, 0, 0.0, pricing.getIsDynamicPrice(), order.getCityId(), pricing.getDynamicPricingJson()); |
| | | XpOrderDetail xpOrderDetail = new XpOrderDetail(); |
| | | xpOrderDetail.setDetailType(1); |
| | | xpOrderDetail.setOrderId(orderId); |
| | |
| | | order.setTripEnd(tripEnd); |
| | | this.updateById(order); |
| | | } |
| | | // 计算行程时间 单位分钟 |
| | | // 计算时间差 |
| | | Duration durationBetween = Duration.between(createTime, tripEnd); |
| | | |
| | | // 转换为秒并保留一位小数 |
| | | BigDecimal minutes = BigDecimal.valueOf(durationBetween.getSeconds()); |
| | | res.setTime(minutes); |
| | | double exactMinutes = Duration.between(order.getBoardingTime(), order.getTripEnd()).toMillis() / (1000.0 * 60); |
| | | res.setTime(new BigDecimal(exactMinutes).setScale(2, RoundingMode.HALF_UP)); |
| | | return R.ok(res); |
| | | } |
| | | |
| | |
| | | } else { |
| | | orderDetailVo.setOrderTime(0.0); |
| | | } |
| | | orderDetailVo.setTotalMileage(order.getMileageKilometers() != null ? new BigDecimal(order.getMileageKilometers()).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0D); |
| | | |
| | | orderDetailVo.setTotalMileage(order.getMileageKilometers() != null ? new BigDecimal(order.getMileageKilometers() * 1000).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0D); |
| | | orderDetailVo.setOrderTime(new BigDecimal(null == order.getDuration() ? 0 : order.getDuration()).multiply(new BigDecimal(60)).setScale(0, RoundingMode.HALF_EVEN).doubleValue()); |
| | | return orderDetailVo; |
| | | } |
| | | |