From 59954a15d604cf65b02943133a0594dc5df8e8fd Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期六, 08 二月 2025 17:57:31 +0800
Subject: [PATCH] 修改订单异常问题

---
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java |   42 +++++++++++++++++++++++-------------------
 1 files changed, 23 insertions(+), 19 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 09cc925..31345c1 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
@@ -1155,8 +1155,7 @@
                         userRedPacketRecordService.updateBatchById(userRedPacketRecords);
                     }
                     orderLogistics.setRedPacketId(jsonArray.toJSONString());
-                }
-                if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){
+                }else if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){
                     orderLogistics.setRedPacketMoney(total);
                     orderMoney = orderMoney.subtract(new BigDecimal(total)).setScale(2, RoundingMode.HALF_EVEN);
                     //获取红包id
@@ -1264,21 +1263,21 @@
                 userCouponRecord.setEndTime(new Date());
                 userCouponRecordService.updateById(userCouponRecord);
             }
-            if(null != orderLogistics.getRedPacketId()){
-                JSONArray jsonArray = JSON.parseArray(orderLogistics.getRedPacketId());
-                for (int i = 0; i < jsonArray.size(); i++) {
-                    JSONObject jsonObject = jsonArray.getJSONObject(i);
-                    Integer id1 = jsonObject.getInteger("id");
-                    Double money = jsonObject.getDouble("money");
-                    UserRedPacketRecord userRedPacketRecord = userRedPacketRecordService.selectById(id1);
-                    userRedPacketRecord.setRemainingAmount(userRedPacketRecord.getRemainingAmount() - money);
-                    if(0 == userRedPacketRecord.getRemainingAmount()){
-                        userRedPacketRecord.setState(2);
-                        userRedPacketRecord.setEndTime(new Date());
-                    }
-                    userRedPacketRecordService.updateById(userRedPacketRecord);
-                }
-            }
+//            if(null != orderLogistics.getRedPacketId()){
+//                JSONArray jsonArray = JSON.parseArray(orderLogistics.getRedPacketId());
+//                for (int i = 0; i < jsonArray.size(); i++) {
+//                    JSONObject jsonObject = jsonArray.getJSONObject(i);
+//                    Integer id1 = jsonObject.getInteger("id");
+//                    Double money = jsonObject.getDouble("money");
+//                    UserRedPacketRecord userRedPacketRecord = userRedPacketRecordService.selectById(id1);
+//                    userRedPacketRecord.setRemainingAmount(userRedPacketRecord.getRemainingAmount() - money);
+//                    if(0 == userRedPacketRecord.getRemainingAmount()){
+//                        userRedPacketRecord.setState(2);
+//                        userRedPacketRecord.setEndTime(new Date());
+//                    }
+//                    userRedPacketRecordService.updateById(userRedPacketRecord);
+//                }
+//            }
     
             //添加已收入明细
             Company company = companyService.selectById(orderLogistics.getCompanyId());
@@ -3261,15 +3260,20 @@
         if(orderLogistics.getState() == 10 || orderLogistics.getState() == 12){
             Car car = carService.selectById(orderLogistics.getCarId());
             //修改行程信息
-            boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null);
+            boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, orderLogistics.getTripId(), null, null, null, null);
             if(!updateTrip){
                 for (int i = 0; i < 5; i++) {
-                    updateTrip = fleetEngineUtil.updateTrip("CANCELED", car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null);
+                    updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, orderLogistics.getTripId(), null, null, null, null);
                     if(updateTrip){
+                        orderLogistics.setIsover(1);
+                        this.updateById(orderLogistics);
                         break;
                     }
                     Thread.sleep(3000L);
                 }
+            }else{
+                orderLogistics.setIsover(1);
+                this.updateById(orderLogistics);
             }
         }
         //添加消息

--
Gitblit v1.7.1