From 06ecfd333bfdce96fab3ee4c056ee12782435e10 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期三, 12 二月 2025 16:35:42 +0800
Subject: [PATCH] 补充

---
 ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java |   52 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java b/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
index 13c1741..829f722 100644
--- a/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
+++ b/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -26,6 +26,7 @@
 import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
+import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.ui.Model;
@@ -42,6 +43,7 @@
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 司机审核列表控制器
@@ -57,6 +59,8 @@
 
     @Autowired
     private ITDriverService tDriverService;
+    @Autowired
+    private ITOrderTaxiService orderTaxiService;
 
     @Autowired
     private ITCompanyService tCompanyService;
@@ -105,7 +109,8 @@
      */
     @RequestMapping("/tDriver_add")
     public String tDriverAdd(Model model) {
-        List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2));
+        List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2)
+                .ne("flag",3));
         model.addAttribute("companyList",companyList);
 
         Integer roleType = ShiroKit.getUser().getRoleType();
@@ -184,12 +189,15 @@
         model.addAttribute("objectName",tCompanyService.selectById(ShiroKit.getUser().getObjectId()).getName());
 
         if (1 == roleType){
-            List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2));
+            List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2)
+                    .ne("flag",3));
             model.addAttribute("companyList",companyList);
-            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId",tDriver.getCompanyId()));
+            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>()
+                    .ne("flag",3).eq("type", 3).eq("superiorId",tDriver.getCompanyId()));
             model.addAttribute("franchiseeList",franchiseeList);
         }else if (2 == roleType){
-            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId",ShiroKit.getUser().getObjectId()));
+            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>()
+                    .ne("flag",3).eq("type", 3).eq("superiorId",ShiroKit.getUser().getObjectId()));
             model.addAttribute("franchiseeList",franchiseeList);
         }
 
@@ -578,6 +586,18 @@
         Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
         List<Map<String, Object>> driverList = tDriverService.getDriverList(page, ShiroKit.getUser().getRoleType(), ShiroKit.getUser().getObjectId(),
                 beginTime, endTime, companyName, phone, name, addType, authState);
+        List<Integer> driverIds = driverList.stream().map(map -> Integer.valueOf(map.get("id").toString())).collect(Collectors.toList());
+        // 查询司机订单
+        List<TOrderTaxi> orderTaxiList = orderTaxiService.selectList(new EntityWrapper<TOrderTaxi>()
+                .in("driverId", driverIds));
+        // 查询司机所有的收入
+        List<TPubTransactionDetails> tPubTransactionDetailsIncome = pubTransactionDetailsService.selectList(new EntityWrapper<TPubTransactionDetails>()
+                .in("userId", driverIds)
+                .eq("userType", 2)
+                .eq("type", 1)
+                .eq("state",1)
+                .eq("orderType", 2));
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         for (Map<String, Object> stringObjectMap : driverList) {
             // 司机id
             Integer id = Integer.valueOf(stringObjectMap.get("id").toString());
@@ -596,6 +616,30 @@
                 String formattedV = df.format(v);
                 stringObjectMap.put("fraction",formattedV);
             }
+
+            // 司机订单统计
+            if(CollectionUtils.isEmpty(orderTaxiList)){
+                stringObjectMap.put("dayReceivingOrders", 0);
+                stringObjectMap.put("sumReceivingOrders", 0);
+                stringObjectMap.put("dayIncome", 0);
+                stringObjectMap.put("sumIncome", 0);
+            }else {
+                long dayReceivingOrders = orderTaxiList.stream().filter(orderTaxi -> orderTaxi.getDriverId().equals(id) && format.format(orderTaxi.getTravelTime()).equals(format.format(new Date()))).count();
+                stringObjectMap.put("dayReceivingOrders", dayReceivingOrders);
+                long sumReceivingOrders = orderTaxiList.stream().filter(orderTaxi -> orderTaxi.getDriverId().equals(id)).count();
+                stringObjectMap.put("sumReceivingOrders", sumReceivingOrders);
+                // 今日统计收入
+                Optional<BigDecimal> dayReduceIncome = tPubTransactionDetailsIncome.stream().filter(pubTransactionDetails -> pubTransactionDetails.getUserId().equals(id)
+                                && format.format(pubTransactionDetails.getInsertTime()).equals(format.format(new Date())))
+                        .map(TPubTransactionDetails::getMoney).reduce(BigDecimal::add);
+                dayReduceIncome.ifPresent(bigDecimal -> stringObjectMap.put("dayIncome", bigDecimal));
+
+                // 过滤所有统计
+                Optional<BigDecimal> sumReduceIncome = tPubTransactionDetailsIncome.stream().filter(pubTransactionDetails -> pubTransactionDetails.getUserId().equals(id))
+                        .map(TPubTransactionDetails::getMoney).reduce(BigDecimal::add);
+                sumReduceIncome.ifPresent(bigDecimal -> stringObjectMap.put("sumIncome", bigDecimal));
+            }
+
         }
         page.setRecords(driverList);
         return super.packForBT(page);

--
Gitblit v1.7.1