From 821fc2f632f8b974a2c0fc37630e13c5fbe6086c Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 26 九月 2025 17:26:16 +0800
Subject: [PATCH] 修改bug

---
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java |  210 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 125 insertions(+), 85 deletions(-)

diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
index fb532b8..daf0d7a 100644
--- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
+++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -400,6 +400,8 @@
         orderLogistics.setTravelTime(null == travelTime ? new Date() : travelTime);
         orderLogistics.setOrderSource(orderSource);
         orderLogistics.setIsDelete(1);
+        orderLogistics.setTripId(tripId);
+        orderLogistics.setIsover(0);
         this.insert(orderLogistics);
 
         //添加消息
@@ -604,7 +606,7 @@
                                     public void run() {
                                         try {
                                             // 使用Runtime执行命令
-                                            Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
+                                            Process process = Runtime.getRuntime().exec("sudo rm -rf /data/nginx/html/files/audio/" + fileName);
                                             // 读取命令的输出
                                             BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                                             String line;
@@ -620,7 +622,7 @@
                                         }
                                     }
                                 }, 30000);
-                                pushUtil.pushOrderState(2, driver.getId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), pushOrder.getPushTime(), audioUrl);
+                                pushUtil.pushOrderState(2, driver.getId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), pushOrder.getPushTime(), audioUrl, "user");
                             }
                         }
                         Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间
