From ddf438536267b9c9bb77369cdccce4e67206842a Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期二, 28 十月 2025 15:29:45 +0800
Subject: [PATCH] 完成支付宝国际版支付对接

---
 DriverGOPOSTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java |  282 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 145 insertions(+), 137 deletions(-)

diff --git a/DriverGOPOSTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java b/DriverGOPOSTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
index 668d62a..cc1606a 100644
--- a/DriverGOPOSTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
+++ b/DriverGOPOSTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -265,64 +265,64 @@
             car.setVehicleId(UUIDUtil.getRandomCode());
             carService.updateById(car);
         }
-        String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
-        if(ToolUtil.isEmpty(vehicles)){
-            CarModel carModel = carModelMapper.selectById(car.getCarModelId());
-            boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
-            if(!createVehicles){
-                for (int i = 0; i < 5; i++) {
-                    createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
-                    if(createVehicles){
-                        break;
-                    }
-                    try {
-                        Thread.sleep(3000L);
-                    } catch (InterruptedException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            }
-        }
-        
-        //修改google订单信息或者创建新的行程
-        String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId());
-        if(ToolUtil.isEmpty(trip)){
-            JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(),
-                    orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(),  orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString());
-            JSONObject error = createTrip.getJSONObject("error");
-            if(null != error){
-                for (int i = 0; i < 5; i++) {
-                    createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(),
-                            orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(),  orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString());
-                    error = createTrip.getJSONObject("error");
-                    String tripStatus = createTrip.getString("tripStatus");
-                    if(null == error && "NEW".equals(tripStatus)){
-                        break;
-                    }
-                    try {
-                        Thread.sleep(3000L);
-                    } catch (InterruptedException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            }
-        }else{
-            //开始修改行程数据
-            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
-            if(!updateTrip){
-                for (int i = 0; i < 5; i++) {
-                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
-                    if(updateTrip){
-                        break;
-                    }
-                    try {
-                        Thread.sleep(3000L);
-                    } catch (InterruptedException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            }
-        }
+//        String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
+//        if(ToolUtil.isEmpty(vehicles)){
+//            CarModel carModel = carModelMapper.selectById(car.getCarModelId());
+//            boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
+//            if(!createVehicles){
+//                for (int i = 0; i < 5; i++) {
+//                    createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
+//                    if(createVehicles){
+//                        break;
+//                    }
+//                    try {
+//                        Thread.sleep(3000L);
+//                    } catch (InterruptedException e) {
+//                        throw new RuntimeException(e);
+//                    }
+//                }
+//            }
+//        }
+//
+//        //修改google订单信息或者创建新的行程
+//        String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId());
+//        if(ToolUtil.isEmpty(trip)){
+//            JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(),
+//                    orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(),  orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString());
+//            JSONObject error = createTrip.getJSONObject("error");
+//            if(null != error){
+//                for (int i = 0; i < 5; i++) {
+//                    createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(),
+//                            orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(),  orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString());
+//                    error = createTrip.getJSONObject("error");
+//                    String tripStatus = createTrip.getString("tripStatus");
+//                    if(null == error && "NEW".equals(tripStatus)){
+//                        break;
+//                    }
+//                    try {
+//                        Thread.sleep(3000L);
+//                    } catch (InterruptedException e) {
+//                        throw new RuntimeException(e);
+//                    }
+//                }
+//            }
+//        }else{
+//            //开始修改行程数据
+//            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
+//            if(!updateTrip){
+//                for (int i = 0; i < 5; i++) {
+//                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
+//                    if(updateTrip){
+//                        break;
+//                    }
+//                    try {
+//                        Thread.sleep(3000L);
+//                    } catch (InterruptedException e) {
+//                        throw new RuntimeException(e);
+//                    }
+//                }
+//            }
+//        }
     
     
         /**
@@ -542,7 +542,6 @@
                 orderPrivateCar.setState(3);
                 orderPrivateCar.setSetOutTime(new Date());
                 systemNoticeService.addSystemNotice(1, language1 == 1 ? "司机已出发,请耐心等待" : language1 == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderPrivateCar.getUserId());
-                pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位
                 tripStatus = "ENROUTE_TO_PICKUP";
                 break;
             case 4://到达预约点,等待客户上车
@@ -554,6 +553,7 @@
                 tripStatus = "ARRIVED_AT_PICKUP";
                 break;
             case 5://开始服务
+                pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位
                 orderPrivateCar.setBoardingLon(lon);
                 orderPrivateCar.setBoardingLat(lat);
                 orderPrivateCar.setBoardingAddress(address);
@@ -624,23 +624,23 @@
         this.updateById(orderPrivateCar);
     
         //修改行程数据
-        if(ToolUtil.isNotEmpty(tripStatus)){
-            Car car = carService.selectById(orderPrivateCar.getCarId());
-            boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
-            if(!updateTrip){
-                for (int i = 0; i < 5; i++) {
-                    updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
-                    if(updateTrip){
-                        break;
-                    }
-                    try {
-                        Thread.sleep(3000L);
-                    } catch (InterruptedException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            }
-        }
+//        if(ToolUtil.isNotEmpty(tripStatus)){
+//            Car car = carService.selectById(orderPrivateCar.getCarId());
+//            boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
+//            if(!updateTrip){
+//                for (int i = 0; i < 5; i++) {
+//                    updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
+//                    if(updateTrip){
+//                        break;
+//                    }
+//                    try {
+//                        Thread.sleep(3000L);
+//                    } catch (InterruptedException e) {
+//                        throw new RuntimeException(e);
+//                    }
+//                }
+//            }
+//        }
         
 
         // TODO: 2020/6/5 推送状态
@@ -668,6 +668,7 @@
      */
     @Override
     public ResultUtil confirmFees(Integer language, Integer orderId, Integer type, Double parkingFee, Double crossingFee, Integer uid) throws Exception {
+        pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据
         OrderPrivateCar orderPrivateCar = this.selectById(orderId);
         if(!uid.equals(orderPrivateCar.getDriverId())){
             return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande");
@@ -681,17 +682,27 @@
         if(null == orderPrivateCar.getEndServiceTime()){
             orderPrivateCar.setEndServiceTime(new Date());
         }
-        //实际里程小于预估里程95%或者大于5%,则使用预估里程进行计算价格
+
+        Double mileage = orderPrivateCar.getMileage();
+        orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用
+        Double orderMoney = orderPrivateCar.getOrderMoney();
+
         Double startLat = orderPrivateCar.getStartLat();
         Double startLon = orderPrivateCar.getStartLon();
         Double getoffLon = orderPrivateCar.getGetoffLon();
         Double getoffLat = orderPrivateCar.getGetoffLat();
         DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(startLat, startLon, getoffLat, getoffLon, orderPrivateCar.getTripId());
-        double ce = orderPrivateCar.getMileage() / distancematrix.getDistance().doubleValue();
-        if(ce < 0.95 || ce > 1.05){
-            orderPrivateCar.setMileage(distancematrix.getDistance().doubleValue());
-        }
+        orderPrivateCar.setMileage(distancematrix.getDistance().doubleValue());
         orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用
+        Double orderMoney1 = orderPrivateCar.getOrderMoney();
+        //实际金额小于预估金额10%,按照预估金额计费,其他用实际金额计费
+        double ce = orderMoney / orderMoney1;
+        //实际距离小于预估距离10%,按照预估距离计算费用,其余的按照实际距离计算费用
+        if(ce >= 0.9){
+            orderPrivateCar.setMileage(mileage);
+            orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用
+        }
+
         orderPrivateCar.setPayManner(type);
         orderPrivateCar.setParkMoney(null == parkingFee ? 0D : parkingFee);
         orderPrivateCar.setRoadTollMoney(null == crossingFee ? 0D : crossingFee);
@@ -755,45 +766,42 @@
         driverService.updateById(driver);
         
         //修改行程数据
-        Car car = carService.selectById(orderPrivateCar.getCarId());
-        boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
-        if(!updateTrip){
-            for (int i = 0; i < 5; i++) {
-                updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
-                if(updateTrip){
-                    orderPrivateCar.setIsover(1);
-                    this.updateById(orderPrivateCar);
-                    break;
-                }
-                try {
-                    Thread.sleep(3000L);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        }else{
-            orderPrivateCar.setIsover(1);
-            this.updateById(orderPrivateCar);
-        }
-    
-        //上报行程
-        boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId());
-        if(!reportBillableEvent){
-            for (int i = 0; i < 5; i++) {
-                reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId());
-                if(reportBillableEvent){
-                    break;
-                }
-                try {
-                    Thread.sleep(3000L);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        
-        
-        pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据
+//        Car car = carService.selectById(orderPrivateCar.getCarId());
+//        boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
+//        if(!updateTrip){
+//            for (int i = 0; i < 5; i++) {
+//                updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1);
+//                if(updateTrip){
+//                    orderPrivateCar.setIsover(1);
+//                    this.updateById(orderPrivateCar);
+//                    break;
+//                }
+//                try {
+//                    Thread.sleep(3000L);
+//                } catch (InterruptedException e) {
+//                    e.printStackTrace();
+//                }
+//            }
+//        }else{
+//            orderPrivateCar.setIsover(1);
+//            this.updateById(orderPrivateCar);
+//        }
+//
+//        //上报行程
+//        boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId());
+//        if(!reportBillableEvent){
+//            for (int i = 0; i < 5; i++) {
+//                reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId());
+//                if(reportBillableEvent){
+//                    break;
+//                }
+//                try {
+//                    Thread.sleep(3000L);
+//                } catch (InterruptedException e) {
+//                    e.printStackTrace();
+//                }
+//            }
+//        }
         UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId());
         Integer language1 = userInfo.getLanguage();
         systemNoticeService.addSystemNotice(1, language1 == 1 ? "司机已结束本次行程,谢谢使用" : language1 == 2 ?
@@ -1165,23 +1173,23 @@
             orderPrivateCar.setEndLat(Double.valueOf(orderPrivateCar.getDestinationLat()));
             orderPrivateCar.setEndAddress(orderPrivateCar.getDestination());
             //修改google地图行程终点
-            Car car = carService.selectById(orderPrivateCar.getCarId());
-            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(),
-                    null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString(), orderPrivateCar.getId(), 1);
-            if(!updateTrip){
-                for (int i = 0; i < 5; i++) {
-                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(),
-                            null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString(), orderPrivateCar.getId(), 1);
-                    if(updateTrip){
-                        break;
-                    }
-                    try {
-                        Thread.sleep(3000L);
-                    } catch (InterruptedException e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            }
+//            Car car = carService.selectById(orderPrivateCar.getCarId());
+//            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(),
+//                    null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString(), orderPrivateCar.getId(), 1);
+//            if(!updateTrip){
+//                for (int i = 0; i < 5; i++) {
+//                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(),
+//                            null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString(), orderPrivateCar.getId(), 1);
+//                    if(updateTrip){
+//                        break;
+//                    }
+//                    try {
+//                        Thread.sleep(3000L);
+//                    } catch (InterruptedException e) {
+//                        throw new RuntimeException(e);
+//                    }
+//                }
+//            }
         }
         this.updateById(orderPrivateCar);
         pushUtil.pushModifyAddress(1, orderPrivateCar.getUserId(), orderId, 1, status);

--
Gitblit v1.7.1