From 8ad3e49abf615d868460e0fab004c365148b90cb Mon Sep 17 00:00:00 2001
From: zhuml4 <zhuml4@xiaopeng.com>
Date: 星期六, 07 三月 2026 21:01:53 +0800
Subject: [PATCH] fix:用户中心返回

---
 xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java |  192 +++++++++++++++++++++--------------------------
 1 files changed, 86 insertions(+), 106 deletions(-)

diff --git a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
index f9921f2..32b7c88 100644
--- a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
+++ b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
@@ -1,18 +1,19 @@
 package com.xiaopeng.order.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.ImmutableMap;
 import com.xiaopeng.api.dto.account.GetUserCouponDto;
+import com.xiaopeng.api.dto.account.UcUserInfo;
 import com.xiaopeng.api.dto.account.UseUserCouponDto;
-import com.xiaopeng.api.dto.account.UserResourcesDto;
 import com.xiaopeng.api.dto.automaticPilot.PushOrderDto;
 import com.xiaopeng.api.dto.operation.LonLatDto;
 import com.xiaopeng.api.dto.order.GetOrderNumDto;
@@ -25,7 +26,6 @@
 import com.xiaopeng.api.dto.statistics.StatisticsQueryDTO;
 import com.xiaopeng.api.dto.vehicleConvoy.BaseVehicleUserDto;
 import com.xiaopeng.api.feignClient.account.UserResourcesClient;
-import com.xiaopeng.api.feignClient.account.XpAppUserClient;
 import com.xiaopeng.api.feignClient.account.XpAppUserCouponClient;
 import com.xiaopeng.api.feignClient.automaticPilot.OrderMissionClient;
 import com.xiaopeng.api.feignClient.maintenance.XpTaskRuleClient;
@@ -33,20 +33,17 @@
 import com.xiaopeng.api.feignClient.operation.XpPointClient;
 import com.xiaopeng.api.feignClient.operation.XpPricingClient;
 import com.xiaopeng.api.feignClient.operation.XpSystemSettingClient;
-import com.xiaopeng.api.feignClient.order.XpCruiseOrderClient;
 import com.xiaopeng.api.feignClient.pushMessage.XpPushMessageClient;
 import com.xiaopeng.api.feignClient.vehicleConvoy.UserVehicleClient;
 import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetClient;
 import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetVehicleClient;
 import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient;
-import com.xiaopeng.api.model.account.XpAppUser;
 import com.xiaopeng.api.model.maintenance.XpTaskRule;
 import com.xiaopeng.api.model.operation.*;
 import com.xiaopeng.api.model.order.*;
 import com.xiaopeng.api.model.vehicleConvoy.XpFleet;
 import com.xiaopeng.api.model.vehicleConvoy.XpVehicle;
 import com.xiaopeng.api.vo.OrderType;
-import com.xiaopeng.api.vo.account.GetUserListByUidsVo;
 import com.xiaopeng.api.vo.account.UserCouponVo;
 import com.xiaopeng.api.vo.automaticPilot.VehiclePosition;
 import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudOrderOperation.OrderOperationType;
@@ -89,13 +86,10 @@
 import com.xiaopeng.order.service.IXpOrderReassignService;
 import com.xiaopeng.order.service.IXpOrderService;
 import com.xiaopeng.order.utils.TaxiPricingDemoService;
-import com.xiaopeng.order.utils.TrajectoryGenerator;
 import com.xiaopeng.order.utils.holiday.HolidayUtil;
 import com.xiaopeng.order.vo.OrderDetailVo;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType;
-import org.apache.shardingsphere.transaction.core.TransactionType;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -103,7 +97,6 @@
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -222,13 +215,13 @@
         }
 
         // 4. 批量查询关联数据
-        JSONObject jsonObject = batchGetUsers(userIds);
+        Map<String, UcUserInfo> userInfoMap = batchGetUsers(userIds);
         Map<Long, XpVehicle> vehicleMap = batchGetVehicles(vehicleIds);
         Map<Long, XpFleet> fleetMap = batchGetFleets(fleetIds);
 
         // 5. 组装 VO
         List<XpOrderPageVO> voList = pageResult.getRecords().stream()