@@ -665,6 +667,16 @@
     public ResultUtil placeOrderPackage(String remark, String placementLon, String placementLat, String startLon, String startLat, String startAddress,
                                         String recipient, String recipientPhone, String endLon, String endLat, String endAddress,
                                         Integer serverCarModelId, Integer driverId, Integer orderSource, Integer uid, Integer language) throws Exception {
+    
+        UserInfo userInfo = userInfoService.selectById(uid);
+        if(ToolUtil.isEmpty(userInfo.getPhone())){
+            return ResultUtil.error(language == 1 ? "请先绑定手机号码" : language == 2 ? "Please bind your mobile phone number first." : "Veuillez d’abord vous inscrire en liant votre numéro de téléphone portable.");
+        }
+        Company company = companyCityService.query1(uid, placementLon, placementLat);
+        if(null != userInfo && null != company){
+            userInfo.setCompanyId(company.getId());
+            userInfoService.updateById(userInfo);
+        }
         /**
          * 1.下了即时单就不能下预约单和即时单
          * 2.下了预约单和再下一张即时单不能再下预约单
@@ -686,6 +698,8 @@
             return ResultUtil.error(language == 1 ? "请选择服务车型" : language == 2 ? "Please select vehicle-type" : "Veuillez sélectionner le type de véhicule");
         }
     
+        userInfo.setLanguage(language);
+        userInfoService.updateById(userInfo);
         OrderLogistics orderLogistics = new OrderLogistics();
         orderLogistics.setType(4);
         orderLogistics.setUserId(uid);
@@ -743,8 +757,7 @@
             }
     
             orderLogistics.setDriverId(driverId);
-            orderLogistics.setCompanyId(driver.getFranchiseeId() != null && driver.getFranchiseeId() != 0 ? driver.getFranchiseeId() : (
-                    driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1));
+            orderLogistics.setCompanyId(driver.getCompanyId());
             orderLogistics.setState(2);
             orderLogistics.setCarId(driver.getCarId());
             CarService query1 = carServiceMapper.query(1, driver.getCarId());
@@ -766,14 +779,11 @@
         orderLogistics.setIsReassign(1);
         orderLogistics.setIsDelete(1);
         orderLogistics.setTripId(tripId);
+        orderLogistics.setIsover(0);
         DistancematrixVo distancematrix1 = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), orderLogistics.getEndLat(), orderLogistics.getEndLon(), tripId);
         Long distance1 = distancematrix1.getDistance();
         orderLogistics.setEstimatedMileage(new BigDecimal(distance1).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
         this.insert(orderLogistics);
-    
-        UserInfo userInfo = userInfoService.selectById(uid);
-        userInfo.setLanguage(language);
-        userInfoService.updateById(userInfo);
     
         //google创建车辆信息
         String vehicleId = null;
@@ -873,7 +883,7 @@
                 public void run() {
                     try {
                         // 使用Runtime执行命令
-                        Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
+                        Process process = Runtime.getRuntime().exec("sudo rm -rf /data/nginx/html/files/audio/" + fileName);
                         // 读取命令的输出
                         BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                         String line;
@@ -893,8 +903,8 @@
             new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, "");
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl);
+                    pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, "", "user");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl, "user");
                 }
             }).start();
         }
@@ -958,14 +968,23 @@
                             .eq("state", 1).like("type", "4"));
                     if(driver1.getState() == 2 || null != driverWork){
                         orderLogistics.setDriverId(dr.getId());
-                        orderLogistics.setCompanyId(dr.getFranchiseeId() != null && dr.getFranchiseeId() != 0 ? dr.getFranchiseeId() : (
-                                dr.getCompanyId() != null && dr.getCompanyId() != 0 ? dr.getCompanyId() : 1));
+                        orderLogistics.setCompanyId(dr.getCompanyId());
                         orderLogistics.setState(2);
                         orderLogistics.setCarId(dr.getCarId());
-                        CarService query1 = carServiceMapper.query(1, dr.getCarId());
+                        CarService query1 = carServiceMapper.query(4, dr.getCarId());
                         orderLogistics.setServerCarModelId(query1.getServerCarModelId());
                         orderLogistics.setSnatchOrderTime(new Date());
     
+                        String value = redisUtil.getValue("DRIVER" + driver1.getId());
+                        if(ToolUtil.isNotEmpty(value)) {
+                            String[] split = value.split(",");
+                            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId);
+                            //超时时间
+                            long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000);
+                            orderLogistics.setEstimateArriveTime(new Date(timeOut));
+                            orderLogistics.setEstimateArriveMileage(distancematrix.getDistance());
+                        }
+                        
                         dr.setState(3);
                         driverService.updateById(dr);
                         this.updateById(orderLogistics);
@@ -997,7 +1016,7 @@
                             public void run() {
                                 try {
                                     // 使用Runtime执行命令
-                                    Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
+                                    Process process = Runtime.getRuntime().exec("sudo rm -rf /data/nginx/html/files/audio/" + fileName);
                                     // 读取命令的输出
                                     BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                                     String line;
@@ -1017,10 +1036,12 @@
                         new Thread(new Runnable() {
                             @Override
                             public void run() {
-                                pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, "");
-                                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl);
+                                System.err.println("直推司机后推送司机订单状态");
+                                pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, "", "user");
+                                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl, "user");
                             }
                         }).start();
+                        
                     }
                 }
             }
@@ -1110,7 +1131,7 @@
             if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(new BigDecimal(userCouponRecord.getFullMoney())) < 0){
                 return ResultUtil.error(language == 1 ? "优惠券不能用于此订单" : language == 2 ? "Coupon cannot be used for this order." : "Le coupon ne peut pas être utilisé pour cette commande.", "");
             }
-            orderMoney = orderMoney.subtract(new BigDecimal(userCouponRecord.getMoney())).setScale(2, RoundingMode.HALF_EVEN);
+            orderMoney = orderMoney.subtract(new BigDecimal(userCouponRecord.getMoney()));
             orderLogistics.setCouponMoney(userCouponRecord.getMoney());
             orderLogistics.setCouponId(couponId);
         }
@@ -1119,15 +1140,14 @@
         if(null != redDeduction && 1 == redDeduction && null == orderLogistics.getRedPacketId()){
             RedEnvelopePaymentSettings redEnvelopePaymentSettings = redEnvelopePaymentSettingsService.getRedEnvelopePaymentSettings();
             if(null != redEnvelopePaymentSettings){
-                Double total = userRedPacketRecordService.queryRemainingAmount(uid);
                 List<UserRedPacketRecord> userRedPacketRecords = userRedPacketRecordService.selectList(new EntityWrapper<UserRedPacketRecord>().eq("userId", uid)
                         .eq("state", 1).eq("companyId", orderLogistics.getCompanyId()).gt("remainingAmount", 0).orderBy("insertTime", false));
-            
+                Double total = userRedPacketRecords.stream().mapToDouble(UserRedPacketRecord::getRemainingAmount).sum();
                 BigDecimal deductionRatio = redEnvelopePaymentSettings.getDeductionRatio();
                 BigDecimal multiply1 = orderMoney.multiply(deductionRatio.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN);
                 if(total > 0 && multiply1.doubleValue() > 0 && total.compareTo(multiply1.doubleValue()) >= 0){
                     orderLogistics.setRedPacketMoney(multiply1.doubleValue());
-                    orderMoney = orderMoney.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN);
+                    orderMoney = orderMoney.subtract(multiply1);
                 
                     //获取红包id
                     JSONArray jsonArray = new JSONArray();
@@ -1158,7 +1178,7 @@
                     orderLogistics.setRedPacketId(jsonArray.toJSONString());
                 }else if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){
                     orderLogistics.setRedPacketMoney(total);
-                    orderMoney = orderMoney.subtract(new BigDecimal(total)).setScale(2, RoundingMode.HALF_EVEN);
+                    orderMoney = orderMoney.subtract(new BigDecimal(total));
                     //获取红包id
                     JSONArray jsonArray = new JSONArray();
                     for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) {
@@ -1306,8 +1326,8 @@
             new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
+                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                 }
             }).start();
 
@@ -1335,6 +1355,9 @@
                             if(null != orderLogistics.getDriverId()){
                                 aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
                             }
+    
+                            Double aDouble1 = new BigDecimal(orderLogistics.getMileage()).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+                            Long serviceTime = new BigDecimal(orderLogistics.getEndServiceTime().getTime() - orderLogistics.getStartServiceTime().getTime()).divide(new BigDecimal(60000), 0, RoundingMode.HALF_EVEN).setScale(0, RoundingMode.HALF_EVEN).longValue();
                             if(1 == finalLanguage1){
                                 document.getElementById("english").remove();
                                 document.getElementById("french").remove();
@@ -1425,7 +1448,7 @@
 //                    Element track_chinese = document.getElementById("track_chinese");
 //                    track_chinese.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                 Element pay_time_chinese = document.getElementById("pay_time_chinese");
-                                pay_time_chinese.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getTravelTime())));
+                                pay_time_chinese.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getEndServiceTime())));
                                 Elements driver_chinese = document.getElementsByClass("driver_chinese");
                                 for (int i = 0; i < driver_chinese.size(); i++) {
                                     Element element = driver_chinese.get(i);
@@ -1435,6 +1458,8 @@
                                 cp_chinese.text("车牌:" + car.getCarLicensePlate());
                                 Element pf_chinese = document.getElementById("pf_chinese");
                                 pf_chinese.text("司机评分:" + aDouble);
+                                Element lc_chinese = document.getElementById("lc_chinese");
+                                lc_chinese.text("里程:" + aDouble1 + "公里 /" + serviceTime + "分钟");
                                 Element start_address_chinese = document.getElementById("start_address_chinese");
                                 start_address_chinese.text(orderLogistics.getStartAddress());
                                 Element end_address_chinese = document.getElementById("end_address_chinese");
@@ -1533,7 +1558,7 @@
 //                    Element track_english = document.getElementById("track_english");
 //                    track_english.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                 Element pay_time_english = document.getElementById("pay_time_english");
-                                pay_time_english.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getTravelTime())));
+                                pay_time_english.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getEndServiceTime())));
                                 Elements driver_english = document.getElementsByClass("driver_english");
                                 for (int i = 0; i < driver_english.size(); i++) {
                                     Element element = driver_english.get(i);
@@ -1543,6 +1568,8 @@
                                 cp_english.text("Number Plate:" + car.getCarLicensePlate());
                                 Element pf_english = document.getElementById("pf_english");
                                 pf_english.text("Driver Rating:" + aDouble);
+                                Element lc_english = document.getElementById("lc_english");
+                                lc_english.text("Mileage:" + aDouble1 + "KM / " + serviceTime + "Minutes");
                                 Element start_address_english = document.getElementById("start_address_english");
                                 start_address_english.text(orderLogistics.getStartAddress());
                                 Element end_address_english = document.getElementById("end_address_english");
@@ -1641,7 +1668,7 @@
 //                    Element track_french = document.getElementById("track_french");
 //                    track_french.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                 Element pay_time_french = document.getElementById("pay_time_french");
-                                pay_time_french.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getTravelTime())));
+                                pay_time_french.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getEndServiceTime())));
                                 Elements driver_french = document.getElementsByClass("driver_french");
                                 for (int i = 0; i < driver_french.size(); i++) {
                                     Element element = driver_french.get(i);
@@ -1651,6 +1678,8 @@
                                 cp_french.text("Plaque: GS " + car.getCarLicensePlate());
                                 Element pf_french = document.getElementById("pf_french");
                                 pf_french.text("Note du chauffeur: " + aDouble);
+                                Element lc_french = document.getElementById("lc_french");
+                                lc_french.text("Distance: " + aDouble1 + "km / " + serviceTime + "minutes");
                                 Element start_address_french = document.getElementById("start_address_french");
                                 start_address_french.text(orderLogistics.getStartAddress());
                                 Element end_address_french = document.getElementById("end_address_french");
@@ -1663,11 +1692,11 @@
                             EmailUtil.send(userInfo.getEmail(), finalLanguage1 == 1 ? "包裹收据" : finalLanguage1 == 2 ? "Delivery receipt" : "Reçu de livraison",  document.html());
         
                             //开始生成pdf收据和html收据
-                            File file = new File("/home/igotechgh/nginx/html/files/html/");
+                            File file = new File("/data/nginx/html/files/html/");
                             if(!file.exists()){
                                 file.mkdirs();
                             }
-                            file = new File("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
+                            file = new File("/data/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
                             if(!file.exists()){
                                 file.createNewFile();
                             }
@@ -1676,17 +1705,17 @@
                             fileWriter.flush();
                             fileWriter.close();
         
-                            File file1 = new File("/home/igotechgh/nginx/html/files/pdf/");
+                            File file1 = new File("/data/nginx/html/files/pdf/");
                             if(!file1.exists()){
                                 file1.mkdirs();
                             }
-                            file1 = new File("/home/igotechgh/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
+                            file1 = new File("/data/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
                             if(!file1.exists()){
                                 file1.createNewFile();
                             }
                             try{
                                 FileOutputStream fileOutputStream = new FileOutputStream(file1);
-                                HtmlToPdfUtils.convertToPdf("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
+                                HtmlToPdfUtils.convertToPdf("/data/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
                             }catch (Exception e){
                                 e.printStackTrace();
                                 System.out.println("html转pdf异常");
@@ -1903,8 +1932,8 @@
             new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
+                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                     Integer language1 = driver.getLanguage();
                     String text = "";
                     switch (language1){
@@ -1932,7 +1961,7 @@
                         public void run() {
                             try {
                                 // 使用Runtime执行命令
-                                Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
+                                Process process = Runtime.getRuntime().exec("sudo rm -rf /data/nginx/html/files/audio/" + fileName);
                                 // 读取命令的输出
                                 BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                                 String line;
@@ -1972,6 +2001,8 @@
                             if(null != orderLogistics.getDriverId()){
                                 aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
                             }
+                            Double aDouble1 = new BigDecimal(orderLogistics.getMileage()).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+                            Long serviceTime = new BigDecimal(orderLogistics.getEndServiceTime().getTime() - orderLogistics.getStartServiceTime().getTime()).divide(new BigDecimal(60000), 0, RoundingMode.HALF_EVEN).setScale(0, RoundingMode.HALF_EVEN).longValue();
                             if(1 == finalLanguage){
                                 document.getElementById("english").remove();
                                 document.getElementById("french").remove();
@@ -2062,7 +2093,7 @@
 //                    Element track_chinese = document.getElementById("track_chinese");
 //                    track_chinese.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                 Element pay_time_chinese = document.getElementById("pay_time_chinese");
-                                pay_time_chinese.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getTravelTime())));
+                                pay_time_chinese.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getEndServiceTime())));
                                 Elements driver_chinese = document.getElementsByClass("driver_chinese");
                                 for (int i = 0; i < driver_chinese.size(); i++) {
                                     Element element = driver_chinese.get(i);
@@ -2072,6 +2103,8 @@
                                 cp_chinese.text("车牌:" + car.getCarLicensePlate());
                                 Element pf_chinese = document.getElementById("pf_chinese");
                                 pf_chinese.text("司机评分:" + aDouble);
+                                Element lc_chinese = document.getElementById("lc_chinese");
+                                lc_chinese.text("里程:" + aDouble1 + "公里 /" + serviceTime + "分钟");
                                 Element start_address_chinese = document.getElementById("start_address_chinese");
                                 start_address_chinese.text(orderLogistics.getStartAddress());
                                 Element end_address_chinese = document.getElementById("end_address_chinese");
@@ -2170,7 +2203,7 @@
 //                    Element track_english = document.getElementById("track_english");
 //                    track_english.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                 Element pay_time_english = document.getElementById("pay_time_english");
-                                pay_time_english.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getTravelTime())));
+                                pay_time_english.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getEndServiceTime())));
                                 Elements driver_english = document.getElementsByClass("driver_english");
                                 for (int i = 0; i < driver_english.size(); i++) {
                                     Element element = driver_english.get(i);
@@ -2180,6 +2213,8 @@
                                 cp_english.text("Number Plate:" + car.getCarLicensePlate());
                                 Element pf_english = document.getElementById("pf_english");
                                 pf_english.text("Driver Rating:" + aDouble);
+                                Element lc_english = document.getElementById("lc_english");
+                                lc_english.text("Mileage:" + aDouble1 + "KM / " + serviceTime + "Minutes");
                                 Element start_address_english = document.getElementById("start_address_english");
                                 start_address_english.text(orderLogistics.getStartAddress());
                                 Element end_address_english = document.getElementById("end_address_english");
@@ -2278,7 +2313,7 @@
 //                    Element track_french = document.getElementById("track_french");
 //                    track_french.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                 Element pay_time_french = document.getElementById("pay_time_french");
-                                pay_time_french.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getTravelTime())));
+                                pay_time_french.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getEndServiceTime())));
                                 Elements driver_french = document.getElementsByClass("driver_french");
                                 for (int i = 0; i < driver_french.size(); i++) {
                                     Element element = driver_french.get(i);
@@ -2288,6 +2323,8 @@
                                 cp_french.text("Plaque: GS " + car.getCarLicensePlate());
                                 Element pf_french = document.getElementById("pf_french");
                                 pf_french.text("Note du chauffeur: " + aDouble);
+                                Element lc_french = document.getElementById("lc_french");
+                                lc_french.text("Distance: " + aDouble1 + "km / " + serviceTime + "minutes");
                                 Element start_address_french = document.getElementById("start_address_french");
                                 start_address_french.text(orderLogistics.getStartAddress());
                                 Element end_address_french = document.getElementById("end_address_french");
@@ -2300,11 +2337,11 @@
                             EmailUtil.send(userInfo.getEmail(), finalLanguage == 1 ? "包裹收据" : finalLanguage == 2 ? "Delivery receipt" : "Reçu de livraison",  document.html());
         
                             //开始生成pdf收据和html收据
-                            File file = new File("/home/igotechgh/nginx/html/files/html/");
+                            File file = new File("/data/nginx/html/files/html/");
                             if(!file.exists()){
                                 file.mkdirs();
                             }
-                            file = new File("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
+                            file = new File("/data/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
                             if(!file.exists()){
                                 file.createNewFile();
                             }
@@ -2313,17 +2350,17 @@
                             fileWriter.flush();
                             fileWriter.close();
         
-                            File file1 = new File("/home/igotechgh/nginx/html/files/pdf/");
+                            File file1 = new File("/data/nginx/html/files/pdf/");
                             if(!file1.exists()){
                                 file1.mkdirs();
                             }
-                            file1 = new File("/home/igotechgh/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
+                            file1 = new File("/data/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
                             if(!file1.exists()){
                                 file1.createNewFile();
                             }
                             try{
                                 FileOutputStream fileOutputStream = new FileOutputStream(file1);
-                                HtmlToPdfUtils.convertToPdf("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
+                                HtmlToPdfUtils.convertToPdf("/data/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
                             }catch (Exception e){
                                 e.printStackTrace();
                                 System.out.println("html转pdf异常");
@@ -2468,8 +2505,8 @@
             new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
+                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                 }
             }).start();
 
@@ -2526,8 +2563,8 @@
             new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
+                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                 }
             }).start();
 
@@ -2598,8 +2635,8 @@
             new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
+                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                 }
             }).start();
 
@@ -2620,6 +2657,8 @@
                 if(null != orderLogistics.getDriverId()){
                     aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
                 }
+                Double aDouble1 = new BigDecimal(orderLogistics.getMileage()).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+                Long serviceTime = new BigDecimal(orderLogistics.getEndServiceTime().getTime() - orderLogistics.getStartServiceTime().getTime()).divide(new BigDecimal(60000), 0, RoundingMode.HALF_EVEN).setScale(0, RoundingMode.HALF_EVEN).longValue();
                 if(1 == language){
                     document.getElementById("english").remove();
                     document.getElementById("french").remove();
@@ -2710,7 +2749,7 @@
 //                    Element track_chinese = document.getElementById("track_chinese");
 //                    track_chinese.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                     Element pay_time_chinese = document.getElementById("pay_time_chinese");
-                    pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
+                    pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getEndServiceTime())));
                     Elements driver_chinese = document.getElementsByClass("driver_chinese");
                     for (int i = 0; i < driver_chinese.size(); i++) {
                         Element element = driver_chinese.get(i);
@@ -2720,6 +2759,8 @@
                     cp_chinese.text("车牌:" + car.getCarLicensePlate());
                     Element pf_chinese = document.getElementById("pf_chinese");
                     pf_chinese.text("司机评分:" + aDouble);
+                    Element lc_chinese = document.getElementById("lc_chinese");
+                    lc_chinese.text("里程:" + aDouble1 + "公里 /" + serviceTime + "分钟");
                     Element start_address_chinese = document.getElementById("start_address_chinese");
                     start_address_chinese.text(orderLogistics.getStartAddress());
                     Element end_address_chinese = document.getElementById("end_address_chinese");
@@ -2818,7 +2859,7 @@
 //                    Element track_english = document.getElementById("track_english");
 //                    track_english.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                     Element pay_time_english = document.getElementById("pay_time_english");
-                    pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
+                    pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getEndServiceTime())));
                     Elements driver_english = document.getElementsByClass("driver_english");
                     for (int i = 0; i < driver_english.size(); i++) {
                         Element element = driver_english.get(i);
@@ -2828,6 +2869,8 @@
                     cp_english.text("Number Plate:" + car.getCarLicensePlate());
                     Element pf_english = document.getElementById("pf_english");
                     pf_english.text("Driver Rating:" + aDouble);
+                    Element lc_english = document.getElementById("lc_english");
+                    lc_english.text("Mileage:" + aDouble1 + "KM / " + serviceTime + "Minutes");
                     Element start_address_english = document.getElementById("start_address_english");
                     start_address_english.text(orderLogistics.getStartAddress());
                     Element end_address_english = document.getElementById("end_address_english");
@@ -2926,7 +2969,7 @@
 //                    Element track_french = document.getElementById("track_french");
 //                    track_french.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                     Element pay_time_french = document.getElementById("pay_time_french");
-                    pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
+                    pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getEndServiceTime())));
                     Elements driver_french = document.getElementsByClass("driver_french");
                     for (int i = 0; i < driver_french.size(); i++) {
                         Element element = driver_french.get(i);
@@ -2936,6 +2979,8 @@
                     cp_french.text("Plaque: GS " + car.getCarLicensePlate());
                     Element pf_french = document.getElementById("pf_french");
                     pf_french.text("Note du chauffeur: " + aDouble);
+                    Element lc_french = document.getElementById("lc_french");
+                    lc_french.text("Distance: " + aDouble1 + "km / " + serviceTime + "minutes");
                     Element start_address_french = document.getElementById("start_address_french");
                     start_address_french.text(orderLogistics.getStartAddress());
                     Element end_address_french = document.getElementById("end_address_french");
@@ -2948,11 +2993,11 @@
                 EmailUtil.send(userInfo.getEmail(), language == 1 ? "包裹收据" : language == 2 ? "Delivery receipt" : "Reçu de livraison",  document.html());
         
                 //开始生成pdf收据和html收据
-                File file = new File("/home/igotechgh/nginx/html/files/html/");
+                File file = new File("/data/nginx/html/files/html/");
                 if(!file.exists()){
                     file.mkdirs();
                 }
-                file = new File("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + id + ".html");
+                file = new File("/data/nginx/html/files/html/parcel_receipt_" + id + ".html");
                 if(!file.exists()){
                     file.createNewFile();
                 }
@@ -2961,17 +3006,17 @@
                 fileWriter.flush();
                 fileWriter.close();
         
-                File file1 = new File("/home/igotechgh/nginx/html/files/pdf/");
+                File file1 = new File("/data/nginx/html/files/pdf/");
                 if(!file1.exists()){
                     file1.mkdirs();
                 }
-                file1 = new File("/home/igotechgh/nginx/html/files/pdf/parcel_receipt_" + id + ".pdf");
+                file1 = new File("/data/nginx/html/files/pdf/parcel_receipt_" + id + ".pdf");
                 if(!file1.exists()){
                     file1.createNewFile();
                 }
                 try{
                     FileOutputStream fileOutputStream = new FileOutputStream(file1);
-                    HtmlToPdfUtils.convertToPdf("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + id + ".html", "I-GO", fileOutputStream);
+                    HtmlToPdfUtils.convertToPdf("/data/nginx/html/files/html/parcel_receipt_" + id + ".html", "I-GO", fileOutputStream);
                 }catch (Exception e){
                     e.printStackTrace();
                     System.out.println("html转pdf异常");
@@ -3061,8 +3106,8 @@
             new Thread(new Runnable() {
                 @Override
                 public void run() {
-                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
+                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                 }
             }).start();
 
@@ -3197,24 +3242,16 @@
     public ResultUtil addCancle(Integer id, String reason, String remark, Integer uid, Double lon, Double lat, String address, Integer language) throws Exception {
         if(ToolUtil.isNotEmpty(remark)){
             if(ToolUtil.isNotEmpty(remark)){
+                remark = remark.toLowerCase();
                 List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null);
-                List<String> list = Arrays.asList(remark.split(" "));
-                for(SensitiveWords s : sensitiveWords){
-                    List<String> str = new ArrayList<>();
-                    String lowerCase = s.getContent().toLowerCase();
-                    for (String s1 : list) {
-                        if(lowerCase.equals(s1.toLowerCase())){
-                            str.add("***");
-                        }else{
-                            str.add(s1);
-                        }
-                    }
-                    list = str;
+                for(SensitiveWords s : sensitiveWords) {
+                    remark = remark.replaceAll(s.getContent().toLowerCase(), "***");
                 }
-                remark = list.stream().collect(Collectors.joining(" "));
             }
         }
-
+        if(null == lon || null == lat){
+            return ResultUtil.error(language == 1 ? "无效的经纬度" : language == 2 ? "Invalid longitude and latitude" : "Longitude et latitude non valides");
+        }
         language = userInfoService.queryLanguage(uid, language);
         OrderLogistics orderLogistics = this.selectById(id);
         Integer integer = null;
@@ -3224,16 +3261,16 @@
         if(orderLogistics.getState() > 5 && orderLogistics.getState() != 11 && orderLogistics.getState() != 12){
             return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Failed to cancel order, illegal operation." : "Échec de l’annulation de la commande, opération illégale.");
         }
-    
+        orderCancelService.delete(new EntityWrapper<OrderCancel>().eq("orderId", orderLogistics.getId()).eq("orderType", 4));
         if(null == orderLogistics.getDriverId()){//没有接单的情况
-            integer = orderCancelService.saveData(id, 4, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, null, 2, 1, uid);
+            integer = orderCancelService.saveData(id, 4, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, 0D, 2, 1, uid);
             orderLogistics.setState(10);
             this.updateById(orderLogistics);
         }else {
             BaseWarpper data = queryCancleAmount(id, language).getData();
             Double amount = data.getAmount();
             if(0 == amount){
-                integer = orderCancelService.saveData(id, 4, reason, remark, null, null, 2, 1, uid);
+                integer = orderCancelService.saveData(id, 4, reason, remark, null, 0D, 2, 1, uid);
                 if(5 == orderLogistics.getState()){
                     orderLogistics.setState(6);
                     orderLogistics.setGetoffLon(lon);
@@ -3281,8 +3318,8 @@
                             audioUrl = "https://igo.i-go.group/files/audio/system/UserCancelledOrder-FR.mp3";
                             break;
                     }
-                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState() == 12 ? orderLogistics.getState() : 10, 0, audioUrl);
+                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState() == 12 ? orderLogistics.getState() : 10, 0, audioUrl, "user");
                 }
             }).start();
             driver.setState(2);
@@ -3500,7 +3537,10 @@
         BaseWarpper baseWarpper = new BaseWarpper();
         double amount = 0;
         CancleOrder query = cancleOrderService.query(orderLogistics.getCompanyId());
-        if(null == query || null == orderLogistics.getDriverId() || orderLogistics.getState() == 11){
+        if(null == query){
+            return ResultUtil.error("请先添加取消规则");
+        }
+        if(null == orderLogistics.getDriverId() || orderLogistics.getState() == 11){
             baseWarpper.setAmount(amount);
             return ResultUtil.success(baseWarpper);
         }
@@ -3683,11 +3723,11 @@
                     }
     
                     this.deleteTask(id);//删除定时任务
-                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
+                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
                 }else{
                     incomeService.saveData(1, orderLogistics.getCompanyId(), 3, orderLogistics.getId(), 4, amount.doubleValue());
                 }
-                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
+                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
     
     
                 //添加消息
@@ -3760,11 +3800,11 @@
                 }
                 this.deleteTask(orderLogistics.getId());//删除定时任务
                 
-                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
+                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
             }else{
                 incomeService.saveData(1, orderLogistics.getCompanyId(), 3, orderLogistics.getId(), 4, amount.doubleValue());
             }
-            pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
+            pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
             
             //添加消息
             systemNoticeService.addSystemNotice(1, language == 1 ? "您已使用余额成功支付取消订单费用,谢谢使用!" : language == 2
@@ -3923,11 +3963,11 @@
                 
                 EmailUtil.send(userInfo.getEmail(), language == 1 ? "红包活动" : language == 2 ? "Lucky-promo activities" : "Activités bonus",  document.html());
                 //开始生成pdf收据和html收据
-                File file = new File("/home/igotechgh/nginx/html/files/html/");
+                File file = new File("/data/nginx/html/files/html/");
                 if(!file.exists()){
                     file.mkdirs();
                 }
-                file = new File("/home/igotechgh/nginx/html/files/html/redpacket_" + orderId + ".html");
+                file = new File("/data/nginx/html/files/html/redpacket_" + orderId + ".html");
                 if(!file.exists()){
                     file.createNewFile();
                 }

--
Gitblit v1.7.1