Pu Zhibing
2025-03-28 8b09fbc19a96b57bf1d0e4d7c79b51a76aeca554
ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TDriverMapper.xml
@@ -8,8 +8,10 @@
        <result column="account" property="account" />
        <result column="jobNumber" property="jobNumber" />
        <result column="phone" property="phone" />
        <result column="phoneOperator" property="phoneOperator"/>
        <result column="password" property="password" />
        <result column="name" property="name" />
        <result column="lastName" property="lastName" />
        <result column="firstName" property="firstName" />
        <result column="sex" property="sex" />
        <result column="idCard" property="idCard" />
        <result column="companyId" property="companyId" />
@@ -74,7 +76,7 @@
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, account, jobNumber, phone, password, name, sex, idCard, companyId, headImgUrl, faceImgUrl, idCardImgUrl1, idCardImgUrl2, placeOfEmployment, birthday, bankCardNumber, driverNationality, driverNation, driverMaritalStatus, driverLanguageLevel, driverEducation, driverCensus, driverAddress, driverContactAddress, licenseCode, licenselImgUrl, driverAge, driveCard, driveCardImgUrl, driverType, getDriverLicenseDate, driverLicenseOn, driverLicenseOff, taxiDriver, taxiAptitudeCard, networkCarlssueImg, networkCarlssueOrganization, networkCarlssueDate, getNetworkCarProofDate, networkCarProofOn, networkCarProofOff, registerDate, fullTimeDriver, inDriverBlacklist, commercialType, contractCompany, contractOn, contractOff, emergencyContact, emergencyContactPhone, emergencyContactAddress, remark, isPlatCar, carId, authState, state, flag, insertTime, insertUser, updateTime, updateUser, addType,uid,teamId
        id, account, jobNumber, phone, phoneOperator, password, lastName, firstName, sex, idCard, companyId, headImgUrl, faceImgUrl, idCardImgUrl1, idCardImgUrl2, placeOfEmployment, birthday, bankCardNumber, driverNationality, driverNation, driverMaritalStatus, driverLanguageLevel, driverEducation, driverCensus, driverAddress, driverContactAddress, licenseCode, licenselImgUrl, driverAge, driveCard, driveCardImgUrl, driverType, getDriverLicenseDate, driverLicenseOn, driverLicenseOff, taxiDriver, taxiAptitudeCard, networkCarlssueImg, networkCarlssueOrganization, networkCarlssueDate, getNetworkCarProofDate, networkCarProofOn, networkCarProofOff, registerDate, fullTimeDriver, inDriverBlacklist, commercialType, contractCompany, contractOn, contractOff, emergencyContact, emergencyContactPhone, emergencyContactAddress, remark, isPlatCar, carId, authState, state, flag, insertTime, insertUser, updateTime, updateUser, addType,uid,teamId
    </sql>
    <!--根据条件查询待审核司机列表-->
