| | |
| | | package com.xiaopeng.order.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | import com.xiaopeng.order.job.jobs.OrderCancelJob; |
| | | import com.xiaopeng.order.mangodb.model.OrderTrajectory; |
| | | import com.xiaopeng.order.mangodb.service.OrderTrajectoryService; |
| | | import com.xiaopeng.order.mapper.XpCruiseOrderMapper; |
| | | import com.xiaopeng.order.mapper.XpOrderDetailMapper; |
| | | import com.xiaopeng.order.mapper.XpOrderMapper; |
| | | import com.xiaopeng.order.model.dto.XpOrderCommentDto; |
| | |
| | | private final XpPushMessageClient xpPushMessageClient; |
| | | private final OrderMissionClient orderMissionClient; |
| | | private final XpOrderDetailMapper xpOrderDetailMapper; |
| | | private final XpCruiseOrderMapper xpCruiseOrderMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | |
| | | // 下发命令 |
| | | if(order.getStatus()>1){ |
| | | PushOrderDto pushOrderDto = new PushOrderDto(); |
| | | pushOrderDto.setOrderId(order.getId()); |
| | | pushOrderDto.setOrderId(order.getId().toString()); |
| | | pushOrderDto.setVin(xpVehicle.getVehicleVin()); |
| | | pushOrderDto.setOperation_type(OrderOperationType.VEHICLE_CANCEL_ORDER); |
| | | orderMissionClient.cancelOrder(pushOrderDto); |
| | |
| | | // 下发命令 |
| | | if(order.getStatus()>1){ |
| | | PushOrderDto pushOrderDto = new PushOrderDto(); |
| | | pushOrderDto.setOrderId(order.getId()); |
| | | pushOrderDto.setOrderId(order.getId().toString()); |
| | | pushOrderDto.setVin(xpVehicle.getVehicleVin()); |
| | | pushOrderDto.setOperation_type(OrderOperationType.CLOUD_CANCEL_ORDER); |
| | | orderMissionClient.cancelOrder(pushOrderDto); |
| | |
| | | // TODO 加配置文件取 |
| | | cancelTaxiPassengerVo.setAppId(""); |
| | | userVehicleClient.cancelTaxiPassenger(cancelTaxiPassengerVo); |
| | | |
| | | // 修改车辆接单状态 |
| | | vehicle.setState(0); |
| | | xpVehicleClient.updateVehicleById(vehicle); |
| | | } |
| | | |
| | | |
| | | |
| | | // 根据订单所属开通城市id 查询定价 |
| | | R<XpPricing> pricingByCityId = xpPricingClient.getPricingByCid(order.getCityId()); |
| | | XpPricing pricing = pricingByCityId.getData(); |
| | |
| | | useUserCouponDto.setUserCouponId(order.getCouponId()); |
| | | xpAppUserCouponClient.useUserCoupon(useUserCouponDto); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // 结束后的车辆操作 |
| | | if(vehicle!=null){ |
| | | // 生成新的巡游单子 回到最新巡游的初始起点位置 |
| | | XpCruiseOrder xpCruiseOrders = xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 2).orderByDesc(BaseModel::getCreateTime).last("limit 1")); XpCruiseOrder xpCruiseOrder = new XpCruiseOrder(); |
| | | xpCruiseOrder.setVehicleId(vehicle.getId()); |
| | | xpCruiseOrder.setVehicleVin(vehicle.getVehicleVin()); |
| | | xpCruiseOrder.setOrderType(2); |
| | | // 返程起点是当前正常订单的终点 |
| | | xpCruiseOrder.setStartPointId(order.getEndPointId()); |
| | | xpCruiseOrder.setStartPointName(order.getEndPointName()); |
| | | xpCruiseOrder.setStartLon(order.getEndLon()); |
| | | xpCruiseOrder.setStartLat(order.getEndLat()); |
| | | |
| | | xpCruiseOrder.setEndPointId(xpCruiseOrders.getStartPointId()); |
| | | xpCruiseOrder.setEndPointName(xpCruiseOrders.getStartPointName()); |
| | | xpCruiseOrder.setEndLon(xpCruiseOrders.getStartLon()); |
| | | xpCruiseOrder.setEndLat(xpCruiseOrders.getStartLat()); |
| | | |
| | | xpCruiseOrder.setStatus(1); |
| | | xpCruiseOrder.setLastOrderId(xpCruiseOrders.getId()); |
| | | xpCruiseOrder.setCreateTime(LocalDateTime.now()); |
| | | xpCruiseOrder.setId("XU"+ IdUtil.fastUUID()); |
| | | xpCruiseOrderMapper.insert(xpCruiseOrder); |
| | | |
| | | //下发命令 |
| | | orderMissionClient.pushOrder(new PushOrderDto(vehicle.getVehicleVin(),xpCruiseOrder.getId(),null)); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | return null; |
| | | } |
| | | BeanUtils.copyProperties(xpOrder, xpOrderDetailVO); |
| | | |
| | | R<XpPoint> xpPointR = xpPointClient.queryById(xpOrder.getStartPointId()); |
| | | if (xpPointR.getCode() == R.SUCCESS) { |
| | | XpPoint startPoint = xpPointR.getData(); |
| | | xpOrderDetailVO.setStartParkingTimeLimit(startPoint.getParkingTimeLimit()); |
| | | } |
| | | |
| | | R<XpPoint> xpPointR1 = xpPointClient.queryById(xpOrder.getEndPointId()); |
| | | if (xpPointR1.getCode() == R.SUCCESS) { |
| | | XpPoint endPoint = xpPointR1.getData(); |
| | | xpOrderDetailVO.setEndParkingTimeLimit(endPoint.getParkingTimeLimit()); |
| | | } |
| | | // 算时间 |
| | | if (xpOrder.getStatus() == 1) { |
| | | R<Integer> r = xpPricingClient.getWaitTime(new LonLatDto(xpOrder.getStartLon(), xpOrder.getStartLat())); |