From 46af9e53a6e76b6c0b8cc3291ac1d78e59370831 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 15 八月 2023 18:07:28 +0800
Subject: [PATCH] 更新管理页面

---
 user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java |   69 +++++++++++++++++++++++++++++++---
 1 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java
index b49da12..2bb4eda 100644
--- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java
+++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java
@@ -115,6 +115,9 @@
     @Autowired
     private IOrderService orderService;
 
+    @Autowired
+    private ICompanyFundFlowService companyFundFlowService;
+
     @Value("${wx.appletsAppid}")
     private String appletsAppid;
 
@@ -210,7 +213,9 @@
      */
     public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order, String city){
         order = getOrderInitialPrice(order);
-        SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5));
+        Integer driverId = order.getDriverId();
+        Driver driver = driverService.selectById(driverId);
+        SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5).eq("companyId",driver.getBranchOfficeId()));
         if(null == systemConfig){
             if(type == 1){//预估金额
                 order.setEstimatedPrice(0D);
@@ -311,6 +316,9 @@
         Double num7 = extraCost.getDouble("num7");//恶劣天气超出公里
         Double num8 = extraCost.getDouble("num8");//恶劣天气超出公里单价 X/公里
         Double num9 = extraCost.getDouble("num9");//恶劣天气最高收取金额
+        Double num10 = extraCost.getDouble("num10");//节假日收费
+//        Double num11 = extraCost.getDouble("num11");//恶劣天气最高收取金额
+//        Double num12 = extraCost.getDouble("num12");//恶劣天气最高收取金额
 
         //等待费用
         if(waitTime.compareTo(num1 * 60) >= 0){
@@ -324,13 +332,13 @@
         }
 
         //恶劣天气
-        systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8));
+        systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8).eq("companyId",driver.getBranchOfficeId()));
         if(null != systemConfig){
             JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent());
             Integer num11 = jsonObject1.getInteger("num1");//开启恶劣天气计价
             if(1 == num11){
-                boolean badWeather = WeatherUtil.isBadWeather(city);
-                if(badWeather){
+//                boolean badWeather = WeatherUtil.isBadWeather(city);
+//                if(badWeather){
                     order.setBadWeatherDistance(num5);//恶劣天气公里
                     order.setBadWeatherPrice(num6);//恶劣天气费
                     if(distance.compareTo(num7) > 0){
@@ -350,14 +358,27 @@
                             order.setOverBadWeatherPrice(subtract.doubleValue());//恶劣天气超出公里费
                         }
                     }
-                }
+//                }
+            }
+        }
+
+
+
+        //节假日
+        systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 9).eq("companyId",driver.getBranchOfficeId()));
+        if(null != systemConfig){
+            JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent());
+            Integer num11 = jsonObject1.getInteger("num1");//开启恶劣天气计价
+            if(1 == num11){
+                BigDecimal bigDecimal = new BigDecimal(num10);
+                order.setHolidayPrice(bigDecimal.doubleValue());
             }
         }
 
 
         //计算总金额
         BigDecimal bigDecimal = new BigDecimal(order.getStartPrice() + order.getOverDrivePrice() + order.getLongDistancePrice() + order.getOverLongDistancePrice() +
-                order.getWaitTimePrice() + order.getOutWaitTimePrice() + order.getBadWeatherPrice() + order.getOverBadWeatherPrice() - order.getDiscountAmount()).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                order.getWaitTimePrice() + order.getOutWaitTimePrice() + order.getBadWeatherPrice() + order.getOverBadWeatherPrice()+order.getHolidayPrice() - order.getDiscountAmount()).setScale(2, BigDecimal.ROUND_HALF_EVEN);
 
         if(type == 1){//预估价
             order.setEstimatedPrice(bigDecimal.doubleValue());
@@ -396,6 +417,7 @@
         order.setCouponId(null);//优惠券
         order.setDiscountAmount(0D);//折扣优惠金额
         order.setDiscount(0D);//折扣
+        order.setHolidayPrice(0D);
         return order;
     }
 
@@ -1488,6 +1510,7 @@
             accountChangeDetailService.saveData(accountChangeDetail);
 
             //补贴中分账
