EmployeeBadgeMapper.xml
25.6 KB
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<?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="cn.com.glsx.dj.mindworkplate.mapper.EmployeeBadgeMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.EmployeeBadge">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="employee_name" jdbcType="VARCHAR" property="employeeName" />
<result column="phone_number" jdbcType="VARCHAR" property="phoneNumber" />
<result column="badge_id" jdbcType="VARCHAR" property="badgeId" />
<result column="online_status" jdbcType="TINYINT" property="onlineStatus" />
<result column="bind_time" jdbcType="TIMESTAMP" property="bindTime" />
<result column="badge_manufacturer_id" jdbcType="INTEGER" property="badgeManufacturerId" />
<result column="language" jdbcType="INTEGER" property="language" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
<result column="deleted_flag" jdbcType="CHAR" property="deletedFlag" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, employee_name, phone_number, badge_id, online_status, bind_time, badge_manufacturer_id, `language`,
created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
<select id="employeeBadgeReclistWithPage" resultType="cn.com.glsx.dj.mindworkplate.dto.EmployeeBadgeDTO">
select t2.id as id,t2.audio_time as searchdate,t1.employee_name as employeeName, t1.phone_number as phoneNumber, t1.badge_id as badgeId, t1.online_status as onlineStatus, t1.bind_time as bindTime, t1.badge_manufacturer_id as badgeManufacturerId, t1.created_by as createdBy, t1.created_date as createdDate, t1.updated_by as updatedBy, t1.updated_date as updatedDate, t1.deleted_flag as deletedFlag,t2.seconds as seconds,t2.batch_num as batchNum,t2.enter_reception_batch as enterReceptionBatch, t2.score as score,t2.abnormal_proportion as abnormalProportion
from inspection_conversation_date t2
left join inspection_employee_badge t1 on t1.badge_id = t2.badge_id
where 1=1
<if test="condition.servicePhoneList != null and condition.servicePhoneList.size>0">
AND t1.phone_number in
<foreach close=")" collection="condition.servicePhoneList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="condition.storePhoneList != null and condition.storePhoneList.size>0">
AND t1.phone_number in
<foreach close=")" collection="condition.storePhoneList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="condition.recDevList != null and condition.recDevList.size>0">
AND t1.badge_id in
<foreach close=")" collection="condition.recDevList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="condition.recDevListByType != null and condition.recDevListByType.size>0">
AND t1.badge_id in
<foreach close=")" collection="condition.recDevListByType" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="condition.searchdate != null and condition.searchdate != ''">
and t2.audio_time = #{condition.searchdate}
</if>
<if test="condition.searchStartDate != null and condition.searchStartDate != ''">
and t2.audio_time <![CDATA[ >= ]]> #{condition.searchStartDate}
</if>
<if test="condition.searchEndDate != null and condition.searchEndDate != ''">
and t2.audio_time <![CDATA[ <= ]]> #{condition.searchEndDate}
</if>
<if test="condition.employeeName != null and condition.employeeName != ''">
and t1.employee_name like concat('%', #{condition.employeeName}, '%')
</if>
<if test="condition.phoneNumber != null and condition.phoneNumber != ''">
and t1.phone_number like concat('%', #{condition.phoneNumber}, '%')
</if>
<if test="condition.keyword != null and condition.keyword != ''">
and (t1.phone_number like concat('%', #{condition.keyword}, '%') or t1.employee_name like concat('%', #{condition.keyword}, '%'))
</if>
<if test="condition.badgeId != null and condition.badgeId != ''">
and t1.badge_Id= #{condition.badgeId}
</if>
<if test="condition.qualityTestScoreBegin != null">
<![CDATA[ and t2.score>= #{condition.qualityTestScoreBegin} ]]>
</if>
<if test="condition.qualityTestScoreEnd != null">
<![CDATA[ and t2.score<= #{condition.qualityTestScoreEnd} ]]>
</if>
<if test="condition.toStoreCountBeg != null">
<![CDATA[ and t2.enter_reception_batch>= #{condition.toStoreCountBeg} ]]>
</if>
<if test="condition.toStoreCountEnd != null">
<![CDATA[ and t2.enter_reception_batch<= #{condition.toStoreCountEnd} ]]>
</if>
<if test="condition.abnormalProportionBeg != null">
<![CDATA[ and t2.abnormal_proportion>= #{condition.abnormalProportionBeg} ]]>
</if>
<if test="condition.abnormalProportionEnd != null">
<![CDATA[ and t2.abnormal_proportion<= #{condition.abnormalProportionEnd} ]]>
</if>
<if test="condition.employeeSearchList != null and condition.employeeSearchList.size>0">
and (t2.badge_id, t2.audio_time) IN
<foreach item="pair" collection="condition.employeeSearchList" separator="," open="(" close=")">
(#{pair.badgeId}, #{pair.audioTime})
</foreach>
</if>
order by t2.audio_time desc
</select>
<select id="employeeBadgeReclistWithPageV2" resultType="cn.com.glsx.dj.mindworkplate.dto.EmployeeBadgeV2DTO">
select cb.id id,t1.employee_name employeeName,
t2.audio_time searchdate,
cb.id batchId,cb.start_time startTime,cb.end_time endTime,cb.duration duration, cb.score,cb.file_url fileUrl,
re.customer_name customerName,re.car_model carModel,re.reception_status receptionStatus,re.phone_number phoneNumber,re.bussiness_type businessType,
re.merchant_id merchantNo,re.reception_start_time receptionStartTime,
ind.customer_type customerTypeName,
ind.avg_defence defencePoint,if(t3.Is_mentioned=1,true,false) as axbOpenFlag,
ibr.check_history_flag as checkHistoryFlag,ibr.defence_result_flag defence
from inspection_conversation_date t2
left join inspection_employee_badge t1 on t1.badge_id = t2.badge_id
left join inspection_conversation_batch cb on cb.conversation_id = t2.id
left join reception_customer_info re on cb.task_id = re.id
left join inspection_defence ind on ind.batch_id = cb.id and ind.deleted_flag = 'N'
left join inspection_badge_recordings ibr on ibr.id = cb.record_id and ibr.deleted_flag = 'N'
left join recording_batch_model_call_axb t3 on cb.id=t3.batch_id WHERE cb.deleted_flag = 'N'
<if test="condition.servicePhoneList != null and condition.servicePhoneList.size>0">
AND t1.phone_number in
<foreach close=")" collection="condition.servicePhoneList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="recMerchantNo != null and recMerchantNo.size>0">
and re.merchant_id in
<foreach close=")" collection="recMerchantNo" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="condition.customerPhone != null">
AND re.phone_number like concat('%', #{condition.customerPhone}, '%')
</if>
<if test="condition.recDevList != null and condition.recDevList.size>0">
AND t1.badge_id in
<foreach close=")" collection="condition.recDevList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="condition.recDevListByType != null and condition.recDevListByType.size>0">
AND t1.badge_id in
<foreach close=")" collection="condition.recDevListByType" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="condition.searchdate != null and condition.searchdate != ''">
and t2.audio_time = #{condition.searchdate}
</if>
<if test="condition.searchStartDate != null and condition.searchStartDate != ''">
and t2.audio_time <![CDATA[ >= ]]> #{condition.searchStartDate}
</if>
<if test="condition.searchEndDate != null and condition.searchEndDate != ''">
and t2.audio_time <![CDATA[ <= ]]> #{condition.searchEndDate}
</if>
<if test="condition.employeeName != null and condition.employeeName != ''">
and t1.employee_name like concat('%', #{condition.employeeName}, '%')
</if>
<if test="condition.phoneNumber != null and condition.phoneNumber != ''">
and t1.phone_number like concat('%', #{condition.phoneNumber}, '%')
</if>
<if test="condition.keyword != null and condition.keyword != ''">
and (t1.phone_number like concat('%', #{condition.keyword}, '%') or t1.employee_name like concat('%',
#{condition.keyword}, '%'))
</if>
<if test="condition.badgeId != null and condition.badgeId != ''">
and t1.badge_Id= #{condition.badgeId}
</if>
<if test="condition.qualityTestScoreBegin != null">
<![CDATA[ and cb.score>= #{condition.qualityTestScoreBegin} ]]>
</if>
<if test="condition.qualityTestScoreEnd != null">
<![CDATA[ and cb.score<= #{condition.qualityTestScoreEnd} ]]>
</if>
<if test="condition.toStoreCountBeg != null">
<![CDATA[ and t2.enter_reception_batch>= #{condition.toStoreCountBeg} ]]>
</if>
<if test="condition.toStoreCountEnd != null">
<![CDATA[ and t2.enter_reception_batch<= #{condition.toStoreCountEnd} ]]>
</if>
<if test="condition.abnormalProportionBeg != null">
<![CDATA[ and t2.abnormal_proportion>= #{condition.abnormalProportionBeg} ]]>
</if>
<if test="condition.abnormalProportionEnd != null">
<![CDATA[ and t2.abnormal_proportion<= #{condition.abnormalProportionEnd} ]]>
</if>
<if test="condition.employeeSearchList != null and condition.employeeSearchList.size>0">
and (t2.badge_id, t2.audio_time) IN
<foreach item="pair" collection="condition.employeeSearchList" separator="," open="(" close=")">
(#{pair.badgeId}, #{pair.audioTime})
</foreach>
</if>
<if test="condition.customerName != null and condition.customerName != ''">
and re.customer_name like concat('%', #{condition.customerName}, '%')
</if>
<if test="condition.bussinessType != null">
and re.bussiness_type=#{condition.bussinessType}
</if>
<if test="condition.orderTransactionAmount != null ">
and EXISTS (
SELECT 1
FROM customer_order_temp cot
WHERE cot.phone = re.phone_number
AND cot.scene_type+1 = re.bussiness_type
AND cot.order_status IN (4, 6)
AND cot.order_transaction_amount > #{condition.orderTransactionAmount}
)
</if>
<if test="condition.orderTransactionFlag!=null and condition.orderTransactionFlag==1">
and EXISTS (
SELECT 1
FROM customer_order_temp cot
WHERE cot.phone = re.phone_number
AND cot.scene_type+1 = re.bussiness_type
AND cot.order_status IN (4, 6)
)
</if>
<if test="condition.orderTransactionFlag!=null and condition.orderTransactionFlag==0">
and not EXISTS (
SELECT 1
FROM customer_order_temp cot
WHERE cot.phone = re.phone_number
AND cot.scene_type+1 = re.bussiness_type
AND cot.order_status IN (4, 6)
)
</if>
<if test="condition.orderAxbTransactionFlag!=null and condition.orderAxbTransactionFlag==1">
and EXISTS (
SELECT 1
FROM customer_order_temp cot
WHERE cot.phone = re.phone_number
AND cot.scene_type+1 = re.bussiness_type
AND cot.order_status IN (4, 6)
AND(cot.upgrade_goods_name like concat('%', '安心','%')
or cot.upgrade_goods_alias like concat('%', '安心','%')
or cot.package_name like concat('%', '安心','%')
))
</if>
<if test="condition.orderAxbTransactionFlag!=null and condition.orderAxbTransactionFlag==0">
and not EXISTS (
SELECT 1
FROM customer_order_temp cot
WHERE cot.phone = re.phone_number
AND cot.scene_type+1 = re.bussiness_type
AND cot.order_status IN (4, 6)
AND(cot.upgrade_goods_name like concat('%', '安心','%')
or cot.upgrade_goods_alias like concat('%', '安心','%')
or cot.package_name like concat('%', '安心','%')
))
</if>
<if test="condition.carBrandIds!=null and condition.carBrandIds.size()>0">
and (re.car_brandid in
<foreach close=")" collection="condition.carBrandIds" item="item" open="(" separator=",">
#{item}
</foreach>
or re.one_car_brandid in
<foreach close=")" collection="condition.carBrandIds" item="item" open="(" separator=",">
#{item}
</foreach>)
</if>
order by t2.audio_time desc, cb.start_time desc
</select>
<select id="employeeBadgelistWithPage" resultType="cn.com.glsx.dj.mindworkplate.dto.EmployeeBadgeDTO">
select t1.id as id, t1.employee_name as employeeName, t1.phone_number as phoneNumber, t1.badge_id as badgeId, t1.online_status as onlineStatus, t1.bind_time as bindTime, t1.badge_manufacturer_id as badgeManufacturerId
from inspection_employee_badge t1
where 1=1
<if test="condition.employeeName != null and condition.employeeName != ''">
and t1.employee_name like concat('%', #{condition.employeeName}, '%')
</if>
<if test="condition.badgeManufacturerId != null ">
and t1.badge_manufacturer_id = #{condition.badgeManufacturerId}
</if>
<if test="condition.badgeId != null and condition.badgeId != ''">
and t1.badge_id like concat('%', #{condition.badgeId}, '%')
</if>
<if test="condition.phoneNumber != null and condition.phoneNumber != ''">
and t1.phone_number like concat('%', #{condition.phoneNumber}, '%')
</if>
order by t1.bind_time desc
</select>
<select id="findTotalRecordingDuration" resultType="java.lang.Integer">
SELECT SUM(recording_duration) from inspection_employee_badge t1
left join inspection_badge_recordings t2 on t1.badge_id = t2.badge_id
where t2.recording_start_time like concat('%', #{searchdate}, '%')
<if test="phoneList != null and phoneList.size>0">
and phone_number in
<foreach close=")" collection="phoneList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="findTotalBadgeCount" resultType="java.lang.Integer">
SELECT count(1) from inspection_employee_badge
where 1=1
<if test="phoneList != null and phoneList.size >0">
and phone_number in
<foreach close=")" collection="phoneList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="findAverageQualityTestScore" resultType="java.lang.Integer">
select avg(score) from inspection_employee_badge t1
left join inspection_conversation_date t2 on t1.badge_id = t2.badge_id
where audio_time=#{searchdate}
<if test="phoneList != null and phoneList.size>0">
and phone_number in
<foreach close=")" collection="phoneList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="findUploadBadgeCount" resultType="java.lang.Integer">
SELECT count(distinct t1.badge_id) from inspection_employee_badge t1
left join inspection_badge_recordings t2 on t1.badge_id = t2.badge_id
where t2.recording_start_time like concat('%', #{searchdate}, '%')
<if test="phoneList != null and phoneList.size>0">
and phone_number in
<foreach close=")" collection="phoneList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="findByPhone" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from inspection_employee_badge t1
where t1.phone_number = #{phone}
</select>
<select id="findByBadgeId" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from inspection_employee_badge t1
where t1.badge_id = #{badgeId}
</select>
<select id="findTotalRecordingDurationByBadgeId" resultType="cn.com.glsx.dj.mindworkplate.model.BadgeRecordingsTotal">
SELECT t1.badge_id as badgeId,SUM(recording_duration) as badgeRecordingsTotal from inspection_employee_badge t1
left join inspection_badge_recordings t2 on t1.badge_id = t2.badge_id
where t2.recording_start_time like concat('%', #{searchdate}, '%')
<if test="badgeIds != null and badgeIds.size>0">
and t1.badge_id in
<foreach close=")" collection="badgeIds" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
group by t1.badge_id
</select>
<select id="findBadgeInfoByPhoneAndType"
resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from inspection_employee_badge t1
where t1.phone_number = #{phone} and t1.badge_manufacturer_id=#{type}
</select>
<select id="findRealRecCountByDeviceAndDate"
resultType="cn.com.glsx.dj.mindworkplate.dto.EmployeeBadgeDTO">
select t1.badge_id as badgeId,t1.audio_time as searchdate,count(t1.badge_id) as realRecCount from
inspection_conversation_date t1
left join inspection_conversation_batch t2 on t1.id = t2.conversation_id
where t2.score>=20
<if test="deviceList != null and deviceList.size>0">
and t1.badge_id in
<foreach close=")" collection="deviceList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="condition.searchdate != null and condition.searchdate != ''">
and t1.audio_time = #{condition.searchdate}
</if>
<if test="condition.searchStartDate != null and condition.searchStartDate != ''">
and t1.audio_time <![CDATA[ >= ]]> #{condition.searchStartDate}
</if>
<if test="condition.searchEndDate != null and condition.searchEndDate != ''">
and t1.audio_time <![CDATA[ <= ]]> #{condition.searchEndDate}
</if>
group by t1.badge_id,t1.audio_time
</select>
<select id="findPhoneListByRecMerchantNo" resultType="cn.com.glsx.dj.mindworkplate.dto.EmployeeSearch">
select distinct t2.badge_id as badgeId,date_format(t2.recording_start_time,'%Y-%m-%d') as audioTime from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
where 1=1
<!-- 条件1:安心包是否成交(is_anxin_package = 1) -->
<if test="condition.orderAxbTransactionFlag != null">
AND EXISTS (
SELECT 1
FROM dj_smartcarlife.customer_order_temp cot
WHERE cot.phone = t1.phone_number
AND cot.scene_type = #{bussinessType}
AND cot.order_status IN (4, 6)
AND cot.is_anxin_package = 1
<if test="condition.orderTransactionAmount != null">
AND cot.order_transaction_amount > #{condition.orderTransactionAmount}
</if>
)
</if>
<!-- 条件2:是否有成交订单(不关心是否安心包) -->
<if test="condition.orderTransactionFlag != null">
AND EXISTS (
SELECT 1
FROM dj_smartcarlife.customer_order_temp cot
WHERE cot.phone = t1.phone_number
AND cot.scene_type = #{bussinessType}
AND cot.order_status IN (4, 6)
<if test="condition.orderTransactionAmount != null">
AND cot.order_transaction_amount > #{condition.orderTransactionAmount}
</if>
)
</if>
<if test="recMerchantNo != null and recMerchantNo.size>0">
and t1.merchant_id in
<foreach close=")" collection="recMerchantNo" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="merchantList != null and merchantList.size>0">
and t1.merchant_id in
<foreach close=")" collection="merchantList" item="item" open="(" separator=",">
#{item}
</foreach>
</if>
<if test="bussinessType != null">
and t1.bussiness_type=#{condition.bussinessType}
</if>
<if test="searchStartDate != null and searchStartDate != ''">
and date_format(t2.recording_start_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{searchStartDate}
</if>
<if test="searchEndDate != null and searchEndDate != ''">
and date_format(t2.recording_start_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{searchEndDate}
</if>
<if test="searchdate != null">
and date_format(t2.recording_start_time,'%Y-%m-%d')= #{searchdate}
</if>
<if test="condition.customerName != null and condition.customerName != ''">
and t1.customer_name like concat('%',#{condition.customerName},'%')
</if>
<if test="condition.carBrandIds!=null and condition.carBrandIds.size()>0">
and (t1.car_brandid in
<foreach close=")" collection="condition.carBrandIds" item="item" open="(" separator=",">
#{item}
</foreach>
or t1.one_car_brandid in
<foreach close=")" collection="condition.carBrandIds" item="item" open="(" separator=",">
#{item}
</foreach>)
</if>
<if test="condition.enterpriseCustomerFlag != null and condition.enterpriseCustomerFlag ==0 ">
and t1.customer_name not like concat('%','公司','%')
</if>
<if test="condition.enterpriseCustomerFlag != null and condition.enterpriseCustomerFlag ==1 ">
and t1.customer_name like concat('%','公司','%')
</if>
<if test="condition.customerPhone != null and condition.customerPhone != ''">
and t1.phone_number like concat('%',#{condition.customerPhone},'%')
</if>
and t2.badge_id is not null
</select>
<select id="findPhoneListByType" resultType="java.lang.String">
select distinct t2.badge_id from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
where t1.bussiness_type=#{bussinessType}
<if test="searchStartDate != null and searchStartDate != ''">
and date_format(t2.recording_start_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{searchStartDate}
</if>
<if test="searchEndDate != null and searchEndDate != ''">
and date_format(t2.recording_start_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{searchEndDate}
</if>
<if test="searchdate != null">
and date_format(t2.recording_start_time,'%Y-%m-%d')= #{searchdate}
</if>
and t2.badge_id is not null
</select>
<select id="statisticByStaff" resultType="cn.com.glsx.dj.mindworkplate.dto.EmployeeBadgeStatisticDTO"
parameterType="cn.com.glsx.dj.mindworkplate.dto.EmployeeBadgeStatisticDTO">
select
<include refid="statisticByStaffPart1" />
eb.employee_name as employeeName,
count(distinct rc.id) as appReceptionCount ,
sum(if(br.che_result_flag = 2, 1, 0)) as successStatusCount,
sum(if(br.che_result_flag = 3, 1, 0)) as failStatusCount,
sum(if(batch.score <= 20, 1, 0)) as inauthenticReceptionCount,
sum(if(batch.score = 0, 1, 0)) as zeroCount,
t.averageScore as averageScore,
sum(if(rc.reception_status = 0 and batch.score < t.averageScore, 1, 0)) as unqualifiedCount
<include refid="statisticByStaffPart2" />
inner join (
select
<include refid="statisticByStaffPart1" />
ifnull(avg(if(br.che_result_flag = 2, batch.score, null)), 0) as averageScore
<include refid="statisticByStaffPart2" />
<include refid="statisticByStaffPart3" />
) as t on t.merchantId = rc.merchant_id and t.phoneNumber = eb.phone_number
<if test="isGroupByTime">
and t.receptionStartTime = date_format(rc.reception_start_time, '%Y-%m-%d')
</if>
<include refid="statisticByStaffPart3" />
</select>
<select id="findReceptionPhone" resultType="java.lang.String">
select
distinct dclgoc.customer_phone
from dj_car_life_goods_order dclgo
left join dj_car_life_goods_sub_order dclgso
on dclgo.order_code = dclgso.order_code and dclgso.deleted_flag = 'N'
left join dj_car_life_goods_order_customer dclgoc
on dclgoc.order_code = dclgo.order_code and dclgoc.deleted_flag = 'N'
left join dj_car_life_pay_order dclpo on dclpo.order_code = dclgo.order_code and dclpo.deleted_flag = 'N'
where dclgo.deleted_flag = 'N' and dclgo.scene_type = #{condition.bussinessType}
and dclgo.status in (4, 6) and upgrade_flag = 'Y'
<if test="condition.orderTransactionAmount != null ">
and dclgo.total_price> #{condition.orderTransactionAmount}
</if>
</select>
<sql id="statisticByStaffPart1">
rc.merchant_id as merchantId,
eb.phone_number as phoneNumber,
<if test="isGroupByTime">
date_format(rc.reception_start_time, '%Y-%m-%d') as receptionStartTime,
</if>
</sql>
<sql id="statisticByStaffPart2">
from reception_customer_info rc
left join inspection_badge_recordings br on br.reception_id = rc.id and br.deleted_flag = 'N'
left join inspection_conversation_batch batch on br.id = batch.record_id and batch.deleted_flag = 'N'
left join inspection_employee_badge eb on eb.badge_id = br.badge_id and eb.deleted_flag = 'N'
</sql>
<sql id="statisticByStaffPart3">
<where>
rc.deleted_flag = 'N'
and rc.bussiness_type = 1
<if test="merchantIdList != null and merchantIdList.size() > 0">
and rc.merchant_id in
<foreach collection="merchantIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="staffPhoneList != null and staffPhoneList.size() > 0">
and eb.phone_number in
<foreach collection="staffPhoneList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="searchStartDate != null">
and rc.reception_start_time >= #{searchStartDate}
</if>
<if test="searchEndDate != null">
and rc.reception_end_time <= #{searchEndDate}
</if>
</where>
group by rc.merchant_id, eb.phone_number
<if test="isGroupByTime">
, date_format(rc.reception_start_time, '%Y-%m-%d')
</if>
</sql>
</mapper>