From 1da73e129402bb3923e92f3d561ac49acc87fee5 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 10 十月 2025 15:39:43 +0800
Subject: [PATCH] 删除不必要的日志

---
 DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java |   81 +++++++++++++++++++++++++++++++++-------
 1 files changed, 67 insertions(+), 14 deletions(-)

diff --git a/DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java b/DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
index 1476c81..a89e9e8 100644
--- a/DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
+++ b/DriverZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -101,6 +101,9 @@
     @Value("${filePath}")
     private String filePath;
 
+    @Autowired
+    private IAppOperationLogService appOperationLogService;
+
 
 
 
@@ -207,7 +210,7 @@
 //        }
 //        System.out.println(map);
         this.updateById(orderPrivateCar);
-
+        appOperationLogService.addAppOperationLog(orderPrivateCar.getDriverId(), "{\"type\":\"司机抢单成功\",\"orderId\":\"" + orderPrivateCar.getId() + "\",\"orderInfo\":\"" + JSON.toJSONString(orderPrivateCar) + "\"}");
         //如果是预约单,则不修改司机为服务中
         if(orderPrivateCar.getOrderType() != 2 || (orderPrivateCar.getOrderType() == 2 && orderPrivateCar.getTravelTime().getTime() < System.currentTimeMillis() + 600000)){
             //修改司机为服务中
@@ -299,21 +302,24 @@
         /*if(state==5 && orderPrivateCar.getState()!=4){
             return ResultUtil.error("当前订单不能开始服务");
         }*/
+        String stateName = "";
         switch (state){
             case 3://出发前往预约点
                 // 判断是否有其他未完成的单子
-                List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.queryByState(orderPrivateCar.getUserId(), 1, 1, 3,4, 5,6);
+                List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.queryDriverByState(orderPrivateCar.getDriverId(), 1, 1, 3,4, 5,6);
                 if(!CollectionUtils.isEmpty(orderPrivateCars)){
                     return ResultUtil.error("有未完成的服务订单");
                 }
                 orderPrivateCar.setState(3);
                 orderPrivateCar.setSetOutTime(new Date());
                 systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderPrivateCar.getUserId());
+                stateName = "出发前往预约点";
                 break;
             case 4://到达预约点,等待客户上车
                 orderPrivateCar.setState(4);
                 orderPrivateCar.setArriveTime(new Date());
                 systemNoticeService.addSystemNotice(1, "司机已到达您设置的预约地点,请及时上车", orderPrivateCar.getUserId());
+                stateName = "到达预约点,等待客户上车";
                 break;
             case 5://开始服务
                 orderPrivateCar.setBoardingLon(lon);
@@ -324,7 +330,7 @@
                 orderPrivateCar.setStartServiceTime(new Date());
 
                 pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位
-
+                stateName = "开始服务";
                 new Thread(new Runnable() {
                     @Override
                     public void run() {
@@ -340,7 +346,7 @@
                 orderPrivateCar.setGetoffAddress(address);
                 orderPrivateCar.setGetoffTime(new Date());
                 orderPrivateCar.setEndServiceTime(new Date());
-
+                stateName = "结束服务";
                 // 结束服务时查询轨迹,计算距离
                 Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
                 double sum = 0;
@@ -444,7 +450,7 @@
                 break;
         }
         this.updateById(orderPrivateCar);
-
+        appOperationLogService.addAppOperationLog(orderPrivateCar.getDriverId(), "{\"type\":\"司机操作订单," + stateName + "\",\"orderId\":\"" + orderPrivateCar.getId() + "\",\"orderInfo\":\"" + JSON.toJSONString(orderPrivateCar) + "\"}");
         // TODO: 2020/6/5 推送状态
         OrderPrivateCar finalOrderPrivateCar = orderPrivateCar;
         new Thread(new Runnable() {
@@ -531,6 +537,7 @@
         orderPrivateCar.setParkMoney(null == parkingFee ? 0D : parkingFee);
         orderPrivateCar.setRoadTollMoney(null == crossingFee ? 0D : crossingFee);
         orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney() + orderPrivateCar.getParkMoney() + orderPrivateCar.getRoadTollMoney());
+        orderPrivateCar.setIsConfirm(1);
         //判断是否首单免费-免费直接完成
         Integer orderNumber = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("userId",orderPrivateCar.getUserId()).last("and (state=8 or state=9)"));
 
@@ -561,7 +568,7 @@
                     driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                     driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                     driverService.updateById(driver);
-                    incomeService.saveDriverData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue(),driver.getBalance());
+                    incomeService.saveDriverData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue(),driver.getLaveBusinessMoney());
                 }else{
                     orderPrivateCar.setState(7);
                     orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney()-userInfo.getFreeMoney().doubleValue());
@@ -627,7 +634,7 @@
             driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
             driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
             driverService.updateById(driver);
-            incomeService.saveDriverData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue(), driver.getBalance());
+            incomeService.saveDriverData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue(), driver.getLaveBusinessMoney());
         }else {
             orderPrivateCar.setState(7);
         }
@@ -646,7 +653,7 @@
 //        }
         this.updateById(orderPrivateCar);
 
-
+        appOperationLogService.addAppOperationLog(orderPrivateCar.getDriverId(), "{\"type\":\"司机确认费用\",\"orderId\":\"" + orderPrivateCar.getId() + "\",\"orderInfo\":\"" + JSON.toJSONString(orderPrivateCar) + "\"}");
         pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据
         systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderPrivateCar.getUserId());
 
@@ -693,6 +700,56 @@
             this.setMoney(orderPrivateCar, 0D, 0D);
         }
 
