From 6c741ac9e80353ca42906c1c6c7109324ae9f9f9 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 03 十月 2024 01:02:38 +0800
Subject: [PATCH] 修改bug和翻译

---
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java |   78 +++++++++++++++++++++++++--------------
 1 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
index 350283b..4885e2b 100644
--- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
+++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -653,7 +653,7 @@
         BaseWarpper baseWarpper = new BaseWarpper();
         double amount = 0;
         CancleOrder query = cancleOrderService.query(orderPrivateCar.getCompanyId());
-        if(null == query || null == orderPrivateCar.getDriverId()){
+        if(null == query || null == orderPrivateCar.getDriverId() || orderPrivateCar.getState() == 11){
             baseWarpper.setAmount(amount);
             return ResultUtil.success(baseWarpper);
         }
@@ -1259,12 +1259,12 @@
                     //获取红包id
                     JSONArray jsonArray = new JSONArray();
                     for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) {
-                        JSONObject jsonObject = new JSONObject();
-                        jsonObject.put("id", userRedPacketRecord.getId());
-                        BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount());
                         if(multiply1.compareTo(BigDecimal.ZERO) == 0){
                             break;
                         }
+                        JSONObject jsonObject = new JSONObject();
+                        jsonObject.put("id", userRedPacketRecord.getId());
+                        BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount());
                         if(multiply1.compareTo(remainingAmount) >= 0){
                             userRedPacketRecord.setRemainingAmount(0D);
                             userRedPacketRecord.setEndTime(new Date());
@@ -1272,14 +1272,15 @@
                             multiply1 = multiply1.subtract(remainingAmount).setScale(2, RoundingMode.HALF_EVEN);
                             jsonObject.put("money", remainingAmount);
                             jsonArray.add(jsonObject);
-                            userRedPacketRecordService.updateById(userRedPacketRecord);
                         }else if(remainingAmount.compareTo(multiply1) > 0){
                             userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
                             jsonObject.put("money", multiply1);
                             jsonArray.add(jsonObject);
-                            userRedPacketRecordService.updateById(userRedPacketRecord);
                             multiply1 = BigDecimal.ZERO;
                         }
+                    }
+                    if(userRedPacketRecords.size() > 0){
+                        userRedPacketRecordService.updateBatchById(userRedPacketRecords);
                     }
                     orderPrivateCar.setRedPacketId(jsonArray.toJSONString());
                 }
@@ -1288,29 +1289,18 @@
                     orderMoney = orderMoney.subtract(new BigDecimal(total)).setScale(2, RoundingMode.HALF_EVEN);
                     //获取红包id
                     JSONArray jsonArray = new JSONArray();
-                    BigDecimal multiply = new BigDecimal(total);
                     for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) {
                         JSONObject jsonObject = new JSONObject();
                         jsonObject.put("id", userRedPacketRecord.getId());
-                        BigDecimal remainingAmount = BigDecimal.valueOf(userRedPacketRecord.getRemainingAmount());
-                        if(multiply.compareTo(BigDecimal.ZERO) == 0){
-                            break;
-                        }
-                        if(multiply.compareTo(remainingAmount) >= 0){
-                            userRedPacketRecord.setRemainingAmount(0D);
-                            userRedPacketRecord.setEndTime(new Date());
-                            userRedPacketRecord.setState(2);
-                            multiply = multiply.subtract(remainingAmount).setScale(2, RoundingMode.HALF_EVEN);
-                            jsonObject.put("money", remainingAmount);
-                            jsonArray.add(jsonObject);
-                            userRedPacketRecordService.updateById(userRedPacketRecord);
-                        }else if(remainingAmount.compareTo(multiply) > 0){
-                            userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
-                            jsonObject.put("money", multiply);
-                            jsonArray.add(jsonObject);
-                            userRedPacketRecordService.updateById(userRedPacketRecord);
-                            multiply = BigDecimal.ZERO;
-                        }
+                        jsonObject.put("money", userRedPacketRecord.getRemainingAmount());
+                        jsonArray.add(jsonObject);
+    
+                        userRedPacketRecord.setRemainingAmount(0D);
+                        userRedPacketRecord.setEndTime(new Date());
+                        userRedPacketRecord.setState(2);
+                    }
+                    if(userRedPacketRecords.size() > 0){
+                        userRedPacketRecordService.updateBatchById(userRedPacketRecords);
                     }
                     orderPrivateCar.setRedPacketId(jsonArray.toJSONString());
                 }
@@ -1922,6 +1912,7 @@
                     if(null != settlementAllocation){
                         JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent());
                         Double maxPrice = jsonObject.getDouble("maxPrice");
+                        Integer type1 = jsonObject.getInteger("type");
                         if(null != maxPrice){
                             List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId())
                                     .isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')"));
@@ -1932,12 +1923,12 @@
                             //日结算
                             if(maxPrice.compareTo(total.doubleValue()) <= 0){
                                 SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderPrivateCar.getDriverId())
-                                        .eq("type", 1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')"));
+                                        .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')"));
                                 if(null == settlementRecord){
                                     settlementRecord = new SettlementRecord();
                                     settlementRecord.setDay(new Date());
                                     settlementRecord.setDriverId(orderPrivateCar.getDriverId());
-                                    settlementRecord.setType(1);
+                                    settlementRecord.setType(type1);
                                     settlementRecord.setPaymentStatus(1);
                                     settlementRecord.setPayMoney(total.doubleValue());
                                     settlementRecord.setInsertTime(new Date());
@@ -1950,6 +1941,37 @@
                                     detail.setSettlementRecordId(settlementRecord.getId());
                                     settlementDetailService.updateById(detail);
                                 }
+                                //强制司机下班
+                                DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>()
+                                        .eq("driverId", orderPrivateCar.getDriverId()).eq("state", 1));
+                                if(null != driverWork){
+                                    driverWork.setEndTime(new Date());
+                                    driverWork.setState(2);
+                                    driverWorkService.updateById(driverWork);
+                                    driver.setState(1);
+                                    driverService.updateById(driver);
+                                    Car car = carService.selectById(driver.getCarId());
+                                    if(!org.apache.shiro.util.StringUtils.hasLength(car.getVehicleId())){
+                                        car.setVehicleId(UUIDUtil.getRandomCode());
+                                        carService.updateById(car);
+                                    }
+    
+                                    //司机下班,修改谷歌上的车辆信息
+                                    new Thread(()->{
+                                        try {
+                                            CarModel carModel = carModelMapper.selectById(car.getCarModelId());
+                                            String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
+                                            if(ToolUtil.isEmpty(vehicles)){
+                                                fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
+                                                fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
+                                            }else{
+                                                fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
+                                            }
+                                        }catch (Exception e){
+                                            e.printStackTrace();
+                                        }
+                                    }).start();
+                                }
                             }
                         }
                     }

--
Gitblit v1.7.1