From 87735379c4024b064aed0419e9fb57bbc10ca5c3 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 08 五月 2026 09:02:03 +0800
Subject: [PATCH] 修改电话号码脱敏功能

---
 xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java |  120 +++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 90 insertions(+), 30 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 a6a0dd7..b534f5b 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
@@ -2404,7 +2404,68 @@
                 totalPrice = totalPrice.add(xpOrderDetail1.getMoney());
                 xpOrderDetailMapper.insert(xpOrderDetail1);
             }
-            order.setOrderMoney(totalPrice);
+
+            // 默认费率1
+            double priceRate = 1;
+            if (pricing.getIsDynamicPrice() == 1) {
+                // 先判断是否已经调价过了
+                Object userDynamicPriceObj = redisService.getCacheObject("USER_DYNAMIC_PRICE_" + order.getCityId() + "_" + uid);
+                if (userDynamicPriceObj != null) {
+                    // 是否调价过了
+                    priceRate = Double.parseDouble(userDynamicPriceObj.toString());
+                } else {
+                    // 没有调过
+                    //是否触发动态调价 redis获取
+                    Object dynamicPriceObj = redisService.getCacheObject("DYNAMIC_PRICE_" + order.getCityId());
+                    if (dynamicPriceObj != null) {
+                        JSONObject jsonObject = JSONObject.parseObject(pricing.getDynamicPricingJson());
+                        // 触发动态调价
+                        // value=时间
+                        String timeStr = dynamicPriceObj.toString();
+                        // 判断当前距离这个时间范围的新增订单数(排除取消) / 上浮数量 算出应该增加的价格率
+                        Integer num = this.getOrderNum(new GetOrderNumDto(timeStr, order.getCityId()));
+                        // X单上升一次调价
+                        Integer orderNum = getOrderNum(jsonObject, 4);
+                        // 需要调价的次数
+                        int count = num / orderNum;
+                        if (count > 0) {
+                            // 计算每次上升的费率
+                            Integer upRate = getOrderNum(jsonObject, 5);
+                            BigDecimal divide = new BigDecimal(upRate).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
+                            for (int i = count; i > 0; i--) {
+                                // 当前费率+(费率*上升百分比)
+                                priceRate = new BigDecimal(priceRate).multiply(divide).add(new BigDecimal(priceRate)).setScale(2, RoundingMode.HALF_UP).doubleValue();
+                            }
+
+                            // 天气预报动态调价
+                            JSONArray ws = jsonObject.getJSONArray("weather");
+                            if (null != ws) {
+                                WeatherDTO data = xpMapClient.wether(order.getCityCode()).getData();
+                                List<WeatherDTO.Lives> lives = data.getLives();
+                                if (lives != null && !lives.isEmpty()) {
+                                    String w = lives.get(0).getWeather();
+                                    for (Object o : ws) {
+                                        JSONObject ele = JSONObject.parseObject(o.toString());
+                                        if (w.contains(ele.getString("weatherType"))) {
+                                            double floatRate = jsonObject.getDouble("ratio");
+                                            priceRate = new BigDecimal(priceRate).add(new BigDecimal(floatRate)).doubleValue();
+                                            break;
+                                        }
+                                    }
+                                }
+                            }
+
+
+                            // 冷却时间
+                            Integer time = getOrderNum(jsonObject, 6);
+                            // 触发调价了
+                            redisService.setCacheObject("USER_DYNAMIC_PRICE_" + order.getCityId() + "_" + uid, priceRate, time.longValue(), TimeUnit.MINUTES);
+                        }
+                    }
+                }
+            }
+
+            order.setOrderMoney(totalPrice.multiply(new BigDecimal(priceRate)));
             order.setAppUserId(null);
             baseMapper.updateById(order);
         } else {
@@ -2523,7 +2584,6 @@
                         }
                     }
                 }
-
             }
             // 封装费用明细数据
             for (Map.Entry<String, BigDecimal> stringBigDecimalEntry : bill.entrySet()) {
@@ -3550,6 +3610,7 @@
                 addTaxiPassengerVo.setUid(appUserId.toString());
                 order.setAppUserId(null);
                 this.updateById(order);
+                order.setAppUserId(appUserId);
                 bootCommonService.setCache_orderStatus(order.getId(), order, null);
 
                 //构建推送消息
@@ -3591,19 +3652,18 @@
 
                 //生成前往上车点的导航数据
                 //查询车辆位置
-                //TODO 本地环境默认写死
-                // VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(dto.getXpVehicleVin())), VehiclePosition.class);
-                // if (Objects.isNull(vehiclePosition)) {
-                //     throw new RuntimeException("车辆位置信息不存在");
-                // }
+                 VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(dto.getXpVehicleVin())), VehiclePosition.class);
+                 if (Objects.isNull(vehiclePosition)) {
+                     throw new RuntimeException("车辆位置信息不存在");
+                 }
 
                 LonLatDto destination = new LonLatDto();
                 LonLatDto origin = new LonLatDto();
                 //查询司机当前位置到起点的线路