@@ -89,7 +91,7 @@
        else '' end ) as serverStr,driverId from t_driver_service GROUP BY driverId) as ds on ds.driverId = dd.id
        ) as o
        <where>
            FIND_IN_SET(o.authState,'1,4') and o.flag != 3
            FIND_IN_SET(o.authState,'1,4') and o.flag != 3 and o.lastName is not null
            <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
                AND (o.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            </if>
@@ -130,8 +132,17 @@
    <!--根据审核通过的司机列表-->
    <select id="getDriverList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT * FROM (SELECT cc1.`name` as companyName,cc2.`name` as franchiseeName,ci.carLicensePlate,ds.serverStr,IFNULL(oe.evaluateNum,0) as evaluateNum,
        (IFNULL(ot1.taxiNum, 0) + IFNULL(ot3.num, 0) + IFNULL(ot5.num, 0)) as historyNum,(IFNULL(ot2.taxiMoney, 0)+ IFNULL(ot4.money, 0) + IFNULL(ot6.money, 0)) as historyMoney,dd.*,tdt.teamName from t_driver as dd
        SELECT * FROM (
        SELECT cc1.`name` as companyName,
        cc2.`name` as franchiseeName,
        ci.carLicensePlate,
        ds.serverStr,
        IFNULL(oe.evaluateNum,0) as evaluateNum,
        (IFNULL(ot1.taxiNum, 0) + IFNULL(ot3.num, 0) + IFNULL(ot5.num, 0) + IFNULL(ot7.num, 0)) as historyNum,
        (IFNULL(ot2.taxiMoney, 0)+ IFNULL(ot4.money, 0) + IFNULL(ot6.money, 0) + IFNULL(ot8.money, 0)) as historyMoney,
        dd.*,
        tdt.teamName
        from t_driver as dd
        LEFT JOIN t_driver_team tdt on dd.teamId=tdt.id and tdt.state!=3
        LEFT JOIN (select * from t_company where type = 2 and flag != 3) as cc1 on cc1.id = dd.companyId
        LEFT JOIN (select * from t_company where type = 3 and flag != 3) as cc2 on cc2.id = dd.franchiseeId
@@ -147,7 +158,9 @@
        LEFT JOIN (SELECT COUNT(id) as num,driverId FROM t_order_private_car where FIND_IN_SET(state,'7,8,9') GROUP BY driverId) as ot3 on ot3.driverId = dd.id
        LEFT JOIN (SELECT SUM(orderMoney) as money,driverId FROM t_order_private_car where FIND_IN_SET(state,'7,8,9') GROUP BY driverId) as ot4 on ot4.driverId = dd.id
        LEFT JOIN (SELECT COUNT(id) as num,driverId FROM t_order_cross_city where FIND_IN_SET(state,'6,7,8') GROUP BY driverId) as ot5 on ot5.driverId = dd.id
        LEFT JOIN (SELECT SUM(orderMoney) as money,driverId FROM t_order_cross_city where FIND_IN_SET(state,'6,7,8') GROUP BY driverId) as ot6 on ot6.driverId = dd.id) as o
        LEFT JOIN (SELECT SUM(orderMoney) as money,driverId FROM t_order_cross_city where FIND_IN_SET(state,'6,7,8') GROUP BY driverId) as ot6 on ot6.driverId = dd.id
        LEFT JOIN (SELECT COUNT(id) as num,driverId FROM t_order_logistics where FIND_IN_SET(state,'7,8,9') GROUP BY driverId) as ot7 on ot7.driverId = dd.id
        LEFT JOIN (SELECT SUM(orderMoney) as money,driverId FROM t_order_logistics where FIND_IN_SET(state,'7,8,9') GROUP BY driverId) as ot8 on ot8.driverId = dd.id) as o
        <where>
            o.flag != 3
            <if test="roleType != null and roleType != '' and roleType == 1">