+            Double balance = revenueService.queryCompanyBalance();//平台账户余额
             Double discountedPrice = order.getDiscountedPrice();
             List<RechargeRecord> rechargeRecords = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 4).eq("payStatus", 2).gt("surplusDividedAmount", 0).orderBy("createTime"));
             for (RechargeRecord rechargeRecord : rechargeRecords) {
@@ -1513,6 +1536,13 @@
                 }
             }
 
+            CompanyFundFlow companyFundFlow = new CompanyFundFlow();
+            companyFundFlow.setBalance(new BigDecimal(balance));
+            companyFundFlow.setObjectType(1);
+            companyFundFlow.setType(5);
+            companyFundFlow.setMoney(new BigDecimal(order.getDiscountedPrice()));
+            companyFundFlow.setCreateTime(new Date());
+            companyFundFlowService.insert(companyFundFlow);
         }
     }
 
@@ -1961,6 +1991,7 @@
                     }
                     //处理代理商抽佣
                     if(num3 > 0 && null != driver){
+                        Double balance = revenueService.queryAgentBalance(driver.getAgentId());
                         Revenue revenue = new Revenue();
                         revenue.setType(1);
                         revenue.setUserType(3);
@@ -1994,6 +2025,15 @@
                                 }
                             }
                         }
+
+                        CompanyFundFlow companyFundFlow = new CompanyFundFlow();
+                        companyFundFlow.setType(3);
+                        companyFundFlow.setObjectType(2);
+                        companyFundFlow.setObjectId(driver.getAgentId());
+                        companyFundFlow.setBalance(new BigDecimal(balance));
+                        companyFundFlow.setMoney(new BigDecimal(num3));
+                        companyFundFlow.setCreateTime(new Date());
+                        companyFundFlowService.insert(companyFundFlow);
                     }
                 }
             }
@@ -2079,6 +2119,7 @@
             accountChangeDetailService.saveData(accountChangeDetail);
 
             //补贴中分账
+            Double balance = revenueService.queryCompanyBalance();
             Double discountedPrice = order.getDiscountedPrice();
             List<RechargeRecord> rechargeRecords1 = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 4).eq("payStatus", 2).gt("surplusDividedAmount", 0).orderBy("createTime"));
             for (RechargeRecord rechargeRecord : rechargeRecords1) {
@@ -2103,6 +2144,13 @@
                     }
                 }
             }
+            CompanyFundFlow companyFundFlow = new CompanyFundFlow();
+            companyFundFlow.setBalance(new BigDecimal(balance));
+            companyFundFlow.setObjectType(1);
+            companyFundFlow.setType(5);
+            companyFundFlow.setMoney(new BigDecimal(order.getDiscountedPrice()));
+            companyFundFlow.setCreateTime(new Date());
+            companyFundFlowService.insert(companyFundFlow);
 
         }
         // TODO: 2023/6/25 折扣优惠由司机承担
@@ -2243,6 +2291,7 @@
             driverService.updateById(driver);
             accountChangeDetailService.saveData(accountChangeDetail);
             //补贴中分账
+            Double balance = revenueService.queryCompanyBalance();
             Double discountedPrice = order.getDiscountedPrice();
             List<RechargeRecord> rechargeRecords = rechargeRecordService.selectList(new EntityWrapper<RechargeRecord>().eq("type", 4).eq("payStatus", 2).gt("surplusDividedAmount", 0).orderBy("createTime"));
             for (RechargeRecord rechargeRecord : rechargeRecords) {
@@ -2268,6 +2317,14 @@
                 }
             }
 
+            CompanyFundFlow companyFundFlow = new CompanyFundFlow();
+            companyFundFlow.setBalance(new BigDecimal(balance));
+            companyFundFlow.setObjectType(1);
+            companyFundFlow.setType(5);
+            companyFundFlow.setMoney(new BigDecimal(order.getDiscountedPrice()));
+            companyFundFlow.setCreateTime(new Date());
+            companyFundFlowService.insert(companyFundFlow);
+
         }
     }
 

--
Gitblit v1.7.1