-                .map(order -> convertToPageVO(order, jsonObject, vehicleMap, fleetMap))
+                .map(order -> convertToPageVO(order, userInfoMap, vehicleMap, fleetMap))
                 .collect(Collectors.toList());
 
         // 6. 返回分页结果
@@ -251,11 +244,13 @@
 
         // 3. 获取用户信息
         if (Objects.nonNull(order.getAppUserId())) {
-            JSONObject jsonObject = batchGetUsers(Collections.singleton(order.getAppUserId()));
-            JSONObject userInfo = jsonObject.getJSONObject(order.getAppUserId().toString());
-            if (Objects.nonNull(userInfo)) {
-                vo.setNickName(userInfo.getString("nickName"));
-                vo.setPhoneNumber(userInfo.getString("mobile"));
+            Map<String, UcUserInfo> userInfoMap = batchGetUsers(Collections.singleton(order.getAppUserId()));
+            if (CollUtil.isNotEmpty(userInfoMap)) {
+                UcUserInfo userInfo = userInfoMap.get(order.getAppUserId());
+                if (Objects.nonNull(userInfo)) {
+                    vo.setNickName(userInfo.getNickName());
+                    vo.setPhoneNumber(userInfo.getMobile());
+                }
             }
         }
 
@@ -330,13 +325,13 @@
         }
 
         // 4. 批量查询关联数据
-        JSONObject jsonObject = batchGetUsers(userIds);
+        Map<String, UcUserInfo> userInfoMap = batchGetUsers(userIds);
         Map<Long, XpVehicle> vehicleMap = batchGetVehicles(vehicleIds);
         Map<Long, XpFleet> fleetMap = batchGetFleets(fleetIds);
 
         // 5. 组装 VO
         return orderList.stream()
-                .map(order -> convertToPageVO(order, jsonObject, vehicleMap, fleetMap))
+                .map(order -> convertToPageVO(order, userInfoMap, vehicleMap, fleetMap))
                 .collect(Collectors.toList());
     }
 
@@ -365,22 +360,11 @@
     /**
      * 批量获取用户信息
      */