@@ -163,7 +176,7 @@
                and o.phone  LIKE CONCAT('%',#{phone},'%')
            </if>
            <if test="name != null and name != ''">
                and o.name  LIKE CONCAT('%',#{name},'%')
                and o.lastName  LIKE CONCAT('%',#{name},'%') or o.firstName  LIKE CONCAT('%',#{name},'%')
            </if>
            <if test="addType != null and addType != ''">
                and o.addType = #{addType}
@@ -293,7 +306,7 @@
        select
        concat('user_',id) as id,
        phone as phone,
        IFNULL(name,nickName) as name,
        IFNULL(CONCAT(firstName, ' ', lastName),nickName) as name,
        1 as uType,
        insertTime as insertTime
        from t_user
@@ -303,7 +316,7 @@
        select
        concat('driver_',id) as id,
        phone as phone,
        name as name,
        CONCAT(firstName, " ", lastName) as name,
        2 as uType,
        insertTime as insertTime
        from
@@ -320,15 +333,29 @@
    <select id="queryDriverIncomeData" parameterType="com.baomidou.mybatisplus.plugins.Page" resultType="map">
        SELECT
            td.id as id,
            td.`name` as driverName,
            CONCAT(td.firstName, " ", td.lastName) as driverName,
            tc1.name as companyName,
            tc2.name as franchiseeName,
            <if test="1 == type">
                topc1.num as privateCarTotalNum,
                IFNULL(topc1.num, 0) as privateCarTotalNum,
                IFNULL(topc2.num, 0) as privateCarNotPayNum,
                IFNULL(topc3.num, 0) as privateCarcancelNum,
                IFNULL(topc4.taxiMoney, 0) as privateCarTotalMoney,
                IFNULL(topc5.taxiMoney, 0) as privateCarNotPayMoney,
                IFNULL(topc4.taxiMoney, 0) + IFNULL(topc11.taxiMoney, 0) + IFNULL(topc13.taxiMoney, 0) as privateCarTotalMoney,
                IFNULL(topc5.taxiMoney, 0) + IFNULL(topc13.taxiMoney, 0) as privateCarNotPayMoney,
            </if>
            <if test="4 == type">
                IFNULL(topc6.num, 0) as privateCarTotalNum,
                IFNULL(topc7.num, 0) as privateCarNotPayNum,
                IFNULL(topc8.num, 0) as privateCarcancelNum,
                IFNULL(topc9.taxiMoney, 0) + IFNULL(topc12.taxiMoney, 0) + IFNULL(topc14.taxiMoney, 0) as privateCarTotalMoney,
                IFNULL(topc10.taxiMoney, 0) + IFNULL(topc14.taxiMoney, 0) as privateCarNotPayMoney,
            </if>
            <if test="null == type">
                IFNULL(topc1.num, 0) + IFNULL(topc6.num, 0) as privateCarTotalNum,
                IFNULL(topc2.num, 0) + IFNULL(topc7.num, 0) as privateCarNotPayNum,
                IFNULL(topc3.num, 0) + IFNULL(topc8.num, 0) as privateCarcancelNum,
                IFNULL(topc4.taxiMoney, 0) + IFNULL(topc9.taxiMoney, 0) + IFNULL(topc11.taxiMoney, 0) + IFNULL(topc12.taxiMoney, 0) + IFNULL(topc13.taxiMoney, 0) + IFNULL(topc14.taxiMoney, 0) as privateCarTotalMoney,
                IFNULL(topc5.taxiMoney, 0) + IFNULL(topc10.taxiMoney, 0) + IFNULL(topc13.taxiMoney, 0) + IFNULL(topc14.taxiMoney, 0) as privateCarNotPayMoney,
            </if>
            td.state as driverState,
            td.phone as driverPhone
@@ -336,8 +363,8 @@
        t_driver td
        LEFT JOIN (SELECT id,name FROM t_company WHERE FIND_IN_SET(type, '1,2') AND flag != 3 ) AS tc1 ON td.companyId=tc1.id
        LEFT JOIN ( SELECT id,name FROM t_company WHERE type = 3 AND flag != 3 ) AS tc2 ON tc2.id = td.franchiseeId
        <if test="1 == type">
        INNER JOIN ( SELECT COUNT(id) AS num, driverId FROM t_order_private_car WHERE FIND_IN_SET(state, '7,8,9,10,12')
        <if test="null == type or 1 == type">
        LEFT JOIN ( SELECT COUNT(id) AS num, driverId FROM t_order_private_car WHERE FIND_IN_SET(state, '7,8,9,10,12')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
@@ -355,18 +382,86 @@
            </if>
        GROUP BY driverId
        ) AS topc3 ON topc3.driverId = td.id
        LEFT JOIN ( SELECT SUM(orderMoney) AS taxiMoney, driverId FROM t_order_private_car WHERE FIND_IN_SET(state, '7,8,9,12')
        LEFT JOIN ( SELECT SUM(orderMoney) AS taxiMoney, driverId FROM t_order_private_car WHERE FIND_IN_SET(state, '8,9')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
        GROUP BY driverId
        ) AS topc4 ON topc4.driverId = td.id
        LEFT JOIN ( SELECT SUM(orderMoney) AS taxiMoney, driverId FROM t_order_private_car WHERE FIND_IN_SET(state, '7,12')
        LEFT JOIN ( SELECT SUM(orderMoney) AS taxiMoney, driverId FROM t_order_private_car WHERE FIND_IN_SET(state, '7')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
        GROUP BY driverId
        ) AS topc5 ON topc5.driverId = td.id
            LEFT JOIN (
            SELECT SUM(a.money) AS taxiMoney, b.driverId FROM t_order_cancel a
            left join t_order_private_car b on (a.orderId = b.id and a.orderType = 1)
            where FIND_IN_SET(b.state, '10')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(b.travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            group by b.driverId
            ) AS topc11 ON topc11.driverId = td.id
        LEFT JOIN (
            SELECT SUM(a.money) AS taxiMoney, b.driverId FROM t_order_cancel a
            left join t_order_private_car b on (a.orderId = b.id and a.orderType = 1)
            where FIND_IN_SET(b.state, '12')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(b.travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            group by b.driverId
        ) AS topc13 ON topc13.driverId = td.id
        </if>
        <if test="null == type or 4 == type">
            LEFT JOIN ( SELECT COUNT(id) AS num, driverId FROM t_order_logistics WHERE FIND_IN_SET(state, '7,8,9,10,12')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            GROUP BY driverId
            ) AS topc6 ON topc6.driverId = td.id
            LEFT JOIN ( SELECT COUNT(id) AS num, driverId FROM t_order_logistics WHERE FIND_IN_SET(state, '7,12')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            GROUP BY driverId
            ) AS topc7 ON topc7.driverId = td.id
            LEFT JOIN ( SELECT COUNT(id) AS num, driverId FROM t_order_logistics WHERE FIND_IN_SET(state, '10,12')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            GROUP BY driverId
            ) AS topc8 ON topc8.driverId = td.id
            LEFT JOIN ( SELECT SUM(orderMoney) AS taxiMoney, driverId FROM t_order_logistics WHERE FIND_IN_SET(state, '8,9')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            GROUP BY driverId
            ) AS topc9 ON topc9.driverId = td.id
            LEFT JOIN ( SELECT SUM(orderMoney) AS taxiMoney, driverId FROM t_order_logistics WHERE FIND_IN_SET(state, '7')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            GROUP BY driverId
            ) AS topc10 ON topc10.driverId = td.id
            LEFT JOIN (
            SELECT SUM(a.money) AS taxiMoney, b.driverId FROM t_order_cancel a
            left join t_order_logistics b on (a.orderId = b.id and a.orderType = 4)
            where FIND_IN_SET(b.state, '10')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(b.travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            group by b.driverId
            ) AS topc12 ON topc12.driverId = td.id
            LEFT JOIN (
            SELECT SUM(a.money) AS taxiMoney, b.driverId FROM t_order_cancel a
            left join t_order_logistics b on (a.orderId = b.id and a.orderType = 4)
            where FIND_IN_SET(b.state, '12')
            <if test="null != start and '' != start and null != end and '' != end">
                and DATE_FORMAT(b.travelTime, '%Y-%m-%d') between #{start} and #{end}
            </if>
            group by b.driverId
            ) AS topc14 ON topc14.driverId = td.id
        </if>
        <where>
            <if test="null!= companyId and '' != companyId">
@@ -379,7 +474,7 @@
    <select id="queryDriverIncomeDataNoPage"  resultType="map">
        SELECT
        td.id as id,
        td.`name` as driverName,
        CONCAT(td.firstName, " ", td.lastName) as driverName,
        tc1.name as companyName,
        tc2.name as franchiseeName,
        <if test="1 == type">