无关风月
2025-01-16 aa0e37185b47cb59a8f90bcd81c2416ed0f24cfb
ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -26,6 +26,8 @@
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;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +43,7 @@
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 司机审核列表控制器
@@ -56,6 +59,8 @@
    @Autowired
    private ITDriverService tDriverService;
    @Autowired
    private ITOrderTaxiService orderTaxiService;
    @Autowired
    private ITCompanyService tCompanyService;
@@ -577,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> 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());
@@ -595,6 +612,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);
@@ -879,7 +920,9 @@
        tDriver.setUpdateTime(new Date());
        tDriver.setUpdateUser(ShiroKit.getUser().getId());
//        tDriver.setPassword(MD5Util.encrypt(tDriver.getPassword()));
//        tDriver.setPassword(ShiroKit.md5(tDriver.getPassword(), "SA;d5#"));
        if(StringUtils.hasLength(tDriver.getPassword())){
            tDriver.setPassword(ShiroKit.md5(tDriver.getPassword(), "SA;d5#"));
        }
        tDriverService.updateById(tDriver);
        //删除业务