|
@@ -240,7 +240,9 @@ FROM
|
240
|
240
|
a.intention as intention,
|
241
|
241
|
a.create_date as createDate,
|
242
|
242
|
if(a.sex = 1, '男',if(a.sex = 2, '女', '未知')) as sex,
|
243
|
|
- concat(c.nickname, c.phone) as recommend
|
|
243
|
+ c.nickname as recommend,
|
|
244
|
+ c.phone as recommendTel,
|
|
245
|
+ if(a.verify_status = 0, '未通过', if(a.verify_status = 1, '已通过', if(a.verify_status = 2, '已驳回', ''))) as verifyStatusName
|
244
|
246
|
FROM
|
245
|
247
|
ta_recommend_customer a
|
246
|
248
|
LEFT JOIN ta_person c on a.recommend_person = c.person_id
|
|
@@ -333,13 +335,31 @@ FROM
|
333
|
335
|
a.phone as phone,
|
334
|
336
|
if(a.gender = '1', '男', if(a.gender = '2', '女', '未知')) as gender,
|
335
|
337
|
if(ifnull(tc.channel_name, '') != '', '渠道经纪人', '独立经纪人') as personType,
|
336
|
|
- tc.channel_name as channelName
|
|
338
|
+ tc.channel_name as channelName,
|
|
339
|
+ (
|
|
340
|
+ SELECT
|
|
341
|
+ count( 1 )
|
|
342
|
+ FROM
|
|
343
|
+ ta_recommend_customer tarc
|
|
344
|
+ LEFT JOIN ta_person tp ON tarc.recommend_person = tp.person_id
|
|
345
|
+ WHERE
|
|
346
|
+ tarc.recommend_person = a.person_id and ifnull(tp.person_type, '') = 'customer'
|
|
347
|
+ ) AS recommedCount,
|
|
348
|
+ (
|
|
349
|
+ SELECT
|
|
350
|
+ count( 1 )
|
|
351
|
+ FROM
|
|
352
|
+ ta_recommend_customer tarc
|
|
353
|
+ LEFT JOIN ta_person tp ON tarc.recommend_person = tp.person_id
|
|
354
|
+ WHERE
|
|
355
|
+ tarc.recommend_person = a.person_id and ifnull(tp.person_type, '') in ('channel agent', 'estate agent')
|
|
356
|
+ ) AS agentCount
|
337
|
357
|
FROM
|
338
|
358
|
ta_person a
|
339
|
359
|
left join ta_channel_person tcp on a.person_id = tcp.person_id
|
340
|
360
|
left join ta_channel tc on tc.channel_id = tcp.channel_id
|
341
|
361
|
<where>
|
342
|
|
- a.person_type = 'estate agent'
|
|
362
|
+ ifnull(a.person_type, '') in ('channel agent', 'estate agent')
|
343
|
363
|
and a.status >0
|
344
|
364
|
<if test="orgId != null">
|
345
|
365
|
and a.org_id = #{orgId}
|
|
@@ -349,6 +369,167 @@ FROM
|
349
|
369
|
|
350
|
370
|
ORDER BY
|
351
|
371
|
a.create_date DESC
|
|
372
|
+ limit #{pageCode}, #{pageSize}
|
|
373
|
+ </select>
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+ <select id="getPublicCustomerExportListCount" resultType="Integer">
|
|
377
|
+ SELECT
|
|
378
|
+ count(1)
|
|
379
|
+ FROM
|
|
380
|
+ ta_person b
|
|
381
|
+ <where>
|
|
382
|
+ b.status > 0
|
|
383
|
+ AND IFNULL(b.person_type, '') in ('estate agent', 'customer')
|
|
384
|
+ <if test="name != null and name !=''">
|
|
385
|
+ and b.nickname like CONCAT('%',#{name}, '%')
|
|
386
|
+ </if>
|
|
387
|
+ <if test="tel != null and tel!=''">
|
|
388
|
+ and b.phone like CONCAT('%',#{tel}, '%')
|
|
389
|
+ </if>
|
|
390
|
+ <if test="entryType != null and entryType !=''">
|
|
391
|
+ and b.entry_type = #{entryType}
|
|
392
|
+ </if>
|
|
393
|
+ <if test="sex != null and sex !=''">
|
|
394
|
+ and b.sex = #{sex}
|
|
395
|
+ </if>
|
|
396
|
+ <if test="orgId != null">
|
|
397
|
+ and b.org_id = #{orgId}
|
|
398
|
+ </if>
|
|
399
|
+ <if test="consultTel != null and consultTel !=''">
|
|
400
|
+ and b.tel like CONCAT('%',#{consultTel}, '%')
|
|
401
|
+ </if>
|
|
402
|
+ and NOT EXISTS ( select * from ta_recommend_customer a where a.recommend_person = b.person_id)
|
|
403
|
+ </where>
|
|
404
|
+ order by b.create_date desc
|
|
405
|
+ </select>
|
|
406
|
+
|
|
407
|
+ <select id="getPublicCustomerExportList" resultType="com.huiju.estateagents.excel.PublicCustomerExport">
|
|
408
|
+ SELECT
|
|
409
|
+ b.nickname as nickname,
|
|
410
|
+ b.phone as phone,
|
|
411
|
+ if(b.sex = 1, '男', if(b.sex = 2, '女', '未知')) as sex
|
|
412
|
+ FROM
|
|
413
|
+ ta_person b
|
|
414
|
+ <where>
|
|
415
|
+ b.status > 0
|
|
416
|
+ AND IFNULL(b.person_type, '') in ('estate agent', 'customer')
|
|
417
|
+ <if test="name != null and name !=''">
|
|
418
|
+ and b.nickname like CONCAT('%',#{name}, '%')
|
|
419
|
+ </if>
|
|
420
|
+ <if test="tel != null and tel!=''">
|
|
421
|
+ and b.phone like CONCAT('%',#{tel}, '%')
|
|
422
|
+ </if>
|
|
423
|
+ <if test="entryType != null and entryType !=''">
|
|
424
|
+ and b.entry_type = #{entryType}
|
|
425
|
+ </if>
|
|
426
|
+ <if test="sex != null and sex !=''">
|
|
427
|
+ and b.sex = #{sex}
|
|
428
|
+ </if>
|
|
429
|
+ <if test="orgId != null">
|
|
430
|
+ and b.org_id = #{orgId}
|
|
431
|
+ </if>
|
|
432
|
+ <if test="consultTel != null and consultTel !=''">
|
|
433
|
+ and b.tel like CONCAT('%',#{consultTel}, '%')
|
|
434
|
+ </if>
|
|
435
|
+ and NOT EXISTS ( select * from ta_recommend_customer a where a.recommend_person = b.person_id)
|
|
436
|
+ </where>
|
|
437
|
+ order by b.create_date desc
|
|
438
|
+ limit #{pageCode}, #{pageSize}
|
|
439
|
+ </select>
|
|
440
|
+
|
|
441
|
+ <select id="getCustomerExportListCount" resultType="Integer" >
|
|
442
|
+ SELECT
|
|
443
|
+ count(1)
|
|
444
|
+ FROM
|
|
445
|
+ ta_recommend_customer a
|
|
446
|
+ LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
|
|
447
|
+ LEFT JOIN ta_person c on a.recommend_person = c.person_id
|
|
448
|
+ <where>
|
|
449
|
+ a.status > 0
|
|
450
|
+ and realty_consultant is not null
|
|
451
|
+ <if test="orgId != null">
|
|
452
|
+ and a.org_id = #{orgId}
|
|
453
|
+ </if>
|
|
454
|
+ <if test="building != null and building !=''">
|
|
455
|
+ and a.building_id = #{building}
|
|
456
|
+ </if>
|
|
457
|
+ <if test="name != null and name !=''">
|
|
458
|
+ and a.name like CONCAT('%',#{name}, '%')
|
|
459
|
+ </if>
|
|
460
|
+ <if test="tel != null and tel!=''">
|
|
461
|
+ and a.phone like CONCAT('%',#{tel}, '%')
|
|
462
|
+ </if>
|
|
463
|
+ <if test="consultName != null and consultName !=''">
|
|
464
|
+ and b.name like CONCAT('%',#{consultName}, '%')
|
|
465
|
+ </if>
|
|
466
|
+ <if test="consultTel != null and consultTel !=''">
|
|
467
|
+ and b.tel like CONCAT('%',#{consultTel}, '%')
|
|
468
|
+ </if>
|
|
469
|
+ <if test="entryType != null and entryType !=''">
|
|
470
|
+ and a.entry_type = #{entryType}
|
|
471
|
+ </if>
|
|
472
|
+ <if test="verifyStatus != null and verifyStatus !=''">
|
|
473
|
+ and a.verify_status = #{verifyStatus}
|
|
474
|
+ </if>
|
|
475
|
+ <if test="status != null and status !=''">
|
|
476
|
+ and a.status = #{status}
|
|
477
|
+ </if>
|
|
478
|
+ <if test="sex != null and sex !=''">
|
|
479
|
+ and a.sex = #{sex}
|
|
480
|
+ </if>
|
|
481
|
+ </where>
|
|
482
|
+ order by a.create_date desc
|
|
483
|
+ </select>
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+ <select id="getCustomerExportList" resultType="com.huiju.estateagents.excel.PrivateCustomerExport">
|
|
487
|
+ SELECT
|
|
488
|
+ a.name AS name,
|
|
489
|
+ a.phone as phone,
|
|
490
|
+ if(a.sex = 1, '男', if(a.sex = 2, '女', '未知')) as sex,
|
|
491
|
+ b.name as consultantName,
|
|
492
|
+ b.tel as consultTel
|
|
493
|
+ FROM
|
|
494
|
+ ta_recommend_customer a
|
|
495
|
+ LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
|
|
496
|
+ LEFT JOIN ta_person c on a.recommend_person = c.person_id
|
|
497
|
+ <where>
|
|
498
|
+ a.status > 0
|
|
499
|
+ and realty_consultant is not null
|
|
500
|
+ <if test="orgId != null">
|
|
501
|
+ and a.org_id = #{orgId}
|
|
502
|
+ </if>
|
|
503
|
+ <if test="building != null and building !=''">
|
|
504
|
+ and a.building_id = #{building}
|
|
505
|
+ </if>
|
|
506
|
+ <if test="name != null and name !=''">
|
|
507
|
+ and a.name like CONCAT('%',#{name}, '%')
|
|
508
|
+ </if>
|
|
509
|
+ <if test="tel != null and tel!=''">
|
|
510
|
+ and a.phone like CONCAT('%',#{tel}, '%')
|
|
511
|
+ </if>
|
|
512
|
+ <if test="consultName != null and consultName !=''">
|
|
513
|
+ and b.name like CONCAT('%',#{consultName}, '%')
|
|
514
|
+ </if>
|
|
515
|
+ <if test="consultTel != null and consultTel !=''">
|
|
516
|
+ and b.tel like CONCAT('%',#{consultTel}, '%')
|
|
517
|
+ </if>
|
|
518
|
+ <if test="entryType != null and entryType !=''">
|
|
519
|
+ and a.entry_type = #{entryType}
|
|
520
|
+ </if>
|
|
521
|
+ <if test="verifyStatus != null and verifyStatus !=''">
|
|
522
|
+ and a.verify_status = #{verifyStatus}
|
|
523
|
+ </if>
|
|
524
|
+ <if test="status != null and status !=''">
|
|
525
|
+ and a.status = #{status}
|
|
526
|
+ </if>
|
|
527
|
+ <if test="sex != null and sex !=''">
|
|
528
|
+ and a.sex = #{sex}
|
|
529
|
+ </if>
|
|
530
|
+ </where>
|
|
531
|
+ order by a.create_date desc
|
|
532
|
+ limit #{pageCode}, #{pageSize}
|
352
|
533
|
</select>
|
353
|
534
|
|
354
|
535
|
</mapper>
|