Pu Zhibing
2 天以前 3ed8156b12d445bb4e374a7ee43696c60c10c58c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stylefeng.guns.modular.system.dao.DriverMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Driver">
        <id column="id" property="id" />
        <result column="account" property="account" />
        <result column="jobNumber" property="jobNumber" />
        <result column="phone" property="phone" />
        <result column="password" property="password" />
        <result column="name" property="name" />
        <result column="sex" property="sex" />
        <result column="idCard" property="idCard" />
        <result column="companyId" property="companyId" />
        <result column="franchiseeId" property="franchiseeId" />
        <result column="headImgUrl" property="headImgUrl" />
        <result column="faceImgUrl" property="faceImgUrl" />
        <result column="idCardImgUrl1" property="idCardImgUrl1" />
        <result column="idCardImgUrl2" property="idCardImgUrl2" />
        <result column="placeOfEmployment" property="placeOfEmployment" />
        <result column="birthday" property="birthday" />
        <result column="bankCardNumber" property="bankCardNumber" />
        <result column="driverNationality" property="driverNationality" />
        <result column="driverNation" property="driverNation" />
        <result column="driverMaritalStatus" property="driverMaritalStatus" />
        <result column="driverLanguageLevel" property="driverLanguageLevel" />
        <result column="driverEducation" property="driverEducation" />
        <result column="driverCensus" property="driverCensus" />
        <result column="driverAddress" property="driverAddress" />
        <result column="driverContactAddress" property="driverContactAddress" />
        <result column="driverAge" property="driverAge" />
        <result column="driveCard" property="driveCard" />
        <result column="driveCardImgUrl" property="driveCardImgUrl" />
        <result column="driverType" property="driverType" />
        <result column="getDriverLicenseDate" property="getDriverLicenseDate" />
        <result column="driverLicenseOn" property="driverLicenseOn" />
        <result column="driverLicenseOff" property="driverLicenseOff" />
        <result column="taxiDriver" property="taxiDriver" />
        <result column="taxiAptitudeCard" property="taxiAptitudeCard" />
        <result column="networkCarlssueImg" property="networkCarlssueImg"/>
        <result column="networkCarlssueOrganization" property="networkCarlssueOrganization" />
        <result column="networkCarlssueDate" property="networkCarlssueDate" />
        <result column="getNetworkCarProofDate" property="getNetworkCarProofDate" />
        <result column="networkCarProofOn" property="networkCarProofOn" />
        <result column="networkCarProofOff" property="networkCarProofOff" />
        <result column="registerDate" property="registerDate" />
        <result column="fullTimeDriver" property="fullTimeDriver" />
        <result column="inDriverBlacklist" property="inDriverBlacklist" />
        <result column="commercialType" property="commercialType" />
        <result column="contractCompany" property="contractCompany" />
        <result column="contractOn" property="contractOn" />
        <result column="contractOff" property="contractOff" />
        <result column="emergencyContact" property="emergencyContact" />
        <result column="emergencyContactPhone" property="emergencyContactPhone" />
        <result column="emergencyContactAddress" property="emergencyContactAddress" />
        <result column="remark" property="remark" />
        <result column="isPlatCar" property="isPlatCar" />
        <result column="carId" property="carId" />
        <result column="authState" property="authState" />
        <result column="state" property="state" />
        <result column="addType" property="addType" />
        <result column="balance" property="balance" />
        <result column="activityMoney" property="activityMoney" />
        <result column="laveActivityMoney" property="laveActivityMoney" />
        <result column="businessMoney" property="businessMoney" />
        <result column="laveBusinessMoney" property="laveBusinessMoney" />
        <result column="laveBusinessMoney" property="laveBusinessMoney" />
        <result column="appletsOpenId" property="appletsOpenId"/>
 
 
        <result column="flag" property="flag"/>
        <result column="insertTime" property="insertTime"/>
        <result column="insertUser" property="insertUser"/>
        <result column="updateTime" property="updateTime"/>
        <result column="updateUser" property="updateUser"/>
    </resultMap>
 
 
 
    <select id="queryIdleDriver" resultType="Driver">
        select
        id as id,
        account as account,
        jobNumber as jobNumber,
        phone as phone,
        password as password,
        name as name,
        sex as sex,
        idCard as idCard,
        companyId as companyId,
        franchiseeId as franchiseeId,
        headImgUrl as headImgUrl,
        faceImgUrl as faceImgUrl,
        idCardImgUrl1 as idCardImgUrl1,
        idCardImgUrl2 as idCardImgUrl2,
        placeOfEmployment as placeOfEmployment,
        birthday as birthday,
        bankCardNumber as bankCardNumber,
        driverNationality as driverNationality,
        driverNation as driverNation,
        driverMaritalStatus as driverMaritalStatus,
        driverLanguageLevel as driverLanguageLevel,
        driverEducation as driverEducation,
        driverCensus as driverCensus,
        driverAddress as driverAddress,
        driverContactAddress as driverContactAddress,
        driverAge as driverAge,
        driveCard as driveCard,
        driveCardImgUrl as driveCardImgUrl,
        driverType as driverType,
        getDriverLicenseDate as getDriverLicenseDate,
        driverLicenseOn as driverLicenseOn,
        driverLicenseOff as driverLicenseOff,
        taxiDriver as taxiDriver,
        taxiAptitudeCard as taxiAptitudeCard,
        networkCarlssueImg as networkCarlssueImg,
        networkCarlssueOrganization as networkCarlssueOrganization,
        networkCarlssueDate as networkCarlssueDate,
        getNetworkCarProofDate as getNetworkCarProofDate,
        networkCarProofOn as networkCarProofOn,
        networkCarProofOff as networkCarProofOff,
        registerDate as registerDate,
        fullTimeDriver as fullTimeDriver,
        inDriverBlacklist as inDriverBlacklist,
        commercialType as commercialType,
        contractCompany as contractCompany,
        contractOn as contractOn,
        contractOff as contractOff,
        emergencyContact as emergencyContact,
        emergencyContactPhone as emergencyContactPhone,
        emergencyContactAddress as emergencyContactAddress,
        remark as remark,
        isPlatCar as isPlatCar,
        carId as carId,
        authState as authState,
        state as state,
        addType as addType,
        balance as balance,
        flag as flag,
        insertTime as insertTime,
        insertUser as insertUser,
        updateTime as updateTime,
        updateUser as updateUser
        from t_driver
        where flag != 3 and state = 2 and authState = 2
        <if test="null != companyId">
            <choose>
                <when test="companyId != 1">
                    and companyId = #{companyId} or franchiseeId = #{companyId}
                </when>
                <otherwise>
                    and companyId is null or companyId = 0 or companyId = 1 or franchiseeId is null or franchiseeId = 0
                </otherwise>
            </choose>
 
        </if>
        and id in
        (
          select driverId from t_driver_work where startTime &lt; now() and state = 1 and `type` like CONCAT('%', #{type}, '%')
        )
        and id in (select driverId from t_driver_orders where `type` = #{type})
    </select>
 
 
 
 
    <select id="queryIdleDriver_" resultType="Driver">
        select
        id as id,
        account as account,
        jobNumber as jobNumber,
        phone as phone,
        password as password,
        name as name,
        sex as sex,
        idCard as idCard,
        companyId as companyId,
        franchiseeId as franchiseeId,
        headImgUrl as headImgUrl,
        faceImgUrl as faceImgUrl,
        idCardImgUrl1 as idCardImgUrl1,
        idCardImgUrl2 as idCardImgUrl2,
        placeOfEmployment as placeOfEmployment,
        birthday as birthday,
        bankCardNumber as bankCardNumber,
        driverNationality as driverNationality,
        driverNation as driverNation,
        driverMaritalStatus as driverMaritalStatus,
        driverLanguageLevel as driverLanguageLevel,
        driverEducation as driverEducation,
        driverCensus as driverCensus,
        driverAddress as driverAddress,
        driverContactAddress as driverContactAddress,
        driverAge as driverAge,
        driveCard as driveCard,
        driveCardImgUrl as driveCardImgUrl,
        driverType as driverType,
        getDriverLicenseDate as getDriverLicenseDate,
        driverLicenseOn as driverLicenseOn,
        driverLicenseOff as driverLicenseOff,
        taxiDriver as taxiDriver,
        taxiAptitudeCard as taxiAptitudeCard,
        networkCarlssueImg as networkCarlssueImg,
        networkCarlssueOrganization as networkCarlssueOrganization,
        networkCarlssueDate as networkCarlssueDate,
        getNetworkCarProofDate as getNetworkCarProofDate,
        networkCarProofOn as networkCarProofOn,
        networkCarProofOff as networkCarProofOff,
        registerDate as registerDate,
        fullTimeDriver as fullTimeDriver,
        inDriverBlacklist as inDriverBlacklist,
        commercialType as commercialType,
        contractCompany as contractCompany,
        contractOn as contractOn,
        contractOff as contractOff,
        emergencyContact as emergencyContact,
        emergencyContactPhone as emergencyContactPhone,
        emergencyContactAddress as emergencyContactAddress,
        remark as remark,
        isPlatCar as isPlatCar,
        carId as carId,
        authState as authState,
        state as state,
        addType as addType,
        balance as balance,
        flag as flag,
        insertTime as insertTime,
        insertUser as insertUser,
        updateTime as updateTime,
        updateUser as updateUser
        from t_driver
        where flag != 3 and state = 2 and authState = 2
        <if test="null != companyId">
            <choose>
                <when test="companyId != 1">
                    and companyId = #{companyId} or franchiseeId = #{companyId}
                </when>
                <otherwise>
                    and companyId is null or companyId = 0 or companyId = 1 or franchiseeId is null or franchiseeId = 0
                </otherwise>
            </choose>
 
        </if>
        and id in
        (
        select driverId from t_driver_work where startTime &lt; now() and state = 1 and `type` like CONCAT('%', #{type}, '%')
        )
        and id in (select driverId from t_driver_orders where `type` = #{type})
        and carId in (select carId from t_car_service where `type` = #{type}
        <if test="null != serverCarModelId">
            and serverCarModelId = #{serverCarModelId}
        </if>
        )
    </select>
 
 
 
    <select id="queryOrderDriver" resultType="map">
        select
        b.id as orderId,
        b.state as state,
        a.id as driverId,
        a.`name` as `name`,
        a.headImgUrl as avatar,
        a.phone as phone,
        c.carLicensePlate as carCode,
        CONCAT(f.`name`, d.`name`,  '.', c.carColor) as carName,
        (select sum(fraction) / count(id) from t_order_evaluate where driverId = a.id) as score,
        (
        (select count(id) from t_order_private_car where state in (7, 8, 9) and driverId = a.id) +
        (select count(id) from t_order_taxi where state in (7, 8, 9) and driverId = a.id) +
        (select count(id) from t_order_cross_city where state in (6, 8, 9) and driverId = a.id)
        ) as num,
        DATE_FORMAT(b.startServiceTime, '%m月%d日 %H:%i') as `time`,
        b.startAddress as `start`,
        b.endAddress as `end`
        from t_driver a
        <if test="orderType == 1">
            left join t_order_private_car b on (a.id = b.driverId)
        </if>
        <if test="orderType == 2">
            left join t_order_taxi b on (a.id = b.driverId)
        </if>
        <if test="orderType == 3">
            left join t_order_cross_city b on (a.id = b.driverId)
        </if>
        <if test="orderType == 4">
            left join t_order_tat_order_logisticsxi b on (a.id = b.driverId)
        </if>
        <if test="orderType == 5">
            left join t_order_logistics b on (a.id = b.driverId)
        </if>
        left join t_car c on (b.carId = c.id)
        left join t_car_model d on (c.carModelId = d.id)
        left join t_car_brand f on (d.brandId = f.id)
        where b.id = #{orderId}
    </select>
 
 
 
    <select id="queryDriverInfo" resultType="map">
        select
        a.id as id,
        a.headImgUrl as avatar,
        a.`name` as `name`,
        a.phone as phone,
        a.idCard as idcode,
        b.carLicensePlate as licensePlate,
        b.carColor as carColor,
        CONCAT(d.`name`, c.`name`) as brand,
        if((select count(id) from t_driver_work where state = 1 and driverId = a.id) = 0, 1, if(
        (
        (select count(id) from t_order_private_car where state not in (6, 7, 8, 9, 10, 12) and driverId = a.id) +
        (select count(id) from t_order_taxi where state not in (6, 7, 8, 9, 10, 12) and driverId = a.id) +
        (select count(id) from t_order_cross_city where state not in (6, 7, 8, 9, 10, 12) and driverId = a.id)
        ) = 0, 2, 3)) as state,
        (
        (select count(id) from t_order_private_car where state in (7, 8, 9) and driverId = a.id) +
        (select count(id) from t_order_taxi where state in (7, 8, 9) and driverId = a.id) +
        (select count(id) from t_order_cross_city where state in (6, 8, 9) and driverId = a.id)
        ) as orderNum,
        ((select sum(fraction) from t_order_evaluate where driverId = a.id) / (select count(id) from t_order_evaluate where driverId = a.id)) as fraction
        from t_driver a
        left join t_car b on (a.carId = b.id)
        left join t_car_model c on (b.carModelId = c.id)
        left join t_car_brand d on (c.brandId = d.id)
        where a.id = #{id}
    </select>
</mapper>