From 475993b4a8221e3dd434460569d1c878cdb61495 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 09 一月 2025 15:24:36 +0800
Subject: [PATCH] 司机统计订单,计费规则,司机提现
---
ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 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..3d620ec 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;
@@ -578,6 +582,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> tPubTransactionDetails = pubTransactionDetailsService.selectList(new EntityWrapper<TPubTransactionDetails>()
+ .in("userId", driverIds)
+ .eq("userType", 2)
+ .eq("type", 1)
+ .eq("state", 2)
+ .eq("orderType", 6));
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
for (Map<String, Object> stringObjectMap : driverList) {
// 司机id
Integer id = Integer.valueOf(stringObjectMap.get("id").toString());
@@ -596,6 +612,34 @@
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> dayReduce = orderTaxiList.stream().filter(orderTaxi -> orderTaxi.getDriverId().equals(id)
+ && format.format(orderTaxi.getTravelTime()).equals(format.format(new Date()))
+ && orderTaxi.getState() == 6).map(TOrderTaxi::getPayMoney).reduce(BigDecimal::add);
+ Optional<BigDecimal> dayReduceOut = tPubTransactionDetails.stream().filter(pubTransactionDetails -> pubTransactionDetails.getUserId().equals(id)
+ && format.format(pubTransactionDetails.getInsertTime()).equals(format.format(new Date())))
+ .map(TPubTransactionDetails::getMoney).reduce(BigDecimal::add);
+ dayReduce.ifPresent(bigDecimal -> stringObjectMap.put("dayIncome", bigDecimal.subtract(dayReduceOut.get())));
+ // 过滤所有统计
+ Optional<BigDecimal> sumReduce = orderTaxiList.stream().filter(orderTaxi -> orderTaxi.getDriverId().equals(id)
+ && orderTaxi.getState() == 6).map(TOrderTaxi::getPayMoney).reduce(BigDecimal::add);
+ Optional<BigDecimal> sumReduceOut = tPubTransactionDetails.stream().filter(pubTransactionDetails -> pubTransactionDetails.getUserId().equals(id))
+ .map(TPubTransactionDetails::getMoney).reduce(BigDecimal::add);
+ sumReduce.ifPresent(bigDecimal -> stringObjectMap.put("sumIncome", bigDecimal.subtract(sumReduceOut.get())));
+ }
+
}
page.setRecords(driverList);
return super.packForBT(page);
--
Gitblit v1.7.1