-    private JSONObject batchGetUsers(Set<Long> userIds) {
+    private Map<String, UcUserInfo> batchGetUsers(Set<Long> userIds) {
         if (CollectionUtils.isEmpty(userIds)) {
-            return new JSONObject();
+            return new HashMap<>();
         }
-        try {
-            GetUserListByUidsVo getUserListByUidsVo = new GetUserListByUidsVo();
-            getUserListByUidsVo.setUids(new ArrayList<>(userIds));
-            getUserListByUidsVo.setGetPreCarOwner(Boolean.TRUE);
-            UserResourcesDto userListByUids = userResourcesClient.getUserListByUids(getUserListByUidsVo);
-            if (userListByUids.getCode().equals(HttpStatus.SUCCESS)) {
-                return JSONObject.parseObject(userListByUids.getData().toString());
-            }
-        } catch (Exception e) {
-            log.error("批量获取用户信息失败: {}", e.getMessage());
-        }
-        return new JSONObject();
+        return userResourcesClient.getUserListByUids(new ArrayList<>(userIds), false);
     }
 
     /**
@@ -464,7 +448,7 @@
      * 转换为分页列表 VO
      */
     private XpOrderPageVO convertToPageVO(XpOrder order,
-                                          JSONObject jsonObject,
+                                          Map<String, UcUserInfo> userInfoMap,
                                           Map<Long, XpVehicle> vehicleMap,
                                           Map<Long, XpFleet> fleetMap) {
         XpOrderPageVO vo = new XpOrderPageVO();
@@ -479,10 +463,10 @@
         vo.setStatus(order.getStatus());
 
         // 用户信息
-        if (Objects.nonNull(order.getAppUserId()) && jsonObject.containsKey(order.getAppUserId().toString())) {
-            JSONObject userInfo = jsonObject.getJSONObject(order.getAppUserId().toString());
-            vo.setNickName(userInfo.getString("nickName"));
-            vo.setPhoneNumber(userInfo.getString("mobile"));
+        if (Objects.nonNull(order.getAppUserId()) && userInfoMap.containsKey(order.getAppUserId().toString())) {
+            UcUserInfo userInfo = userInfoMap.get(order.getAppUserId().toString());
+            vo.setNickName(userInfo.getNickName());
+            vo.setPhoneNumber(userInfo.getMobile());
         }
 
         // 车辆信息
@@ -862,13 +846,13 @@
             // 保留2位数小数
             Double distance = datum.getDistance();
             datum.setDistance(BigDecimal.valueOf(distance).setScale(2, RoundingMode.HALF_UP).doubleValue());
-            xpOrders.stream().filter(e->e.getStartPointId().equals(datum.getId())).findFirst().ifPresent(
-                    order->{
+            xpOrders.stream().filter(e -> e.getStartPointId().equals(datum.getId())).findFirst().ifPresent(
+                    order -> {
                         datum.setNum(order.getNum());
                     }
             );
         }
-        data =  data.stream().sorted(Comparator.comparingInt(XpHistoryStartPointsVo::getNum).reversed()).collect(Collectors.toList());
+        data = data.stream().sorted(Comparator.comparingInt(XpHistoryStartPointsVo::getNum).reversed()).collect(Collectors.toList());
 
         return data;
 
@@ -893,13 +877,13 @@
             // 保留2位数小数
             Double distance = datum.getDistance();
             datum.setDistance(BigDecimal.valueOf(distance).setScale(2, RoundingMode.HALF_UP).doubleValue());
-            xpOrders.stream().filter(e->e.getEndPointId().equals(datum.getId())).findFirst().ifPresent(
-                    order->{
+            xpOrders.stream().filter(e -> e.getEndPointId().equals(datum.getId())).findFirst().ifPresent(
+                    order -> {
                         datum.setNum(order.getNum());
                     }
             );
         }
-        data =  data.stream().sorted(Comparator.comparingInt(XpHistoryEndPointsVo::getNum).reversed()).collect(Collectors.toList());
+        data = data.stream().sorted(Comparator.comparingInt(XpHistoryEndPointsVo::getNum).reversed()).collect(Collectors.toList());
 
         return data;
 
@@ -917,7 +901,7 @@
         Page<XpOrderHistoryListVO> page = new Page<>(query.getPageNum(), query.getPageSize());
         List<XpOrderHistoryListVO> list = this.baseMapper.getHistoryOrderList(page, query, Long.parseLong(uid));
         XpOrderHistoryVO xpOrderHistoryVO = new XpOrderHistoryVO();
-        if(list.isEmpty()){
+        if (list.isEmpty()) {
             return xpOrderHistoryVO;
         }
 
@@ -941,7 +925,7 @@
 
             for (XpOrderHistoryListVO xpOrderHistoryListVO : value) {
                 XpPoint xpPoint = pointList.stream().filter(e -> e.getId().equals(xpOrderHistoryListVO.getStartPointId())).findFirst().orElse(null);
-                if(xpPoint!=null){
+                if (xpPoint != null) {
                     xpOrderHistoryListVO.setStartPointName(xpPoint.getPointName());
                     xpOrderHistoryListVO.setStartLat(xpPoint.getPointLat());
                     xpOrderHistoryListVO.setStartLon(xpPoint.getPointLon());
@@ -950,7 +934,7 @@
                 }
 
                 xpPoint = pointList.stream().filter(e -> e.getId().equals(xpOrderHistoryListVO.getEndPointId())).findFirst().orElse(null);
-                if(xpPoint!=null){
+                if (xpPoint != null) {
                     xpOrderHistoryListVO.setEndPointName(xpPoint.getPointName());
                     xpOrderHistoryListVO.setEndLat(xpPoint.getPointLat());
                     xpOrderHistoryListVO.setEndLon(xpPoint.getPointLon());
@@ -980,15 +964,15 @@
     public void cancelOrder(Long orderId, String uid) {
         XpOrder order = this.getById(orderId);
         if (order == null) {
-            throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
+            throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
         }
         if (!order.getAppUserId().toString().equals(uid)) {
-            throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
+            throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
         }
         if (order.getStatus() > 5 || order.getStatus() < 1) {
-            throw new ServiceException("订单状态错误",I18nKeyConstant.ORDER_STATUS_ERROR);
+            throw new ServiceException("订单状态错误", I18nKeyConstant.ORDER_STATUS_ERROR);
         }
-        if(order.getStatus()==1){
+        if (order.getStatus() == 1) {
             order.setStatus(0);
             order.setAppUserId(null);
             baseMapper.updateById(order);
@@ -1002,7 +986,7 @@
         R<XpVehicle> xpVehicleR = xpVehicleClient.queryById(vehicleId);
         XpVehicle xpVehicle = xpVehicleR.getData();
         if (xpVehicle == null) {
-            throw new ServiceException("车辆不存在",I18nKeyConstant.VEHICLE_NOT_EXISTS);
+            throw new ServiceException("车辆不存在", I18nKeyConstant.VEHICLE_NOT_EXISTS);
         }
         cancelTaxiPassengerVo.setVin(xpVehicle.getVehicleVin());
         cancelTaxiPassengerVo.setUid(order.getAppUserId().toString());
@@ -1011,7 +995,7 @@
         cancelTaxiPassengerVo.setAppId("");
 
         BaseVehicleUserDto baseVehicleUserDto = userVehicleClient.cancelTaxiPassenger(cancelTaxiPassengerVo);
-        if (baseVehicleUserDto==null) {
+        if (baseVehicleUserDto == null) {
             // TODO 本地无法调通
 //            throw new RuntimeException("取消订单失败");
         }
@@ -1035,7 +1019,7 @@
         }
 
         // 下发命令
-        if(order.getStatus()>1){
+        if (order.getStatus() > 1) {
             PushOrderDto pushOrderDto = new PushOrderDto();
             pushOrderDto.setOrderId(order.getId().toString());
             pushOrderDto.setVin(xpVehicle.getVehicleVin());
@@ -1050,7 +1034,7 @@
     public void cancelOrder(String orderId) {
         XpOrder order = this.getById(orderId);
         if (order == null) {
-            throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
+            throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
         }
         order.setStatus(0);
         order.setAppUserId(null);
@@ -1084,7 +1068,7 @@
         log.info("订单取消消息推送完毕");
 
         // 下发命令
-        if(order.getStatus()>1){
+        if (order.getStatus() > 1) {
             PushOrderDto pushOrderDto = new PushOrderDto();
             pushOrderDto.setOrderId(order.getId().toString());
             pushOrderDto.setVin(xpVehicle.getVehicleVin());
@@ -1105,13 +1089,13 @@
     public void comment(XpOrderCommentDto dto, String uid) {
         XpOrder xpOrder = this.getById(dto.getOrderId());
         if (xpOrder == null) {
-            throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
+            throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
         }
         if (!xpOrder.getAppUserId().toString().equals(uid)) {
-            throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
+            throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
         }
         if (xpOrder.getStatus() != 9) {
-            throw new ServiceException("订单状态错误",I18nKeyConstant.ORDER_STATUS_ERROR);
+            throw new ServiceException("订单状态错误", I18nKeyConstant.ORDER_STATUS_ERROR);
         }
         xpOrder.setAppUserId(null);
         xpOrder.setStatus(10);
@@ -1232,7 +1216,6 @@
         }
 
 
-
         // 根据订单所属开通城市id 查询定价
         R<XpPricing> pricingByCityId = xpPricingClient.getPricingByCid(order.getCityId());
         XpPricing pricing = pricingByCityId.getData();
@@ -1251,13 +1234,13 @@
 //            TaxiPricingDemoService.GpsPoint point = new TaxiPricingDemoService.GpsPoint(trajectory.getDistance(), trajectory.getLocatetime());
 //            gpsPoints.add(point);
 //        }
-    // 补充临时轨迹数据
+        // 补充临时轨迹数据
         List<TaxiPricingDemoService.GpsPoint> gpsPoints = TaxiPricingDemoService.createMockGpsPoints(DateUtils.toDate(order.getCreateTime()));
 
 
         TaxiPricingDemoService.PricingConfig config = new TaxiPricingDemoService.PricingConfig();
         JSONArray startingFareJsonArray = JSONArray.parseArray(pricing.getStartingFareJson());
-        if(pricing.getPricingType()==1){
+        if (pricing.getPricingType() == 1) {
             JSONObject basicPricingJson = JSONObject.parseObject(pricing.getBasicPricingJson());
             config.peaks.add(new TaxiPricingDemoService.PricingRule("高峰期", basicPricingJson.getString("num21").split(" - ")[0], basicPricingJson.getString("num21").split(" - ")[1], Double.parseDouble(basicPricingJson.getString("num24")), Double.parseDouble(basicPricingJson.getString("num25")), Double.parseDouble(basicPricingJson.getString("num26")), Double.parseDouble(basicPricingJson.getString("num27")), Double.parseDouble(basicPricingJson.getString("num28"))));
             config.peaks.add(new TaxiPricingDemoService.PricingRule("高峰期", basicPricingJson.getString("num22").split(" - ")[0], basicPricingJson.getString("num22").split(" - ")[1], Double.parseDouble(basicPricingJson.getString("num24")), Double.parseDouble(basicPricingJson.getString("num25")), Double.parseDouble(basicPricingJson.getString("num26")), Double.parseDouble(basicPricingJson.getString("num27")), Double.parseDouble(basicPricingJson.getString("num28"))));
@@ -1292,7 +1275,7 @@
         System.err.println("--------------------------");
         System.err.println("应付总额: " + totalAmount + " 元");
         BigDecimal startMoney = BigDecimal.ZERO;
-         // 默认费率1
+        // 默认费率1
         double priceRate = 1;
         if (pricing.getIsDynamicPrice() == 1) {
             // 先判断是否已经调价过了
@@ -1440,11 +1423,11 @@
             xpOrderDetailMapper.insert(xpOrderDetail);
         }
         for (XpOrderDetail xpOrderDetail : xpOrderDetails) {
-            if (xpOrderDetail.getDetailType() == 1){
+            if (xpOrderDetail.getDetailType() == 1) {
                 order.setDurationType(xpOrderDetail.getType());
                 order.setDurationMoney(xpOrderDetail.getMoney());
                 order.setDuration(Double.parseDouble(xpOrderDetail.getDuration() + ""));
-            }else{
+            } else {
                 order.setLongDistanceType(order.getDurationType());
                 order.setLongDistance(xpOrderDetail.getMileage().doubleValue());
                 order.setLongDistancemoney(xpOrderDetail.getMoney());
@@ -1454,7 +1437,7 @@
 
         BigDecimal orderMoney = startMoney.add(mileageMoney).add(order.getDurationMoney() != null ? order.getDurationMoney() : BigDecimal.ZERO)
                 .add(order.getLongDistancemoney() != null ? order.getLongDistancemoney() : BigDecimal.ZERO)
-                .add(order.getWaitMoney()!=null?order.getWaitMoney():BigDecimal.ZERO);
+                .add(order.getWaitMoney() != null ? order.getWaitMoney() : BigDecimal.ZERO);
         order.setOrderMoney(orderMoney);
         order.setAppUserId(null);
         baseMapper.updateById(order);
@@ -1467,7 +1450,7 @@
             useUserCouponDto.setUserCouponId(order.getCouponId());
             xpAppUserCouponClient.useUserCoupon(useUserCouponDto);
         }
-       // 计算完价格后 挑选优惠券
+        // 计算完价格后 挑选优惠券
         GetUserCouponDto getUserCouponDto = new GetUserCouponDto();
         getUserCouponDto.setUserId(Long.valueOf(uid));
         getUserCouponDto.setTotalAmount(order.getOrderMoney().doubleValue());
@@ -1481,16 +1464,13 @@
         baseMapper.updateById(order);
 
 
-
-
-
         // 结束后的车辆操作
-        if(vehicle!=null){
+        if (vehicle != null) {
             // 修改车辆状态
             vehicle.setState(0);
 
 
-            addCruiseMission(vehicle,order);
+            addCruiseMission(vehicle, order);
 //            // 获取配置 根据配置判断是否该收车 如果是则找到收车点位进行收车操作
 //            R<XpTaskRule> xpTaskRuleR = xpTaskRuleClient.queryDetail();
 //            XpTaskRule xpTaskRule = xpTaskRuleR.getData();
@@ -1569,19 +1549,20 @@
 
     /**
      * 添加巡游任务下发命令
+     *
      * @param vehicle
      * @param order
      */
 
     public void addCruiseMission(XpVehicle vehicle, XpOrder order) {
 
-        if(vehicle.getState()!=0 || vehicle.getOperatingStatus()!=1){
+        if (vehicle.getState() != 0 || vehicle.getOperatingStatus() != 1) {
             return;
         }
 
         // 判断是否有计划
         R<XpCruisePlanVehicle> xpCruisePlanR = xpCruisePlanClient.getCruisePlan(vehicle.getId());
-        if(xpCruisePlanR==null || xpCruisePlanR.getData()==null){
+        if (xpCruisePlanR == null || xpCruisePlanR.getData() == null) {
             return;
         }
 
@@ -1591,11 +1572,11 @@
 
         // 生成新的巡游单子 回到最新巡游的初始起点位置
         XpCruiseOrder xpCruiseOrders = xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 2).orderByDesc(BaseModel::getCreateTime).last("limit 1"));
-        int temp=0;
-        if(xpCruiseOrders==null){
-            temp=1;
+        int temp = 0;
+        if (xpCruiseOrders == null) {
+            temp = 1;
             //特殊情况 可能没有产生终止的订单  (到站点就被正常接单了)所以找正常订单
-            xpCruiseOrders=xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 3).orderByDesc(BaseModel::getCreateTime).last("limit 1"));
+            xpCruiseOrders = xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 3).orderByDesc(BaseModel::getCreateTime).last("limit 1"));
         }
         XpCruiseOrder xpCruiseOrder = new XpCruiseOrder();
         xpCruiseOrder.setVehicleId(vehicle.getId());
@@ -1609,12 +1590,12 @@
         xpCruiseOrder.setStartLat(order.getEndLat());
 
         // 完成的直接走终点   终止的走起点
-        if(temp==0){
+        if (temp == 0) {
             xpCruiseOrder.setEndPointId(xpCruiseOrders.getStartPointId());
             xpCruiseOrder.setEndPointName(xpCruiseOrders.getStartPointName());
             xpCruiseOrder.setEndLon(xpCruiseOrders.getStartLon());
             xpCruiseOrder.setEndLat(xpCruiseOrders.getStartLat());
-        }else {
+        } else {
             xpCruiseOrder.setEndPointId(xpCruiseOrders.getEndPointId());
             xpCruiseOrder.setEndPointName(xpCruiseOrders.getEndPointName());
             xpCruiseOrder.setEndLon(xpCruiseOrders.getEndLon());
@@ -1625,7 +1606,7 @@
         xpCruiseOrder.setStatus(0);
         xpCruiseOrder.setLastOrderId(xpCruiseOrders.getId());
         xpCruiseOrder.setCreateTime(LocalDateTime.now());
-        xpCruiseOrder.setId("XU"+ IdUtil.fastUUID());
+        xpCruiseOrder.setId("XU" + IdUtil.fastUUID());
 
         // 判断当前时分秒是否大于收车时间
         LocalTime vehicleCollectionTime = xpTaskRule.getVehicleCollectionTime();
@@ -1876,14 +1857,14 @@
             detail.setTime(xpOrderDetail.getTime());
             detail.setMileage(xpOrderDetail.getMileage());
             detail.setDuration(xpOrderDetail.getDuration());
-            if (xpOrderDetail.getDetailType() == 1){
+            if (xpOrderDetail.getDetailType() == 1) {
                 start.add(detail);
-            }else{
+            } else {
                 mileage.add(detail);
             }
         }
         List<FareBreakdownDetailVo> duration = new ArrayList<>();
-        if (order.getDuration()!=null&&order.getDuration()>0){
+        if (order.getDuration() != null && order.getDuration() > 0) {
             FareBreakdownDetailVo durationDetail = new FareBreakdownDetailVo();
             durationDetail.setType(order.getDurationType());
             durationDetail.setDuration(order.getDuration());
@@ -1892,24 +1873,24 @@
         }
         List<FareBreakdownDetailVo> longDistance = new ArrayList<>();
 
-        if (order.getLongDistance()!=null&&order.getLongDistance()>0){
+        if (order.getLongDistance() != null && order.getLongDistance() > 0) {
             FareBreakdownDetailVo longDistanceDetail = new FareBreakdownDetailVo();
             longDistanceDetail.setType(order.getLongDistanceType());
             longDistanceDetail.setMileage(BigDecimal.valueOf(order.getLongDistance()));
             longDistanceDetail.setMoney(order.getLongDistancemoney());
             longDistance.add(longDistanceDetail);
         }
-        res.setStart( start);
-        res.setMileage( mileage);
-        res.setDuration( duration);
-        res.setLongDistance( longDistance);
+        res.setStart(start);
+        res.setMileage(mileage);
+        res.setDuration(duration);
+        res.setLongDistance(longDistance);
         res.setRedPacketMoney(order.getRedPacketMoney());
         res.setCouponMoney(order.getCouponMoney());
         res.setOrderMoney(order.getOrderMoney());
-        res.setKilometer(order.getMileageKilometers()==null?BigDecimal.ZERO:BigDecimal.valueOf(order.getMileageKilometers()));
+        res.setKilometer(order.getMileageKilometers() == null ? BigDecimal.ZERO : BigDecimal.valueOf(order.getMileageKilometers()));
         LocalDateTime createTime = order.getCreateTime();
         LocalDateTime tripEnd = order.getTripEnd();
-        if (tripEnd==null){
+        if (tripEnd == null) {
             tripEnd = LocalDateTime.now();
             order.setTripEnd(tripEnd);
             this.updateById(order);
@@ -2060,7 +2041,7 @@
         XpPricing pricing = pricingByCityId.getData();
         if (pricing == null) {
             throw new ServiceException("当前城市未配置定价规则", I18nKeyConstant.ORDER_PRICING_NOT_EXISTS);
-        }else{
+        } else {
             return R.ok(pricing.getPriceRule());
         }
     }
@@ -2072,15 +2053,15 @@
      * @param dto
      */
     @Override
-    @Transactional
-    @ShardingSphereTransactionType(TransactionType.BASE)
+//    @Transactional
+//    @ShardingSphereTransactionType(TransactionType.BASE)
     public void popOrder(PopOrderDto dto) {
         String orderType = dto.getOrderType();
         Long orderId = dto.getOrderId();
         //巡游单处理逻辑
-        if(OrderType.CRUISE_ORDER.equals(orderType)){
+        if (OrderType.CRUISE_ORDER.equals(orderType)) {
             XpCruiseOrder xpCruiseOrder = xpCruiseOrderMapper.selectById(orderId);
-            if(xpCruiseOrder!=null){
+            if (xpCruiseOrder != null) {
                 xpCruiseOrder.setStatus(1);
                 xpCruiseOrderMapper.updateById(xpCruiseOrder);
             }
@@ -2088,11 +2069,11 @@
 
         }
         //乘客单处理逻辑
-        if(OrderType.USER_ORDER.equals(orderType)){
+        if (OrderType.USER_ORDER.equals(orderType)) {
             XpOrder order = this.getById(orderId);
             Long appUserId = order.getAppUserId();
             //订单为待接单状态
-            if(order.getStatus() < 4){
+            if (order.getStatus() < 4) {
                 AddTaxiPassengerVo addTaxiPassengerVo = new AddTaxiPassengerVo();
                 order.setAcceptanceTime(LocalDateTime.now());
                 R<XpVehicle> byVehicleVin = xpVehicleClient.findByVehicleVin(dto.getXpVehicleVin());
@@ -2130,7 +2111,7 @@
                 userVehicleClient.addTaxiPassenger(addTaxiPassengerVo);
                 //推送乘客车辆到达预约点的导航数据
                 sendRoute(addTaxiPassengerVo.getUid(), orderId, "ORDER_NAVIGATION_START_DATA", dto.getXpVehicleVin());
-            }else{
+            } else {
                 //推送行起点到终点的驶轨迹给乘客端
                 sendRoute(appUserId.toString(), orderId, "ORDER_NAVIGATION_END_DATA", dto.getXpVehicleVin());
             }
@@ -2140,13 +2121,14 @@
 
     /**
      * 发送乘客导航路径数据
+     *
      * @param appUserId
      * @param keyStr
      */
-    public void sendRoute(String appUserId, Long orderId, String keyStr, String vin){
+    public void sendRoute(String appUserId, Long orderId, String keyStr, String vin) {
         VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class);
         Object cacheObject = redisService.getCacheObject(keyStr + ":" + appUserId);
-        if(null != cacheObject){
+        if (null != cacheObject) {
             RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class);
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("type", "ORDER_ROUTE");
@@ -2160,7 +2142,7 @@
             route.put("duration", routeVo.getDuration());
             route.put("routeID", routeVo.getRouteID());
 
-            List<JSONObject> collect = routeVo.getPolyline().stream().map(item->{
+            List<JSONObject> collect = routeVo.getPolyline().stream().map(item -> {
                 JSONObject point = new JSONObject();
                 point.put("latitude", item.getLatitude());
                 point.put("longitude", item.getLongitude());
@@ -2179,8 +2161,6 @@
     }
 
 
-
-
     /**
      * 获取当前用户正在执行的订单
      *
@@ -2190,7 +2170,7 @@
     @Override
     public XpOrderDetailVO getActiveOrder(String uid) {
         XpOrderDetailVO xpOrderDetailVO = new XpOrderDetailVO();
-        XpOrder xpOrder = this.baseMapper.selectOne(new LambdaQueryWrapper<XpOrder>().eq(XpOrder::getAppUserId, Long.parseLong(uid)).in(XpOrder::getStatus, Arrays.asList(1,2,3, 4, 5, 6, 7, 8)).orderByDesc(BaseModel::getCreateTime).last("LIMIT 1"));
+        XpOrder xpOrder = this.baseMapper.selectOne(new LambdaQueryWrapper<XpOrder>().eq(XpOrder::getAppUserId, Long.parseLong(uid)).in(XpOrder::getStatus, Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8)).orderByDesc(BaseModel::getCreateTime).last("LIMIT 1"));
         if (xpOrder == null) {
             return null;
         }
@@ -2218,7 +2198,7 @@
 
         }
 
-        if(xpOrder.getVehicleId()!=null){
+        if (xpOrder.getVehicleId() != null) {
             R<XpVehicle> xpVehicleR = xpVehicleClient.queryById(xpOrder.getVehicleId());
             xpOrderDetailVO.setPlateNumber(xpVehicleR.getData().getPlateNumber());
         }

--
Gitblit v1.7.1