无关风月
2025-01-16 aa0e37185b47cb59a8f90bcd81c2416ed0f24cfb
ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -586,13 +586,13 @@
        // 查询司机订单
        List<TOrderTaxi> orderTaxiList = orderTaxiService.selectList(new EntityWrapper<TOrderTaxi>()
                .in("driverId", driverIds));
        // 查询司机所有的扣款
        List<TPubTransactionDetails> tPubTransactionDetails = pubTransactionDetailsService.selectList(new EntityWrapper<TPubTransactionDetails>()
        // 查询司机所有的收入
        List<TPubTransactionDetails> tPubTransactionDetailsIncome = pubTransactionDetailsService.selectList(new EntityWrapper<TPubTransactionDetails>()
                .in("userId", driverIds)
                .eq("userType", 2)
                .eq("type", 1)
                .eq("state", 2)
                .eq("orderType", 6));
                .eq("state",1)
                .eq("orderType", 2));
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        for (Map<String, Object> stringObjectMap : driverList) {
            // 司机id
@@ -625,19 +625,15 @@
                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)
                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);
                dayReduce.ifPresent(bigDecimal -> stringObjectMap.put("dayIncome", bigDecimal.subtract(dayReduceOut.get())));
                dayReduceIncome.ifPresent(bigDecimal -> stringObjectMap.put("dayIncome", bigDecimal));
                // 过滤所有统计
                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))
                Optional<BigDecimal> sumReduceIncome = tPubTransactionDetailsIncome.stream().filter(pubTransactionDetails -> pubTransactionDetails.getUserId().equals(id))
                        .map(TPubTransactionDetails::getMoney).reduce(BigDecimal::add);
                sumReduce.ifPresent(bigDecimal -> stringObjectMap.put("sumIncome", bigDecimal.subtract(sumReduceOut.get())));
                sumReduceIncome.ifPresent(bigDecimal -> stringObjectMap.put("sumIncome", bigDecimal));
            }
        }