Merge branch '1.0' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi into 1.0
| | |
| | | package com.xiaopeng.account.config; |
| | | |
| | | import com.xiaopeng.unifiedverification.interceptor.CheckForClientInterceptor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Slf4j |
| | | @Configuration |
| | | public class MiniprogramConfigurer extends WebMvcConfigurerAdapter { |
| | | |
| | | @Resource |
| | | @Lazy |
| | | private CheckForClientInterceptor checkForClientInterceptor; |
| | | |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | try { |
| | | log.info("正在注册小程序拦截器..."); |
| | | // 统一验证服务拦截器 |
| | | registry.addInterceptor(checkForClientInterceptor) |
| | | .addPathPatterns("/base/v1/mini-program/**", "/api/v1/mini-program/**"); |
| | | log.info("小程序拦截器注册成功"); |
| | | } catch (Exception e) { |
| | | log.warn("小程序拦截器注册失败: {}", e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | //package com.xiaopeng.account.config; |
| | | // |
| | | //import com.xiaopeng.unifiedverification.interceptor.CheckForClientInterceptor; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | //import org.springframework.context.annotation.Lazy; |
| | | //import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | //import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
| | | // |
| | | //import javax.annotation.Resource; |
| | | // |
| | | //@Slf4j |
| | | //@Configuration |
| | | //public class MiniprogramConfigurer extends WebMvcConfigurerAdapter { |
| | | // |
| | | // @Resource |
| | | // @Lazy |
| | | // private CheckForClientInterceptor checkForClientInterceptor; |
| | | // |
| | | // @Override |
| | | // public void addInterceptors(InterceptorRegistry registry) { |
| | | // try { |
| | | // log.info("正在注册小程序拦截器..."); |
| | | // // 统一验证服务拦截器 |
| | | //// registry.addInterceptor(checkForClientInterceptor) |
| | | //// .addPathPatterns("/base/v1/mini-program/**", "/api/v1/mini-program/**"); |
| | | // log.info("小程序拦截器注册成功"); |
| | | // } catch (Exception e) { |
| | | // log.warn("小程序拦截器注册失败: {}", e.getMessage()); |
| | | // } |
| | | // } |
| | | // |
| | | //} |
| | |
| | | return R.ok(appUserCoupon.getMoney()); |
| | | } |
| | | |
| | | /** |
| | | * 退回用户的优惠卷 |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | @PostMapping("/logan/inner/appUserCoupon/backUserCoupon") |
| | | public R<BigDecimal> backUserCoupon(@RequestBody UseUserCouponDto dto) { |
| | | if(dto.getUserCouponId() == null){ |
| | | return R.ok(); |
| | | } |
| | | XpAppUserCoupon appUserCoupon = xpAppUserCouponService.getById(dto.getUserCouponId()); |
| | | //状态(1=未使用,2=已使用,3=已过期) |
| | | if(appUserCoupon.getExpirationTime().isAfter(LocalDateTime.now())){ |
| | | appUserCoupon.setStatus(3); |
| | | }else{ |
| | | appUserCoupon.setStatus(1); |
| | | } |
| | | appUserCoupon.setUseTime(null); |
| | | appUserCoupon.setAppUserId(null); |
| | | xpAppUserCouponService.updateById(appUserCoupon); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| New file |
| | |
| | | package com.xiaopeng.account.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.xiaopeng.account.service.IXpUserRoutePlanRuleService; |
| | | import com.xiaopeng.api.model.account.XpUserRoutePlanRule; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | |
| | | /** |
| | | * 用户规划线路偏好 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class XpUserRoutePlanRuleController { |
| | | |
| | | @Resource |
| | | private IXpUserRoutePlanRuleService xpUserRoutePlanRuleService; |
| | | |
| | | |
| | | /** |
| | | * 根据用户id获取导航偏好设置 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | @GetMapping("/logan/inner/userRoutePlanRule/getXpUserRoutePlanRule/{uid}") |
| | | public R<XpUserRoutePlanRule> getXpUserRoutePlanRule(@PathVariable("uid") String uid){ |
| | | XpUserRoutePlanRule one = xpUserRoutePlanRuleService.getOne(new LambdaQueryWrapper<XpUserRoutePlanRule>().eq(XpUserRoutePlanRule::getUserId, uid) |
| | | .eq(XpUserRoutePlanRule::getDeleted, 0)); |
| | | return R.ok(one); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.account.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.xiaopeng.api.model.account.XpUserRoutePlanRule; |
| | | |
| | | public interface XpUserRoutePlanRuleMapper extends BaseMapper<XpUserRoutePlanRule> { |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.account.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.xiaopeng.api.model.account.XpUserRoutePlanRule; |
| | | |
| | | public interface IXpUserRoutePlanRuleService extends IService<XpUserRoutePlanRule> { |
| | | } |
| New file |
| | |
| | | package com.xiaopeng.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.account.mapper.XpUserRoutePlanRuleMapper; |
| | | import com.xiaopeng.account.service.IXpUserRoutePlanRuleService; |
| | | import com.xiaopeng.api.model.account.XpUserRoutePlanRule; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class XpUserRoutePlanRuleServiceImpl extends ServiceImpl<XpUserRoutePlanRuleMapper, XpUserRoutePlanRule> implements IXpUserRoutePlanRuleService { |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.xiaopeng.account.mapper.XpUserRoutePlanRuleMapper"> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | package com.xiaopeng.api.factory.account; |
| | | |
| | | import com.xiaopeng.api.feignClient.account.UserRoutePlanRuleClient; |
| | | import com.xiaopeng.api.model.account.XpUserRoutePlanRule; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | |
| | | |
| | | @Slf4j |
| | | public class UserRoutePlanRuleClientFallbackFactory implements FallbackFactory<UserRoutePlanRuleClient> { |
| | | @Override |
| | | public UserRoutePlanRuleClient create(Throwable cause) { |
| | | return new UserRoutePlanRuleClient() { |
| | | @Override |
| | | public R<XpUserRoutePlanRule> getXpUserRoutePlanRule(String uid) { |
| | | log.error("根据用户id获取导航偏好设置失败:" + cause); |
| | | return R.fail("根据用户id获取导航偏好设置失败:" + cause); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | |
| | | /** |
| | |
| | | return R.fail("优惠券使用失败,"+cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<BigDecimal> backUserCoupon(UseUserCouponDto dto) { |
| | | log.error("优惠券退回失败,原因: {}", cause.getMessage()); |
| | | return null; |
| | | } |
| | | |
| | | }; |
| | | } |
| | | } |
| | |
| | | return R.fail("更新订单状态失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R<String> carAbnormalUpdateOrderStatus(Long orderId) { |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R<String> saveVehicleLocation(OrderTrajectoryVo orderTrajectory) { |
| New file |
| | |
| | | package com.xiaopeng.api.feignClient.account; |
| | | |
| | | |
| | | import com.xiaopeng.api.factory.account.UserRoutePlanRuleClientFallbackFactory; |
| | | import com.xiaopeng.api.model.account.XpUserRoutePlanRule; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.dto.ServiceNameConstantsEnum; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | |
| | | @FeignClient(contextId = "UserRoutePlanRuleClient", |
| | | value = ServiceNameConstantsEnum.XP_ACCOUNT_SERVICE, |
| | | fallbackFactory = UserRoutePlanRuleClientFallbackFactory.class) |
| | | public interface UserRoutePlanRuleClient { |
| | | |
| | | |
| | | /** |
| | | * 根据用户id获取导航偏好设置 |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | @GetMapping("/logan/inner/userRoutePlanRule/getXpUserRoutePlanRule/{uid}") |
| | | R<XpUserRoutePlanRule> getXpUserRoutePlanRule(@PathVariable("uid") String uid); |
| | | } |
| | |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | |
| | | R<BigDecimal> useUserCoupon(@RequestBody UseUserCouponDto dto); |
| | | |
| | | |
| | | /** |
| | | * 退回用户的优惠卷 |
| | | * @param dto |
| | | * @return |
| | | */ |
| | | @PostMapping("/logan/inner/appUserCoupon/backUserCoupon") |
| | | R<BigDecimal> backUserCoupon(@RequestBody UseUserCouponDto dto); |
| | | |
| | | |
| | | } |
| | |
| | | @PostMapping("/logan/inner/v1/order/updateOrderStatus") |
| | | R<String> updateOrderStatus(@RequestParam Long orderId, |
| | | @RequestParam Integer status); |
| | | /** |
| | | * 行驶中车辆异常,订单状态修改- 修改状态=7 再修改 金额-再将状态修改成8 |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @PostMapping("/logan/inner/v1/order/carAbnormalUpdateOrderStatus") |
| | | R<String> carAbnormalUpdateOrderStatus(@RequestParam Long orderId); |
| | | |
| | | |
| | | /** |
| | |
| | | package com.xiaopeng.api.model.account; |
| | | |
| | | import java.math.BigDecimal; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.xiaopeng.common.core.web.domain.BaseModel; |
| | | import io.swagger.annotations.ApiModel; |
| | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "使用时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(updateStrategy = FieldStrategy.IGNORED) |
| | | private LocalDateTime useTime; |
| | | |
| | | @ApiModelProperty(value = "状态(1=未使用,2=已使用,3=已过期)") |
| New file |
| | |
| | | package com.xiaopeng.api.model.account; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.xiaopeng.common.core.web.domain.BaseModel; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @TableName("xp_user_route_plan_rule") |
| | | public class XpUserRoutePlanRule extends BaseModel { |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.NONE) |
| | | private Long id; |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @TableField("user_id") |
| | | private String userId; |
| | | /** |
| | | * 路线规划规则 0:速度优先(只返回一条路线),此路线不一定距离最短 1:费用优先(只返回一条路线),不走收费路段,且耗时最少的路线 2:常规最快(只返回一条路线)综合距离/耗时规划结果 32:默认,高德推荐,同高德地图APP默认 33:躲避拥堵 34:高速优先 35:不走高速 36:少收费 37:大路优先 38:速度最快 39:躲避拥堵+高速优先 40:躲避拥堵+不走高速 41:躲避拥堵+少收费 42:少收费+不走高速 43:躲避拥堵+少收费+不走高速 44:与躲避拥堵+大路优先 45:躲避拥堵+速度最快 |
| | | */ |
| | | @TableField("route_plan_rule") |
| | | private String routePlanRule; |
| | | } |
| | |
| | | package com.xiaopeng.api.model.order; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.xiaopeng.common.core.enums.OrderStatusEnum; |
| | | import com.xiaopeng.common.core.web.domain.BaseModel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | @ApiModelProperty(value = "优惠券id") |
| | | private Long couponId; |
| | | |
| | | /** |
| | | * {@link OrderStatusEnum } |
| | | */ |
| | | @ApiModelProperty(value = "状态 0=已取消,1=待接单,2=待出发,3=接驾中,4=待客上车,5=乘客已上车,6=服务中,7=待客下车,8=待付款,9=待评价,10=已完成") |
| | | private Integer status; |
| | | |
| | |
| | | |
| | | import com.xiaopeng.api.vo.order.XpPricingCardVo; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | @lombok.Data |
| | | @ApiModel(description = "线路和运费") |
| | |
| | | |
| | | |
| | | private XpPricingCardVo xpPricingCard; |
| | | /** |
| | | * 导航策略ID |
| | | */ |
| | | private String routePlan; |
| | | |
| | | |
| | | @ApiModelProperty(value = "导航策略偏好(1是 2否)") |
| | | private Integer preference=2; |
| | | |
| | | @ApiModelProperty(value = "导航策略名称") |
| | | private String routePlanName; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | com.xiaopeng.api.factory.operation.XpRoutePlanClientFallbackFactory |
| | | com.xiaopeng.api.factory.order.XpTestOrderClientFallbackFactory |
| | | com.xiaopeng.api.factory.map.AdcFencePushClientFallbackFactory |
| | | com.xiaopeng.api.factory.account.UserRoutePlanRuleClientFallbackFactory |
| | |
| | | log.info("车辆故障,车辆状态修改0 {}", vehicle.getPlateNumber()); |
| | | } |
| | | }else { |
| | | //正常订单 |
| | | //正常订单 车辆故障 |
| | | /* |
| | | 1.将订单信息车辆的 查询出来 设置故障状态 |
| | | 2.解除用户和车的关系 |
| | | 3.如果是 接驾中的车需要重新派车 |
| | | 4.如果是行驶中的车需要将订单结束 计算金额 |
| | | */ |
| | | XpOrder xpOrder = xpOrderClient.queryOrderById(Long.parseLong(orderId)).getData(); |
| | | vehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | if (vehicle != null) { |
| | |
| | | cancelTaxiPassengerVo.setAppId(appid); |
| | | userVehicleClient.cancelTaxiPassenger(cancelTaxiPassengerVo); |
| | | } |
| | | //status 状态 0=已取消,1=待接单,2=待出发,3=接驾中,4=待客上车,5=乘客已上车,6=服务中,7=待客下车,8=待付款,9=待评价,10=已完成 |
| | | List<Integer> notDrive = new ArrayList<Integer>(){{ //未行驶的情况下订单故障状态点 |
| | | add(OrderStatusEnum.READY_DEPART.getCode());add(OrderStatusEnum.PICK_UP.getCode()); |
| | | add(OrderStatusEnum.PICK_UP_GUESTS.getCode());add(OrderStatusEnum.PASSENGER_BOARDED.getCode()); |
| | | }}; |
| | | |
| | | if(xpOrder.getStatus().equals(OrderStatusEnum.IN_SERVICE.getCode()) |
| | | || xpOrder.getStatus().equals(OrderStatusEnum.SEE_OFF_GUESTS.getCode()) ){ //6=服务中 7=待客下车 在行驶中 修改订单-已完成 需要处理订单金额 |
| | | //单独写个修改订单的方法。 |
| | | // ff |
| | | xpOrderClient.carAbnormalUpdateOrderStatus(Long.parseLong(orderId)); |
| | | |
| | | }else if(notDrive.contains(xpOrder.getStatus())){//在接驾中 车辆出现故障 重新派单 |
| | | |
| | | // TODO 重新派单 |
| | | ReassignOrderDTO reassignOrderDTO = new ReassignOrderDTO(); |
| | | reassignOrderDTO.setUid(xpOrder.getAppUserId().toString()); |
| | |
| | | reassignOrderDTO.setLongitude(longitude); |
| | | reassignOrderDTO.setLatitude(latitude); |
| | | reassignOrderClient.reassignOrder(reassignOrderDTO); |
| | | } |
| | | } |
| | | //添加车辆异常任务和发送消息 |
| | | xpTaskClient.saveVehicleAccidentError(vehicle.getId()); |
| | |
| | | if(xpOrder.getStatus() == 0 || xpOrder.getStatus() >= 8){ |
| | | return; |
| | | } |
| | | if(xpOrder.getStatus() > 5 && xpOrder.getStatus() < 8){ |
| | | //行程中取消订单,按照行程结束处理 |
| | | |
| | | List<Integer> xczqx = new ArrayList<Integer>(){{ |
| | | add(OrderStatusEnum.IN_SERVICE.getCode());//服务中 |
| | | add(OrderStatusEnum.SEE_OFF_GUESTS.getCode());//SEE_OFF_GUESTS |
| | | }}; |
| | | if(xczqx.contains(xpOrder.getStatus())){//行程中取消订单,按照行程结束处理 |
| | | buildPushOrderStatus(cmd, orderId, OrderStatusEnum.SEE_OFF_GUESTS, sequence); |
| | | xpOrderClient.updateOrderStatus(Long.parseLong(orderId), OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | redisService.setCacheObject("ORDER_STATUS:" + orderId, OrderStatusEnum.SEE_OFF_GUESTS.getCode(), 24L, TimeUnit.HOURS); |
| | |
| | | @PostMapping("/base/v1/mini-program/navigation/route-and-fare") |
| | | @ApiOperation(value = "导航-获取路线和费用", tags = {"小程序-获取路线和费用"}, response = RouteAndFareVo.class) |
| | | @XpClientCheck(checkToken = false, checkOtpToken = true) |
| | | public R<RouteAndFareVo> getRouteAndFare(@RequestBody @Valid RouteAndFareDto routeAndFareDto, HttpServletRequest request) { |
| | | public R<List<RouteAndFareVo>> getRouteAndFare(@RequestBody @Valid RouteAndFareDto routeAndFareDto, HttpServletRequest request) { |
| | | // uid已通过拦截器otp校验,可以直接使用 |
| | | String uid = request.getHeader("XP-Uid"); |
| | | return R.ok(xpPricingService.getRouteAndFare(routeAndFareDto, uid)); |
| | |
| | | * @param userId 用户id |
| | | * @return |
| | | */ |
| | | RouteAndFareVo getRouteAndFare(RouteAndFareDto routeAndFareDto, String userId); |
| | | List<RouteAndFareVo> getRouteAndFare(RouteAndFareDto routeAndFareDto, String userId); |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | public RouteAndFareVo getRouteAndFare(RouteAndFareDto routeAndFareDto, String userId) { |
| | | public List<RouteAndFareVo> getRouteAndFare(RouteAndFareDto routeAndFareDto, String userId) { |
| | | // // 判断是否5分钟内进行了查询 相同站点的起始点 并且是同时段 |
| | | // String key = "xp-map-query-" + routeAndFareDto.getOpenCityId() |
| | | // + "-" + routeAndFareDto.getOrigin().getLongitude() + "-" + routeAndFareDto.getOrigin().getLatitude() |
| | |
| | | // RouteAndFareVo RouteAndFareVo = JSONObject.parseObject(jsonStr, RouteAndFareVo.class); |
| | | // return (RouteAndFareVo); |
| | | // } |
| | | |
| | | ArrayList<RouteAndFareVo> routeAndFareVos = new ArrayList<>(3); |
| | | |
| | | // 1. 基础数据查询 |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(routeAndFareDto.getOrigin().getLongitude().toString(), routeAndFareDto.getOrigin().getLatitude().toString()); |
| | |
| | | } |
| | | XpOpenCity xpOpenCity = openCities; |
| | | routeAndFareDto.setOpenCityId(xpOpenCity.getId()); |
| | | XpRoutePlan xpRoutePlan = xpRoutePlanMapper.selectOne(new LambdaQueryWrapper<XpRoutePlan>().eq(XpRoutePlan::getAuditStatus, 2).eq(XpRoutePlan::getCityCode, cityCode)); |
| | | 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(xpRoutePlan.getRoutePlanRule()); |
| | | routeAndFareDto.setRoutePlanRule(routePlan.getRoutePlanRule()); |
| | | } |
| | | Object userPref = redisService.getCacheObject(CacheConstants.USER_ROUTE_PREFERENCE + userId); |
| | | if (userPref != null) { |
| | |
| | | // 算距离 |
| | | R<RouteVo> distanceAndDuration = xpMapClient.getDistanceAndDuration(routeAndFareDto); |
| | | if (distanceAndDuration.getCode() != 200) { |
| | | throw new ServiceException("获取导肮信息失败", I18nKeyConstant.PATH_NOT_FOUND); |
| | | // throw new ServiceException("获取导肮信息失败", I18nKeyConstant.PATH_NOT_FOUND); |
| | | continue; |
| | | } |
| | | |
| | | |
| | |
| | | // redisService.setCacheObject(key, voJsonStr, 5l, TimeUnit.MINUTES); |
| | | //缓存导航数据,用于下单后推送导航给车端和乘客端 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_END_DATA:" + userId, JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | return routeAndFareVo; |
| | | |
| | | if(cacheObject!=null){ |
| | | if (cacheObject.toString().equals(routePlan.getRoutePlanRule().toString())) { |
| | | routeAndFareVo.setPreference(1); |
| | | } |
| | | } |
| | | routeAndFareVo.setRoutePlanName(routePlan.getPlanName()); |
| | | |
| | | routeAndFareVos.add(routeAndFareVo); |
| | | |
| | | |
| | | } |
| | | if(routeAndFareVos.isEmpty()){ |
| | | throw new ServiceException("获取导肮信息失败", I18nKeyConstant.PATH_NOT_FOUND); |
| | | } |
| | | |
| | | |
| | | return routeAndFareVos; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.xiaopeng.api.dto.account.UseUserCouponDto; |
| | | import com.xiaopeng.api.dto.automaticPilot.PushOrderDto; |
| | | import com.xiaopeng.api.dto.map.RouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.dto.operation.VehiclePositionByVinDto; |
| | | import com.xiaopeng.api.dto.pushMessage.SendMessageDTO; |
| | | import com.xiaopeng.api.feignClient.account.XpAppUserCouponClient; |
| | | import com.xiaopeng.api.feignClient.automaticPilot.OrderMissionClient; |
| | | import com.xiaopeng.api.feignClient.map.XpMapClient; |
| | | import com.xiaopeng.api.feignClient.order.XpCruiseOrderClient; |
| | |
| | | import com.xiaopeng.common.core.constant.CacheConstants; |
| | | import com.xiaopeng.common.core.constant.Constants; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.enums.OrderStatusEnum; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.operation.mapper.XpElectronicFenceMapper; |
| | | import com.xiaopeng.operation.service.IXpElectronicFenceAreaService; |
| | |
| | | |
| | | @Resource |
| | | private UidVinPriorityMatcher uidVinPriorityMatcher; |
| | | @Resource |
| | | private XpAppUserCouponClient xpAppUserCouponClient; |
| | | |
| | | |
| | | // 自定义线程池 |
| | |
| | | } |
| | | XpOrder data = xpOrderR.getData(); |
| | | XpTradingStrategy xpTradingStrategy = xpTradingStrategyService.getOne(null); |
| | | boolean orderCarStatus = false;//未派到车 默认 |
| | | //循环找车 |
| | | for (int i = 0; i < count; i++) { |
| | | log.info("进入找车环节"); |
| | | List<VehiclePosition> positionList = vehiclePositionService.findAvailableVehiclesNearby(longitude, latitude, xpTradingStrategy.getOnePushDistance(), xpTradingStrategy.getSimultaneouslyOrderCount()); |
| | |
| | | // 调用推送服务 orderId + carVin |
| | | orderMissionClient.pushOrder(pushOrderDto); |
| | | |
| | | //接单成功 将 修改 订单的状态=1 ( 状态 0=已取消,1=待接单,2=待出发,3=接驾中,4=待客上车,5=乘客已上车,6=服务中,7=待客下车,8=待付款,9=待评价,10=已完成) |
| | | orderCarStatus = true; |
| | | xpOrderClient.updateOrderStatus(data.getId(), OrderStatusEnum.PENDING_ORDER.getCode()); |
| | | redisService.setCacheObject("ORDER_STATUS:" + data.getId(), OrderStatusEnum.PENDING_ORDER.getCode(), 24L, TimeUnit.HOURS); |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } finally { |
| | | lock.unlock(); |
| | | } |
| | | } |
| | | //未找到车 系统强制取消订单,状态流转至“系统自动取消”。 自动退回优惠卷 |
| | | if(!orderCarStatus){ |
| | | xpOrderClient.updateOrderStatus(data.getId(),OrderStatusEnum.CANCELED.getCode()); |
| | | redisService.setCacheObject("ORDER_STATUS:" + data.getId(), OrderStatusEnum.CANCELED.getCode(), 24L, TimeUnit.HOURS); |
| | | //有优惠卷 自动退回优惠卷 |
| | | if(data.getCouponId() != null ){ |
| | | UseUserCouponDto useUserCouponDto = new UseUserCouponDto(); |
| | | useUserCouponDto.setUserCouponId(data.getCouponId() ); |
| | | xpAppUserCouponClient.backUserCoupon(useUserCouponDto); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 行驶中车辆异常,订单状态修改- 修改状态=7 再修改 金额-再将状态修改成8 |
| | | */ |
| | | @ApiOperation(value = "行驶中车辆异常,订单状态修改- 修改状态=7 再修改 金额-再将状态修改成8") |
| | | @PostMapping("/logan/inner/v1/order/carAbnormalUpdateOrderStatus") |
| | | public R<String> carAbnormalUpdateOrderStatus(@RequestParam Long orderId ) { |
| | | // Integer status = OrderStatusEnum.SEE_OFF_GUESTS.getCode(); |
| | | return xpOrderService.carAbnormalUpdateOrderStatus(orderId); |
| | | } |
| | | |
| | | /** |
| | | * 业务流程-通过订单id查询车辆信息 |
| | | */ |
| | | @ApiOperation(value = "通过订单id查询车辆信息", tags = {"小程序-业务流程"}) |
| | |
| | | */ |
| | | R<String> updateOrderStatus(Long orderId, Integer status); |
| | | |
| | | /** |
| | | * 行驶中车辆异常,订单状态修改- 修改状态=7 再修改 金额-再将状态修改成8 |
| | | */ |
| | | R<String> carAbnormalUpdateOrderStatus(Long orderId); |
| | | |
| | | Boolean endTrip(Long orderId, String uid); |
| | | |
| | | |
| | |
| | | // 查询车辆 |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | switch (status) { |
| | | case 0://去掉订单 优惠卷需要返回 |
| | | |
| | | break; |
| | | case 4: |
| | | // 查询起点点位 |
| | | Long startPointId = xpOrder.getStartPointId(); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 行驶中车辆异常,订单状态修改- 修改状态=7 再修改 金额-再将状态修改成8 |
| | | */ |
| | | @Override |
| | | public R<String> carAbnormalUpdateOrderStatus(Long orderId){ |
| | | XpOrder xpOrder = this.getById(orderId); |
| | | if (Objects.isNull(xpOrder)) { |
| | | return R.fail("订单不存在"); |
| | | } |
| | | if (xpOrder.getStatus() == 0) { |
| | | return R.fail("订单已取消"); |
| | | } |
| | | if(xpOrder.getStatus() >= 8){ |
| | | return R.fail("订单已结束"); |
| | | } |
| | | // 查询车辆 |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | Long appUserId = xpOrder.getAppUserId(); |
| | | |
| | | xpOrder.setGetoffTime(LocalDateTime.now()); |
| | | // 解析下车地点 |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | if(Objects.nonNull(vehiclePosition)){ |
| | | GeoJsonPoint point = vehiclePosition.getPoint(); |
| | | if(Objects.nonNull(point)){ |
| | | double x = point.getX(); |
| | | double y = point.getY(); |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(String.valueOf(x), String.valueOf(y)); |
| | | xpOrder.setGetoffAddress(geocode.get("address")); |
| | | } |
| | | } |
| | | //计算行驶总距离和时长 |
| | | List<OrderTrajectory> orderTrajectoryList = mongoTemplate.find(new Query().addCriteria(Criteria.where("orderId").is(xpOrder.getId())), OrderTrajectory.class); |
| | | Double reduce = orderTrajectoryList.stream().map(OrderTrajectory::getDistance).reduce(0.0, Double::sum); |
| | | xpOrder.setMileageKilometers(new BigDecimal(reduce).divide(new BigDecimal(1000)).setScale(4, RoundingMode.HALF_EVEN).doubleValue()); |
| | | long duration = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) - xpOrder.getTripBegin().toEpochSecond(ZoneOffset.of("+8")); |
| | | xpOrder.setDuration(new BigDecimal(duration).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | |
| | | xpOrder.setStatus(OrderStatusEnum.SEE_OFF_GUESTS.getCode());//待客下车 |
| | | xpOrder.setAppUserId(null); |
| | | this.updateById(xpOrder); |
| | | //结束行程,修改状态和计算费用 |
| | | this.endTrip(xpOrder.getId(),appUserId.toString()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Boolean endTrip(Long orderId, String uid) { |
| | | List<XpOrderDetail> xpOrderDetails = new ArrayList<>(); |