+        if(Objects.isNull(orderPrivateCar.getEstimatedPrice())){
+            orderPrivateCar.setEstimatedPrice(0D);
+        }
+        if(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()).subtract(new BigDecimal(orderPrivateCar.getEstimatedPrice())).abs().doubleValue() > 3){
+            orderPrivateCar.setIsException(1);
+        }
+        this.updateById(orderPrivateCar);
+
+        if(orderPrivateCar.getIsConfirm() == 0){
+            // 查询起点或者终点在特殊区域中
+            List<SpecialAreaBilling> specialAreaBillings = specialAreaBillingService.selectList(new EntityWrapper<SpecialAreaBilling>()
+                    .eq("state", 1));
+            if(!CollectionUtils.isEmpty(specialAreaBillings)){
+                // 判断起点或者终点在特殊区域中
+                Iterator<SpecialAreaBilling> iterator = specialAreaBillings.iterator();
+                while (iterator.hasNext()) {
+                    SpecialAreaBilling specialAreaBilling = iterator.next();
+                    // 起点
+                    Double startLon = orderPrivateCar.getStartLon();
+                    Double startLat = orderPrivateCar.getStartLat();
+                    boolean start = ElectricFenceUtil.monitorElectricFenc(specialAreaBilling.getCoordinate(), startLon + "," + startLat);
+                    // 终点
+                    Double endLon = orderPrivateCar.getEndLon();
+                    Double endLat = orderPrivateCar.getEndLat();
+                    boolean end = ElectricFenceUtil.monitorElectricFenc(specialAreaBilling.getCoordinate(), endLon + "," + endLat);
+                    if(!start && !end){
+                        iterator.remove();
+                    }
+                }
+                if(!CollectionUtils.isEmpty(specialAreaBillings)){
+                    // 拿到价格系数最高的特殊区域
+                    specialAreaBillings.sort(new Comparator<SpecialAreaBilling>() {
+                        @Override
+                        public int compare(SpecialAreaBilling o1, SpecialAreaBilling o2) {
+                            return o2.getPriceCoefficient().compareTo(o1.getPriceCoefficient());
+                        }
+                    });
+                    BigDecimal priceCoefficient = specialAreaBillings.get(0).getPriceCoefficient();
+                    orderPrivateCar.setOrderMoney(Objects.nonNull(orderPrivateCar.getOrderMoney())?new BigDecimal(orderPrivateCar.getOrderMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D);
+                    orderPrivateCar.setStartMoney(Objects.nonNull(orderPrivateCar.getStartMoney())?new BigDecimal(orderPrivateCar.getStartMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D);
+                    orderPrivateCar.setMileageMoney(Objects.nonNull(orderPrivateCar.getMileageMoney())?new BigDecimal(orderPrivateCar.getMileageMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D);
+                    orderPrivateCar.setDurationMoney(Objects.nonNull(orderPrivateCar.getDurationMoney())?new BigDecimal(orderPrivateCar.getDurationMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D);
+                    orderPrivateCar.setWaitMoney(Objects.nonNull(orderPrivateCar.getWaitMoney())?new BigDecimal(orderPrivateCar.getWaitMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D);
+                    orderPrivateCar.setLongDistanceMoney(Objects.nonNull(orderPrivateCar.getLongDistanceMoney())?new BigDecimal(orderPrivateCar.getLongDistanceMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D);
+                    orderPrivateCar.setParkMoney(Objects.nonNull(orderPrivateCar.getParkMoney())?new BigDecimal(orderPrivateCar.getParkMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D);
+                    orderPrivateCar.setRoadTollMoney(Objects.nonNull(orderPrivateCar.getRoadTollMoney())?new BigDecimal(orderPrivateCar.getRoadTollMoney()).multiply(priceCoefficient).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue():0D);
+                }
+            }
+        }
+
         Map<String, Object> map = new HashMap<>();
         map.put("orderMoney", orderPrivateCar.getOrderMoney());//订单金额
         map.put("startMileage", orderPrivateCar.getStartMileage());//起步价
@@ -711,12 +768,6 @@
         map.put("couponMoney", orderPrivateCar.getCouponMoney());//优惠券抵扣金额
         map.put("discountMoney", orderPrivateCar.getDiscountMoney());//折扣抵扣金额
         map.put("discount", orderPrivateCar.getDiscount());//折扣
-        if(Objects.isNull(orderPrivateCar.getEstimatedPrice())){
-            orderPrivateCar.setEstimatedPrice(0D);
-        }
-        if(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()).subtract(new BigDecimal(orderPrivateCar.getEstimatedPrice())).abs().doubleValue() > 3){
-            orderPrivateCar.setIsException(1);
-        }
         map.put("estimatedPrice", orderPrivateCar.getEstimatedPrice());
         map.put("isException", orderPrivateCar.getIsException());//是否异常
         return map;
@@ -1008,9 +1059,11 @@
         OrderPrivateCar orderPrivateCar = this.selectById(orderId);
         orderPrivateCar.setPriceType(priceType);
         orderPrivateCar.setUpdatePrice(updatePrice);
+        orderPrivateCar.setOrderMoney(updatePrice.doubleValue());
         orderPrivateCar.setPriceAuditState(1);
         orderPrivateCar.setState(6);
         this.updateById(orderPrivateCar);
+        appOperationLogService.addAppOperationLog(orderPrivateCar.getDriverId(), "{\"type\":\"司机修改费用\",\"orderId\":\"" + orderPrivateCar.getId() + "\",\"orderInfo\":\"" + JSON.toJSONString(orderPrivateCar) + "\"}");
         // 推送新的价格给用户
         pushUtil.pushOrderMoney(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, updatePrice, 0);
         pushUtil.pushOrderMoney(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, updatePrice, 0);

--
Gitblit v1.7.1