-                // origin.setLongitude(vehiclePosition.getPoint().getX());
-                // origin.setLatitude(vehiclePosition.getPoint().getY());
-                origin.setLongitude(104.055499);
-                origin.setLatitude(30.586747);
+                 origin.setLongitude(vehiclePosition.getPoint().getX());
+                 origin.setLatitude(vehiclePosition.getPoint().getY());
+//                origin.setLongitude(104.055499);
+//                origin.setLatitude(30.586747);
                 destination.setLongitude(order.getStartLon());
                 destination.setLatitude(order.getStartLat());
 
@@ -3634,25 +3694,25 @@
                         .plusMinutes(routeVo1.getDuration()).plusMinutes(endPoint.getParkingTimeLimit()).plusMinutes(30);
                 long expirationTime = localDateTime.toEpochSecond(ZoneOffset.of("+8"));
                 //生成token
-//                String token = bluetoothUnlockTokenUtil.generateBluetoothUnlockToken(order.getAppUserId(),
-//                        order.getId(), order.getVehicleId(), expirationTime);
-//                log.info("生成蓝牙token:{} 有效期:{} 订单号: {}", token, expirationTime, order.getOrderNumber());
-//                //存储缓存
-//                JSONObject jsonObject = new JSONObject();
-//                jsonObject.put("userId", order.getAppUserId());
-//                jsonObject.put("orderId", order.getId());
-//                jsonObject.put("vehicleId", order.getVehicleId());
-//                jsonObject.put("expirationTime", expirationTime);
-//                jsonObject.put("orderNumber", order.getOrderNumber());
-//                jsonObject.put("vehicleVin", vehicle.getVehicleVin());
-//                jsonObject.put("createTime", System.currentTimeMillis());
-//                redisService.setCacheObject("rt:bluetooth:unlock:" + token, jsonObject.toJSONString(), expirationTime, TimeUnit.SECONDS);
-//                redisService.setCacheObject("rt:bluetooth:unlock:order:" + order.getId(), token, expirationTime, TimeUnit.SECONDS);
-//                //开始下发蓝牙token
-//                BluetoothDeliverVo vo = new BluetoothDeliverVo();
-//                vo.setCredential(token);
-//                vo.setVim(vehicle.getVehicleVin());
-//                vo.setPassengerUid(order.getAppUserId());
+                String token = bluetoothUnlockTokenUtil.generateBluetoothUnlockToken(order.getAppUserId(),
+                        order.getId(), order.getVehicleId(), expirationTime);
+                log.info("生成蓝牙token:{} 有效期:{} 订单号: {}", token, expirationTime, order.getOrderNumber());
+                //存储缓存
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("userId", order.getAppUserId());
+                jsonObject.put("orderId", order.getId());
+                jsonObject.put("vehicleId", order.getVehicleId());
+                jsonObject.put("expirationTime", expirationTime);
+                jsonObject.put("orderNumber", order.getOrderNumber());
+                jsonObject.put("vehicleVin", vehicle.getVehicleVin());
+                jsonObject.put("createTime", System.currentTimeMillis());
+                redisService.setCacheObject("rt:bluetooth:unlock:" + token, jsonObject.toJSONString(), expirationTime, TimeUnit.SECONDS);
+                redisService.setCacheObject("rt:bluetooth:unlock:order:" + order.getId(), token, expirationTime, TimeUnit.SECONDS);
+                //开始下发蓝牙token
+                BluetoothDeliverVo vo = new BluetoothDeliverVo();
+                vo.setCredential(token);
+                vo.setVim(vehicle.getVehicleVin());
+                vo.setPassengerUid(order.getAppUserId());
 //                BaseVehicleUserDto deliver = bluetoothUnlockClient.deliver(vo);
 //                if(null == deliver){
 //                    throw new ServiceException("下发蓝牙token失败");

--
Gitblit v1.7.1