ReceptionCustomerInfoMapper.xml
43.3 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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
<?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.ReceptionCustomerInfoMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="merchant_id" property="merchantId" jdbcType="VARCHAR" />
<result column="customer_name" property="customerName" jdbcType="VARCHAR" />
<result column="phone_number" property="phoneNumber" jdbcType="VARCHAR" />
<result column="sales_uuid" property="salesUuid" jdbcType="VARCHAR" />
<result column="sales_name" property="salesName" jdbcType="VARCHAR" />
<result column="car_model" property="carModel" jdbcType="VARCHAR" />
<result column="reception_start_time" property="receptionStartTime" jdbcType="TIMESTAMP" />
<result column="reception_end_time" property="receptionEndTime" jdbcType="TIMESTAMP" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="car_purchase_method" property="carPurchaseMethod" jdbcType="INTEGER" />
</resultMap>
<resultMap id="BaseResultDTOMap" type="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerInfoDTO" autoMapping="true">
<id column="id" property="id" jdbcType="INTEGER" />
<id column="bussiness_type" property="bussinessType" jdbcType="INTEGER" />
<result column="merchant_id" property="merchantId" jdbcType="VARCHAR" />
<result column="customer_name" property="customerName" jdbcType="VARCHAR" />
<result column="phone_number" property="phoneNumber" jdbcType="VARCHAR" />
<result column="sales_uuid" property="salesUuid" jdbcType="VARCHAR" />
<result column="sales_name" property="salesName" jdbcType="VARCHAR" />
<result column="car_model" property="carModel" jdbcType="VARCHAR" />
<result column="car_brand" property="carBrand" jdbcType="VARCHAR" />
<result column="reception_start_time" property="receptionStartTime" jdbcType="TIMESTAMP" />
<result column="reception_end_time" property="receptionEndTime" jdbcType="TIMESTAMP" />
<result column="reception_status" property="receptionStatus" jdbcType="INTEGER"/>
<result column="staff_uuid" property="staffUuid" jdbcType="VARCHAR" />
<result column="checkHistoryFlag" property="checkHistoryFlag" jdbcType="INTEGER"/>
<result column="batchId" property="batchId" jdbcType="INTEGER"/>
<result column="score" property="score" jdbcType="DOUBLE"/>
<result column="recordingUrl" property="recordingUrl" jdbcType="VARCHAR"/>
<result column="one_Car_Brand" property="oneCarBrand" jdbcType="VARCHAR"/>
<result column="reviewFlag" property="reviewFlag" jdbcType="INTEGER"/>
<result column="recordId" property="recordId" jdbcType="INTEGER"/>
<result column="isOrderFinishFlagName" property="isOrderFinishFlagName" jdbcType="VARCHAR"/>
<result column="modelType" property="modelType" jdbcType="INTEGER"/>
<result column="checkType" property="checkType" jdbcType="INTEGER"/>
<result column="orderFinishFlag" property="orderFinishFlag" jdbcType="BOOLEAN"/>
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, merchant_id, customer_name, phone_number, sales_uuid, sales_name, car_model, reception_start_time,
reception_end_time, created_by, created_date, updated_by, updated_date, deleted_flag, reception_status, staff_uuid,
car_purchase_method
</sql>
<select id="findByCustomerPhone"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from reception_customer_info
where phone_number = #{phoneNumber,jdbcType=VARCHAR} and staff_uuid = #{staffUuid,jdbcType=VARCHAR}
and deleted_flag = 'N' and DATE(created_date) = CURDATE();
</select>
<select id="statistics" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerStatisticsDTO">
select
count(*) as count,
avg(TIMESTAMPDIFF(SECOND,reception_start_time,reception_end_time)) as avgTime
from reception_customer_info
where merchant_id = #{merchantId}
and bussiness_type = #{bussinessType}
and staff_uuid = #{uuid}
and reception_start_time > #{startTime}
and reception_end_time < #{endTime}
and deleted_flag = 'N'
</select>
<select id="customerInfoPage" resultMap="BaseResultDTOMap">
select
t1.merchant_id, t1.customer_name,t1.phone_number, t1.sales_uuid, t1.sales_name, t1.car_brand,t1.car_model, t1.reception_start_time,
t1.reception_end_time, t1.reception_status, t1.staff_uuid,t2.recording_url as recordingUrl,
t1.car_purchase_method,t2.check_History_Flag as checkHistoryFlag,t3.id as batchId,t3.score as score,t2.review_flag as reviewFlag,
t2.model_type as modelType,
t2.check_type as checkType,
CASE
WHEN EXISTS (
SELECT 1 FROM customer_order_temp t4
WHERE t4.phone = t1.phone_number
AND t4.scene_type = t1.bussiness_type - 1
AND t4.order_status IN (4,6)
) THEN true
ELSE false END as orderFinishFlag,
t1.one_car_brand as oneCarBrand
from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id = t2.reception_id
left join inspection_conversation_batch t3 on t3.record_id=t2.id
where t1.merchant_id = #{merchantId}
and t1.staff_uuid = #{uuid}
and t1.bussiness_type = #{bussinessType}
<if test="startTime != null">
and t1.reception_start_time >= #{startTime}
</if>
<if test="endTime != null">
and t1.reception_end_time <= #{endTime}
</if>
<if test="reviewFlag!=null and reviewFlag==1">
and t2.review_flag=0
</if>
<if test="reviewFlag!=null and reviewFlag==0">
and t2.review_flag is null
</if>
<if test="orderFinishFlag!=null and orderFinishFlag==1">
and EXISTS (
SELECT 1
FROM customer_order_temp t4
WHERE t4.phone = t1.phone_number
AND t4.scene_type+1 = t1.bussiness_type
AND t4.order_status IN (4, 6)
)
</if>
<if test="orderFinishFlag!=null and orderFinishFlag==0">
and not EXISTS (
SELECT 1
FROM customer_order_temp t4
WHERE t4.phone = t1.phone_number
AND t4.scene_type+1 = t1.bussiness_type
AND t4.order_status IN (4, 6)
)
</if>
and t1.deleted_flag = 'N'
order by t1.reception_start_time desc
</select>
<select id="selectReceptionCustomerList" resultMap="BaseResultDTOMap">
select
<include refid="Base_Column_List" />
from reception_customer_info
where deleted_flag = 'N'
and reception_start_time >= #{params.startTime}
and reception_end_time <= #{params.endTime}
and merchant_id in
<foreach collection="params.merchantIds" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
order by reception_start_time desc
</select>
<select id="selectRecMerchantList"
resultType="cn.com.glsx.dj.mindworkplate.dto.MerchantDTO">
select distinct merchant_id as merchantNo from reception_customer_info where merchant_id is not null
</select>
<select id="selectByMerchantId" resultType="java.lang.Integer">
select count(1) from reception_customer_info where merchant_id=#{merchantNo}
</select>
<select id="findReceptionByCondition"
resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionStaticInfoDTO">
select
t3.reception_start_time as receptionStartTime,
t3.reception_start_time as receptionStartTimeTamp,
t2.employee_name as employeeName,
t2.phone_number as employeePhone,
date_format (t3.reception_start_time,'%Y-%m-%d') as staticDate,
t3.customer_name as customerName,
t3.phone_number as phoneNumber,
t3.car_model as carModel,
t3.car_brand as carBrand,
t3.merchant_id as merchantNo,
t5.customer_type as tag,
t9.equity_price_update as orderAmount,
t9.customerName as realCustomerName,
t4.score as qualityCheckScore,
t9.order_status as orderStatus,
t4.start_time as startTime,
t4.end_time as endTime,
t4.duration as totalDuration,
t4.id as batchId,
t4.file_url as fileUrl,
t1.defence_result_flag as defenceResultFlag,
t6.wghs_Status as violationStatus,
t6.Violation_Reason as violationReason,
t1.check_history_flag as checkHistoryFlag,
t1.model_type as modelType,
t1.check_type as checkType
from reception_customer_info t3
left join inspection_badge_recordings t1 on t1.reception_id =t3.id
left join inspection_employee_badge t2 on t1.badge_id =t2.badge_id
left join inspection_conversation_batch t4 on t1.id =t4.record_id
left join (SELECT
t7.transfer_id,
MAX(t8.phone) AS phone,
t8.owner as customerName,
t7.order_status,
t7.equity_price_update
FROM
dj_car_life_vd_quotation t7
LEFT JOIN
dj_car_life_vd_owner t8 ON t7.order_id = t8.order_id
WHERE
t7.order_status IN (0,1,5,3, -1, 2)
GROUP BY
t8.phone,t7.transfer_id
HAVING
t7.order_status =
CASE
WHEN SUM(CASE WHEN t7.order_status in (3,5) THEN 1 ELSE 0 END) > 0 THEN 3
WHEN SUM(CASE WHEN t7.order_status = -1 THEN 1 ELSE 0 END) > 0 THEN -1
WHEN SUM(CASE WHEN t7.order_status in (0,1,2) THEN 1 ELSE 0 END) > 0 THEN 2
ELSE NULL
END) t9 on (t3.phone_number=t9.phone)
left join inspection_defence t5 on (t4.id=t5.batch_id and t5.deleted_flag='N')
left join recording_batch_model_call_wghs t6 on (t4.id=t6.batch_id)
where t3.bussiness_type=1 and t3.merchant_id in
<foreach collection="receptionStaticReqDTO.merchantNo" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
<if test="receptionStaticReqDTO.batchId != null and receptionStaticReqDTO.batchId != ''">
and t4.id = #{receptionStaticReqDTO.batchId}
</if>
<if test="receptionStaticReqDTO.startDateTime != null">
and date_format (t3.reception_start_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{receptionStaticReqDTO.startDateTime}
</if>
<if test="receptionStaticReqDTO.endDateTime != null">
and date_format (t3.reception_start_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{receptionStaticReqDTO.endDateTime}
</if>
<if test="receptionStaticReqDTO.customerName != null and receptionStaticReqDTO.customerName != ''">
and (t3.customer_name like concat('%', #{receptionStaticReqDTO.customerName},'%') or t3.phone_number like concat('%', #{receptionStaticReqDTO.phoneNumber},'%'))
</if>
<if test="receptionStaticReqDTO.customerTypes != null and receptionStaticReqDTO.customerTypes.size>0">
and t5.customer_type in
<foreach collection="receptionStaticReqDTO.customerTypes" item="customerType" open="(" separator="," close=")">
#{customerType}
</foreach>
</if>
<if test="receptionStaticReqDTO.carModels != null and receptionStaticReqDTO.carModels.size>0">
and t3.car_model in
<foreach collection="receptionStaticReqDTO.carModels" item="carModel" open="(" separator="," close=")">
#{carModel}
</foreach>
</if>
<if test="receptionStaticReqDTO.staffUuids != null and receptionStaticReqDTO.staffUuids.size>0">
and t3.staff_uuid in
<foreach collection="receptionStaticReqDTO.staffUuids" item="staffUuid" open="(" separator="," close=")">
#{staffUuid}
</foreach>
</if>
<if test="receptionStaticReqDTO.orderStatusList != null and receptionStaticReqDTO.orderStatusList.size>0">
<if test="receptionStaticReqDTO.orderStatusIsNullFlag">
and (t9.order_status in
<foreach collection="receptionStaticReqDTO.orderStatusList" item="orderStatus" open="(" separator="," close=")">
#{orderStatus}
</foreach>
or t9.order_status is null)
</if>
<if test="!receptionStaticReqDTO.orderStatusIsNullFlag">
and t9.order_status in
<foreach collection="receptionStaticReqDTO.orderStatusList" item="orderStatus" open="(" separator="," close=")">
#{orderStatus}
</foreach>
</if>
</if>
<if test="receptionStaticReqDTO.qualityCheckScoreBegin != null">
and t4.score <![CDATA[ > ]]> #{receptionStaticReqDTO.qualityCheckScoreBegin}
</if>
<if test="receptionStaticReqDTO.qualityCheckScoreEnd != null">
and t4.score <![CDATA[ <= ]]> #{receptionStaticReqDTO.qualityCheckScoreEnd}
</if>
<if test="receptionStaticReqDTO.violationStatus != null">
and t6.wghs_Status=#{receptionStaticReqDTO.violationStatus}
</if>
<choose>
<!-- 当 violationStatus 不为 null 时 -->
<when test="receptionStaticReqDTO.violationStatus == null || receptionStaticReqDTO.violationStatus == 1">
ORDER BY DATE_FORMAT(t3.reception_start_time, '%Y-%m-%d') DESC, t3.reception_start_time
</when>
<!-- 当 violationStatus 等于 2 或者0时 -->
<otherwise>
ORDER BY DATE_FORMAT(t3.reception_start_time, '%Y-%m-%d') DESC, t6.Violation_Reason_confim_time DESC
</otherwise>
</choose>
</select>
<select id="findOrderByMerchantIds"
resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionStaticInfoDTO">
select
date_format (t3.reception_start_time,'%Y-%m-%d') as staticDate,
t9.order_status as orderStatus
from reception_customer_info t3
left join (SELECT
t7.transfer_id,
MAX(t8.phone) AS phone,
t8.owner as customerName,
t7.order_status,
t7.equity_price_update
FROM
dj_car_life_vd_quotation t7
LEFT JOIN
dj_car_life_vd_owner t8 ON t7.order_id = t8.order_id
WHERE
t7.order_status IN (0,1,5,3, -1, 2)
GROUP BY
t8.phone,t7.transfer_id
HAVING
t7.order_status =
CASE
WHEN SUM(CASE WHEN t7.order_status in (3,5) THEN 1 ELSE 0 END) > 0 THEN 3
WHEN SUM(CASE WHEN t7.order_status = -1 THEN 1 ELSE 0 END) > 0 THEN -1
WHEN SUM(CASE WHEN t7.order_status in (0,1,2) THEN 1 ELSE 0 END) > 0 THEN 2
ELSE NULL
END) t9 on (t3.phone_number=t9.phone and t3.staff_uuid=t9.transfer_id)
where t3.bussiness_type=1 and t9.order_status is not null and t3.merchant_id in
<foreach collection="receptionStaticReqDTO.merchantNo" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
<if test="receptionStaticReqDTO.startDateTime != null">
and date_format (t3.reception_start_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{receptionStaticReqDTO.startDateTime}
</if>
<if test="receptionStaticReqDTO.endDateTime != null">
and date_format (t3.reception_start_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{receptionStaticReqDTO.endDateTime}
</if>
<if test="receptionStaticReqDTO.staffUuids != null and receptionStaticReqDTO.staffUuids.size>0">
and t3.staff_uuid in
<foreach collection="receptionStaticReqDTO.staffUuids" item="staffUuid" open="(" separator="," close=")">
#{staffUuid}
</foreach>
</if>
</select>
<select id="selectStaffRecCusCountByCondition"
resultType="cn.com.glsx.dj.mindworkplate.dto.StaffBehaviorRecCusStaticDTO">
select merchant_id as merchantId,count(1) as recCusCount from reception_customer_info t1
LEFT JOIN inspection_badge_recordings t2 ON t1.id=t2.reception_id
LEFT JOIN inspection_conversation_batch t3 ON t3.record_id=t2.id
where t1.deleted_flag = 'N'
and staff_uuid = #{staffBehaviorRecCusDTO.staffUuid}
and bussiness_type = #{staffBehaviorRecCusDTO.bussinessType}
and reception_start_time >= #{staffBehaviorRecCusDTO.startDateTime}
and reception_end_time <= #{staffBehaviorRecCusDTO.endDateTime}
and merchant_id in
<foreach collection="staffBehaviorRecCusDTO.merchantIds" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
group by merchant_id
</select>
<select id="selectStaffRecRealCountByCondition"
resultType="cn.com.glsx.dj.mindworkplate.dto.StaffBehaviorRecCusStaticDTO">
select merchant_id as merchantId,count(1) as notRealRecCusCount from
reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t3.record_id=t2.id
where t1.deleted_flag = 'N' and t3.score <= 20
and staff_uuid = #{staffBehaviorRecCusDTO.staffUuid}
and bussiness_type = #{staffBehaviorRecCusDTO.bussinessType}
and reception_start_time >= #{staffBehaviorRecCusDTO.startDateTime}
and reception_end_time <= #{staffBehaviorRecCusDTO.endDateTime}
and merchant_id in
<foreach collection="staffBehaviorRecCusDTO.merchantIds" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
group by merchant_id
</select>
<select id="selectStaffRecCusCountByMerchant"
resultType="cn.com.glsx.dj.mindworkplate.dto.StaffBehaviorRecCusDetailDTO">
select DATE_FORMAT(reception_start_time, '%Y-%m-%d') as dayTime,count(1) as recCusCount from reception_customer_info t1
LEFT JOIN inspection_badge_recordings t2 ON t1.id=t2.reception_id
LEFT JOIN inspection_conversation_batch t3 ON t3.record_id=t2.id
where t1.deleted_flag = 'N'
and staff_uuid = #{staffBehaviorRecCusDTO.staffUuid}
and bussiness_type = #{staffBehaviorRecCusDTO.bussinessType}
and reception_start_time >= #{staffBehaviorRecCusDTO.startDateTime}
and reception_end_time <= #{staffBehaviorRecCusDTO.endDateTime}
and merchant_id in
<foreach collection="staffBehaviorRecCusDTO.merchantIds" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
group by DATE_FORMAT(reception_start_time, '%Y-%m-%d')
</select>
<select id="selectStaffRecRealCountByMerchant"
resultType="cn.com.glsx.dj.mindworkplate.dto.StaffBehaviorRecCusDetailDTO">
select DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') as dayTime,count(1) as notRealRecCusCount from
reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t3.record_id=t2.id
where t1.deleted_flag = 'N' and t3.score <= 20
and staff_uuid = #{staffBehaviorRecCusDTO.staffUuid}
and bussiness_type = #{staffBehaviorRecCusDTO.bussinessType}
and reception_start_time >= #{staffBehaviorRecCusDTO.startDateTime}
and reception_end_time <= #{staffBehaviorRecCusDTO.endDateTime}
and merchant_id in
<foreach collection="staffBehaviorRecCusDTO.merchantIds" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
group by DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d')
</select>
<select id="findRecepStaffByMerchantId"
resultType="cn.com.glsx.dj.mindworkplate.model.StaffResponse">
SELECT t1.staff_uuid as uuid,t1.merchant_id as merchantId,t3.employee_name as staffName
FROM reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_employee_badge t3 on t3.badge_id =t2.badge_id
where merchant_id in
<foreach collection="merchantNos" item="merchantId" open="(" separator="," close=")">
#{merchantId}
</foreach>
group by t1.staff_uuid
</select>
<select id="findExtendedReceptionCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') as date,t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as extendedWarrantyAppReceptions from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 1
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d'),t1.staff_uuid,t1.merchant_id
</select>
<select id="findExtendedFalseRecordingsCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') as date,t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as falseRecordingsExtendedWarranty from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t3.record_id=t2.id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 1
and ((t3.score is not null and t3.score < 20) or t2.recording_duration <120)
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d'),t1.staff_uuid,t1.merchant_id
</select>
<select id="findLightModReceptionCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') as date,t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as lightModificationAppReceptions from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 2
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d'),t1.staff_uuid,t1.merchant_id
</select>
<select id="findLightModFalseRecordingsCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') as date,t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as falseRecordingsLightModification from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t3.record_id=t2.id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 2
and ((t3.score is not null and t3.score < 20) or t2.recording_duration <120)
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d'),t1.staff_uuid,t1.merchant_id
</select>
<select id="findExtendedSuccessCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select
DATE_FORMAT(dclpo.success_date, '%Y-%m-%d') as date,dclgo.seller_user_id as staffUUid,dclgo.merchant_id as merchantId,count(1) as extendedSuccessCount
from dj_car_life_goods_order dclgo
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'
left join (select * from reception_customer_info where bussiness_type=1)t1 on (t1.phone_number = dclgoc.customer_phone and dclgo.seller_user_id=t1.staff_uuid and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d')=DATE_FORMAT(dclpo.success_date, '%Y-%m-%d'))
where DATE_FORMAT(dclpo.success_date, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(dclpo.success_date, '%Y-%m-%d') <= #{endDate}
and dclgo.deleted_flag = 'N' and dclgo.scene_type = 0
and dclgo.status in (4, 6) and upgrade_flag = 'Y'
and t1.phone_number is null
group by DATE_FORMAT(dclpo.success_date, '%Y-%m-%d'),dclgo.seller_user_id,dclgo.merchant_id
</select>
<select id="findLightModSuccessCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select
DATE_FORMAT(dclpo.success_date, '%Y-%m-%d') as date,dclgo.seller_user_id as staffUUid,dclgo.merchant_id as merchantId,count(1) as lightModSuccessCount
from dj_car_life_goods_order dclgo
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'
left join (select * from reception_customer_info where bussiness_type=2)t1 on (t1.phone_number = dclgoc.customer_phone and dclgo.seller_user_id=t1.staff_uuid and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d')=DATE_FORMAT(dclpo.success_date, '%Y-%m-%d'))
where DATE_FORMAT(dclpo.success_date, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(dclpo.success_date, '%Y-%m-%d') <= #{endDate}
and dclgo.deleted_flag = 'N' and dclgo.scene_type = 1
and dclgo.status in (4, 6) and upgrade_flag = 'Y'
and t1.phone_number is null
group by DATE_FORMAT(dclpo.success_date, '%Y-%m-%d'),dclgo.seller_user_id,dclgo.merchant_id
</select>
<select id="findAssurancePackageOpeningCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') as date,t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as assurancePackageOpeningCount from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t2.id =t3.record_id
left join recording_batch_model_call_axb t4 on t3.id =t4.batch_id
where t1.deleted_flag = 'N' and t4.Is_mentioned =1
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
and t1.bussiness_type = 1
group by DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d'),t1.staff_uuid,t1.merchant_id
</select>
<select id="findLargePackageOpeningCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') as date,t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as largePackageOpeningCount from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t2.id =t3.record_id
left join recording_batch_model_call_dtc t4 on t3.id =t4.batch_id
where t1.deleted_flag = 'N' and t4.Is_mentioned =1
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
and t1.bussiness_type = 1
group by DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d'),t1.staff_uuid,t1.merchant_id
</select>
<select id="findWeeklyExtendedReceptionCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeWeeklyStatsDTO">
select t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as extendedWarrantyAppReceptions from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 1
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by t1.staff_uuid,t1.merchant_id
</select>
<select id="findWeeklyExtendedFalseRecordingsCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeWeeklyStatsDTO">
select t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as falseRecordingsExtendedWarranty from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t3.record_id=t2.id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 1
and ((t3.score is not null and t3.score < 20) or t2.recording_duration <120)
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by t1.staff_uuid,t1.merchant_id
</select>
<select id="findWeeklyLightModReceptionCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeWeeklyStatsDTO">
select t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as lightModificationAppReceptions from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 2
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by t1.staff_uuid,t1.merchant_id
</select>
<select id="findWeeklyLightModFalseRecordingsCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeWeeklyStatsDTO">
select t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as falseRecordingsLightModification from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t3.record_id=t2.id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 2
and ((t3.score is not null and t3.score < 20) or t2.recording_duration < 120)
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by t1.staff_uuid,t1.merchant_id
</select>
<select id="findWeeklyAssurancePackageOpeningCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeWeeklyStatsDTO">
select t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as assurancePackageOpeningCount from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t2.id =t3.record_id
left join recording_batch_model_call_axb t4 on t3.id =t4.batch_id
where t1.deleted_flag = 'N' and t4.Is_mentioned =1
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
and t1.bussiness_type = 1
group by t1.staff_uuid,t1.merchant_id
</select>
<select id="findWeeklyLargePackageOpeningCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeWeeklyStatsDTO">
select t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,count(1) as largePackageOpeningCount from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_conversation_batch t3 on t2.id =t3.record_id
left join recording_batch_model_call_dtc t4 on t3.id =t4.batch_id
where t1.deleted_flag = 'N' and t4.Is_mentioned =1
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
and t1.bussiness_type = 1
group by t1.staff_uuid,t1.merchant_id
</select>
<select id="findAllRepStaffUuids" resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeDailyStatsDTO">
select distinct t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,
t2.staff_name as staffName,t2.phone_number as staffPhone,t3.merchant_name as merchantName
from reception_customer_info t1
left join dj_car_life_staff_info t2 on t1.staff_uuid =t2.staff_uuid
left join dj_car_life_service_merchant t3 on t1.merchant_id =t3.merchant_id
where t1.deleted_flag = 'N'
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
</select>
<select id="findWeeklyExtendedNotReceptionDateCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeWeeklyStatsDTO">
select t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,7-count(distinct DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d')) as extendedWarrantyAppReceptionsNotUseCount from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 1
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by t1.staff_uuid,t1.merchant_id
</select>
<select id="findWeeklyLightNotReceptionDateCount"
resultType="cn.com.glsx.dj.mindworkplate.model.EmployeeWeeklyStatsDTO">
select t1.staff_uuid as staffUUid,t1.merchant_id as merchantId,7-count(distinct DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d')) as lightModificationAppReceptionsNotUseCount from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
where t1.deleted_flag = 'N'
and t1.bussiness_type = 2
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDate}
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDate}
group by t1.staff_uuid,t1.merchant_id
</select>
<select id="findCustomerPhoneByCondition" resultType="java.lang.String">
select distinct t1.phone_number as phoneNumber from reception_customer_info t1
where t1.deleted_flag = 'N'
<if test="condition.merchantId!=null">
and t1.merchant_id = #{condition.merchantId}
</if>
and t1.car_model = #{condition.carModel}
and t1.phone_number is not null
</select>
<select id="findViolationReceptionByConditionPage"
resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionViolationInfoDTO">
select t3.id as batchId,t5.employee_name as employeeName,t5.phone_number as employeePhone,t1.merchant_id as merchantNo,t1.phone_number as phoneNumber,t1.customer_name as customerName,
t1.car_model as carModel,t1.reception_start_time as startTime,t2.recording_url as fileUrl, t1.reception_end_time as endTime,t1.reception_status as receptionStatus,
t1.car_brand as carBrandName, t1.car_brandid as carBrandId,
t2.recording_duration as totalDuration,t4.wghs_Status as violationStatus,t4.Violation_Reason_confim_time as violationReasonConfimTime,t1.bussiness_type as bussinessTypeName,t6.result_json as resultJson
from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_employee_badge t5 on t2.badge_id =t5.badge_id
left join inspection_conversation_batch t3 on t2.id =t3.record_id
left join recording_batch_model_call_wghs t4 on t3.id =t4.batch_id
left join recording_batch_model_call t6 on (t6.recording_batch_id =t4.batch_id and t6.business_type in (11,1107))
where t4.id is not null
<if test="merchantNo!=null">
and t1.merchant_id = #{merchantNo}
</if>
<if test="bussinessType!=null">
and t1.bussiness_type = #{bussinessType}
</if>
<if test="merchantNos!=null">
and t1.merchant_id in
<foreach collection="merchantNos" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="startDateTime!=null">
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{startDateTime}
</if>
<if test="endDateTime!=null">
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{endDateTime}
</if>
<if test="customerName!=null">
and t1.customer_name like CONCAT('%',#{customerName},'%')
</if>
<if test="staffName!=null">
and t5.employee_name like CONCAT('%',#{staffName},'%')
</if>
<if test="violationStatus!=null">
and t4.wghs_Status = #{violationStatus}
</if>
<if test="carBrandId != null">
and t1.car_brandid = #{carBrandId}
</if>
<choose>
<!-- 当 violationStatus 不为 null 时 -->
<when test="violationStatus == null || violationStatus == 1">
ORDER BY t1.reception_start_time desc
</when>
<!-- 当 violationStatus 等于 2 或者0时 -->
<otherwise>
ORDER BY t4.Violation_Reason_confim_time DESC
</otherwise>
</choose>
</select>
<select id="findViolationByBatchId"
resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionViolationInfoDTO">
select t3.id as batchId,t5.employee_name as employeeName,t5.phone_number as employeePhone,t1.merchant_id as merchantNo,t1.phone_number as phoneNumber,t1.customer_name as customerName,
t1.car_model as carModel,t1.reception_start_time as startTime,t2.recording_url as fileUrl, t1.reception_end_time as endTime,t1.reception_status as receptionStatus,
t1.car_brand as carBrandName, t1.car_brandid as carBrandId,
t2.recording_duration as totalDuration,t4.wghs_Status as violationStatus,t4.Violation_Reason_confim_time as violationReasonConfimTime,t1.bussiness_type as bussinessTypeName
from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_employee_badge t5 on t2.badge_id =t5.badge_id
left join inspection_conversation_batch t3 on t2.id =t3.record_id
left join recording_batch_model_call_wghs t4 on t3.id =t4.batch_id
where t4.batch_id = #{batchId}
</select>
<select id="findViolationReceptionByCondition"
resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionViolationInfoDTO">
select t3.id as batchId,t1.staff_uuid as employeeUuid,t5.employee_name as employeeName,t5.phone_number as employeePhone,t1.merchant_id as merchantNo,t1.phone_number as phoneNumber,t1.customer_name as customerName,
t1.car_model as carModel,t1.reception_start_time as startTime,t2.recording_url as fileUrl, t1.reception_end_time as endTime,t1.reception_status as receptionStatus,
t2.recording_duration as totalDuration,t4.wghs_Status as violationStatus,t4.Violation_Reason_confim_time as violationReasonConfimTime,t1.bussiness_type as bussinessTypeName
from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_employee_badge t5 on t2.badge_id =t5.badge_id
left join inspection_conversation_batch t3 on t2.id =t3.record_id
left join recording_batch_model_call_wghs t4 on t3.id =t4.batch_id
where t4.id is not null
<if test="receptionViolationReqDTO.startDateTime!=null">
and t4.Violation_Reason_confim_time >= #{receptionViolationReqDTO.startDateTime}
</if>
<if test="receptionViolationReqDTO.endDateTime!=null">
and t4.Violation_Reason_confim_time <= #{receptionViolationReqDTO.endDateTime}
</if>
<if test="receptionViolationReqDTO.violationStatus!=null">
and t4.wghs_Status = #{receptionViolationReqDTO.violationStatus}
</if>
</select>
<select id="selectStaffCarModelRecCusByCondition"
resultType="cn.com.glsx.dj.mindworkplate.dto.StaffCarModelRecCusStaticDTO">
SELECT t1.merchant_id as merchantId,
COUNT(CASE WHEN t1.car_model LIKE '%问界%' THEN 1 END) AS aoTuCount,
COUNT(CASE WHEN t1.car_model NOT LIKE '%问界%' OR t1.car_model IS NULL THEN 1 END) AS notAoTuCount
from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
WHERE t1.bussiness_type=#{staffBehaviorRecCusDTO.bussinessType}
and t1.staff_uuid in
<foreach collection="staffBehaviorRecCusDTO.staffUuids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and t1.reception_start_time like CONCAT('%',#{staffBehaviorRecCusDTO.monthTime},'%')
group by t1.merchant_id
</select>
<select id="findOrderByPhones"
resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionStaticInfoDTO">
SELECT
t8.phone as phoneNumber,
t7.equity_price_update as orderAmount
FROM
dj_car_life_vd_quotation t7
LEFT JOIN
dj_car_life_vd_owner t8 ON t7.order_id = t8.order_id
INNER JOIN (
-- 找出每个手机号最新的 created_time
SELECT
t8.phone,
MAX(t7.created_time) AS max_created_time
FROM
dj_car_life_vd_quotation t7
LEFT JOIN
dj_car_life_vd_owner t8 ON t7.order_id = t8.order_id
WHERE
t7.order_status IN (3,5) and t8.phone in
<foreach collection="phones" item="item" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY
t8.phone
) latest
ON t8.phone = latest.phone AND t7.created_time = latest.max_created_time
WHERE
t7.order_status IN (3,5) and t8.phone in
<foreach collection="phones" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="receptionTagPage"
resultMap="BaseResultDTOMap">
select t1.*,t2.id as recordId,t4.score as score,
concat(t3.employee_name,' ',t3.phone_number) as staffName,t2.recording_url as recordingUrl,
CASE
WHEN EXISTS (
SELECT 1 FROM customer_order_temp t5
WHERE t5.phone = t1.phone_number
AND t5.scene_type = t1.bussiness_type - 1
AND t5.order_status IN (4,6)
) THEN '1'
ELSE '0' END
as isOrderFinishFlagName,t2.check_Type as checkType
from reception_customer_info t1
left join inspection_badge_recordings t2 on t1.id=t2.reception_id
left join inspection_employee_badge t3 on t2.badge_id =t3.badge_id
left join inspection_conversation_batch t4 on t2.id =t4.record_id
left join customer_order_temp t5 on t1.phone_number = t5.phone and t1.bussiness_type-1 = t5.scene_type
where t2.check_History_Flag=0
<if test="condition.staffName!=null">
and t3.employee_name like CONCAT('%',#{condition.staffName},'%')
</if>
<if test="condition.merchantId!=null">
and t1.merchant_id = #{condition.merchantId}
</if>
<if test="condition.checkType!=null">
and t2.check_type = #{condition.checkType}
</if>
<if test="condition.carBrandId!=null">
and (t1.car_brandId = #{condition.carBrandId} or t1.one_car_brandid = #{condition.carBrandId})
</if>
<if test="condition.checkStartTime!=null">
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') >= #{condition.checkStartTime}
</if>
<if test="condition.checkEndTime!=null">
and DATE_FORMAT(t1.reception_start_time, '%Y-%m-%d') <= #{condition.checkEndTime}
</if>
<if test="condition.orderFinishFlag!=null and condition.orderFinishFlag==0">
and EXISTS (
SELECT 1
FROM customer_order_temp t5
WHERE t5.phone = t1.phone_number
AND t5.scene_type+1 = t1.bussiness_type
AND t5.order_status IN (4, 6)
)
</if>
<if test="condition.orderFinishFlag!=null and condition.orderFinishFlag==1">
and not EXISTS (
SELECT 1
FROM customer_order_temp t5
WHERE t5.phone = t1.phone_number
AND t5.scene_type+1 = t1.bussiness_type
AND t5.order_status IN (4, 6)
)
</if>
order by t1.reception_start_time desc
</select>
<select id="findCheckTypeByStaffPhone" resultType="java.lang.Integer">
select ibr.check_type from inspection_employee_badge ieb
left join inspection_badge_recordings ibr on ieb.badge_id = ibr.badge_id
where ieb.deleted_flag = 'N' and ibr.deleted_flag = 'N'
and ieb.phone_number = #{staffPhone} and ibr.check_type is not null
group by ibr.check_type
</select>
<select id="findReceptionListByStaff" resultMap="BaseResultDTOMap">
select * from dj_car_life_staff_info dclsi
left join reception_customer_info rci on dclsi.staff_uuid = rci.staff_uuid
left join inspection_badge_recordings ibr on rci.id = ibr.reception_id
where dclsi.deleted_flag = 'N' and rci.deleted_flag = 'N' and ibr.deleted_flag = 'N'
<if test="condition.staffPhone!=null and condition.staffPhone!=''">
and dclsi.phone_number = #{condition.staffPhone}
</if>
<if test="condition.carBrandId!=null">
and rci.one_car_brandid = #{condition.carBrandId}
</if>
<if test="condition.checkType!=null">
and ibr.check_type = #{condition.checkType}
</if>
<if test="condition.checkStartTime!=null">
and DATE_FORMAT(rci.reception_start_time, '%Y-%m-%d') >= #{condition.checkStartTime}
</if>
<if test="condition.checkEndTime!=null">
and DATE_FORMAT(rci.reception_start_time, '%Y-%m-%d') <= #{condition.checkEndTime}
</if>
</select>
</mapper>