|
@@ -10,7 +10,7 @@
|
10
|
10
|
left join ta_drainage d on t.be_share = d.drainage_id
|
11
|
11
|
left join ta_building_dynamic e on t.be_share = e.dynamic_id
|
12
|
12
|
left join ta_person f on t.person_id = f.person_id
|
13
|
|
- where t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and f.org_id = #{orgId}
|
|
13
|
+ where t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
14
|
14
|
<if test="buildingId != null and buildingId != ''">
|
15
|
15
|
and (a.building_id = #{buildingId} or b.building_id = #{buildingId} or c.building_id = #{buildingId} or d.building_id = #{buildingId} or e.building_id = #{buildingId})
|
16
|
16
|
</if>
|
|
@@ -34,7 +34,7 @@
|
34
|
34
|
left join ta_drainage d on t.be_share = d.drainage_id
|
35
|
35
|
left join ta_building_dynamic e on t.be_share = e.dynamic_id
|
36
|
36
|
left join ta_person f on t.person_id = f.person_id
|
37
|
|
- where t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and f.org_id = #{orgId}
|
|
37
|
+ where t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
38
|
38
|
<if test="buildingId != null and buildingId != ''">
|
39
|
39
|
and (a.building_id = #{buildingId} or b.building_id = #{buildingId} or c.building_id = #{buildingId} or d.building_id = #{buildingId} or e.building_id = #{buildingId})
|
40
|
40
|
</if>
|
|
@@ -118,7 +118,7 @@
|
118
|
118
|
left join ta_building_dynamic e on t.be_share = e.dynamic_id
|
119
|
119
|
left join ta_person f on t.person_id = f.person_id
|
120
|
120
|
WHERE
|
121
|
|
- t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and f.org_id = #{orgId}
|
|
121
|
+ t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
122
|
122
|
<if test="buildingId != null and buildingId != ''">
|
123
|
123
|
and (a.building_id = #{buildingId} or b.building_id = #{buildingId} or c.building_id = #{buildingId} or d.building_id = #{buildingId} or e.building_id = #{buildingId})
|
124
|
124
|
</if>
|
|
@@ -375,7 +375,7 @@
|
375
|
375
|
left join ta_building_dynamic e on t.be_share = e.dynamic_id
|
376
|
376
|
left join ta_person f on t.person_id = f.person_id
|
377
|
377
|
WHERE
|
378
|
|
- t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and f.org_id = #{orgId}
|
|
378
|
+ t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
379
|
379
|
<if test="buildingId != null and buildingId != ''">
|
380
|
380
|
and (a.building_id = #{buildingId} or b.building_id = #{buildingId} or c.building_id = #{buildingId} or d.building_id = #{buildingId} or e.building_id = #{buildingId})
|
381
|
381
|
</if>
|
|
@@ -395,7 +395,7 @@
|
395
|
395
|
DATE_FORMAT( t.create_date, '%Y-%m-%d' )
|
396
|
396
|
) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date, '%Y-%m-%d' )
|
397
|
397
|
LEFT JOIN (
|
398
|
|
- select COUNT(1) AS sharePersonNum, temp1.create_date from (
|
|
398
|
+ select temp1.sharePersonNum, temp1.create_date from (
|
399
|
399
|
SELECT COUNT( 1 ) AS sharePersonNum, t.create_date AS create_date, t.person_id
|
400
|
400
|
FROM
|
401
|
401
|
ta_share_count t
|
|
@@ -452,59 +452,61 @@
|
452
|
452
|
DATE_FORMAT( t.visit_time, '%Y-%m-%d' )
|
453
|
453
|
) AS temp2 ON temp_date.date = DATE_FORMAT( temp2.create_date, '%Y-%m-%d' )
|
454
|
454
|
LEFT JOIN (
|
455
|
|
- SELECT
|
456
|
|
- COUNT( 1 ) AS visitPersonNum,
|
457
|
|
- t.visit_time AS create_date
|
458
|
|
- FROM
|
459
|
|
- ta_person_visit_record t
|
460
|
|
- WHERE
|
461
|
|
- t.`event` = 'detail' and t.event_type in ('activity','help','group','h5') and t.org_id = #{orgId}
|
462
|
|
- <if test="buildingId != null and buildingId != ''">
|
463
|
|
- and t.building_id = #{buildingId}
|
464
|
|
- </if>
|
465
|
|
- <if test="targetType != null and targetType != ''">
|
466
|
|
- and t.target_type = #{targetType}
|
467
|
|
- </if>
|
468
|
|
- <if test="startDate != null">
|
469
|
|
- and t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
470
|
|
- </if>
|
471
|
|
- <if test="endDate != null">
|
472
|
|
- and t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
473
|
|
- </if>
|
474
|
|
- <if test="startDate == null or endDate == null">
|
475
|
|
- AND t.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
476
|
|
- </if>
|
477
|
|
- GROUP BY
|
478
|
|
- DATE_FORMAT( t.visit_time, '%Y-%m-%d' ) , person_id
|
|
455
|
+ select count(*)AS visitPersonNum , visitPersonCount.* from (
|
|
456
|
+ SELECT
|
|
457
|
+ t.visit_time AS create_date,
|
|
458
|
+ t.person_id
|
|
459
|
+ FROM
|
|
460
|
+ ta_person_visit_record t
|
|
461
|
+ WHERE
|
|
462
|
+ t.`event` = 'detail' and t.event_type in ('activity','help','group','h5') and t.org_id = #{orgId}
|
|
463
|
+ <if test="buildingId != null and buildingId != ''">
|
|
464
|
+ and t.building_id = #{buildingId}
|
|
465
|
+ </if>
|
|
466
|
+ <if test="targetType != null and targetType != ''">
|
|
467
|
+ and t.target_type = #{targetType}
|
|
468
|
+ </if>
|
|
469
|
+ <if test="startDate != null">
|
|
470
|
+ and t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
|
471
|
+ </if>
|
|
472
|
+ <if test="endDate != null">
|
|
473
|
+ and t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
|
474
|
+ </if>
|
|
475
|
+ <if test="startDate == null or endDate == null">
|
|
476
|
+ AND t.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
|
477
|
+ </if>
|
|
478
|
+ GROUP BY
|
|
479
|
+ DATE_FORMAT(t.visit_time, '%Y-%m-%d'),
|
|
480
|
+ person_id) as visitPersonCount GROUP BY DATE_FORMAT(visitPersonCount.create_date, '%Y-%m-%d')
|
479
|
481
|
) AS temp3 ON temp_date.date = DATE_FORMAT( temp3.create_date, '%Y-%m-%d' )
|
480
|
482
|
LEFT JOIN (
|
481
|
|
- SELECT
|
482
|
|
- COUNT( 1 ) AS addRegistNum ,
|
483
|
|
- t.create_date AS create_date
|
484
|
|
- FROM
|
485
|
|
- ta_share_person_from t
|
486
|
|
- WHERE
|
487
|
|
- t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id = #{orgId}
|
488
|
|
- <if test="buildingId != null and buildingId != ''">
|
489
|
|
- and t.building_id = #{buildingId}
|
490
|
|
- </if>
|
491
|
|
- and t.status = 1
|
492
|
|
- <if test="targetType != null and targetType != ''">
|
493
|
|
- and t.target_type = #{targetType}
|
494
|
|
- </if>
|
495
|
|
- <if test="startDate != null ">
|
496
|
|
- and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
497
|
|
- </if>
|
498
|
|
- <if test="endDate != null ">
|
499
|
|
- and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
500
|
|
- </if>
|
501
|
|
- <if test="startDate == null or endDate == null">
|
502
|
|
- AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
503
|
|
- </if>
|
504
|
|
- GROUP BY
|
505
|
|
- DATE_FORMAT( t.create_date, '%Y-%m-%d' ) ,t.person_id, t.target_type
|
|
483
|
+ select count(*) as addRegistNum,temp4.* from (
|
|
484
|
+ SELECT
|
|
485
|
+ t.create_date AS create_date,
|
|
486
|
+ t.person_id
|
|
487
|
+ FROM
|
|
488
|
+ ta_share_person_from t
|
|
489
|
+ WHERE
|
|
490
|
+ t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id = #{orgId}
|
|
491
|
+ <if test="buildingId != null and buildingId != ''">
|
|
492
|
+ and t.building_id = #{buildingId}
|
|
493
|
+ </if>
|
|
494
|
+ and t.status = 1
|
|
495
|
+ <if test="targetType != null and targetType != ''">
|
|
496
|
+ and t.target_type = #{targetType}
|
|
497
|
+ </if>
|
|
498
|
+ <if test="startDate != null ">
|
|
499
|
+ and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
|
500
|
+ </if>
|
|
501
|
+ <if test="endDate != null ">
|
|
502
|
+ and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
|
503
|
+ </if>
|
|
504
|
+ <if test="startDate == null or endDate == null">
|
|
505
|
+ AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
|
506
|
+ </if>
|
|
507
|
+ GROUP BY t.person_id, t.target_type
|
|
508
|
+ ) as temp4 GROUP BY DATE_FORMAT(temp4.create_date,'%Y-%m-%d')
|
506
|
509
|
) AS temp4 ON temp_date.date = DATE_FORMAT( temp4.create_date, '%Y-%m-%d' )
|
507
|
|
-
|
508
|
510
|
GROUP BY date
|
509
|
511
|
<if test="colKey == null or colKey == ''">
|
510
|
512
|
ORDER BY date desc
|
|
@@ -541,7 +543,7 @@
|
541
|
543
|
left join ta_building_dynamic e on t.be_share = e.dynamic_id
|
542
|
544
|
left join ta_person f on t.person_id = f.person_id
|
543
|
545
|
WHERE
|
544
|
|
- t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and f.org_id = #{orgId}
|
|
546
|
+ t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
545
|
547
|
<if test="buildingId != null and buildingId != ''">
|
546
|
548
|
and (a.building_id = #{buildingId} or b.building_id = #{buildingId} or c.building_id = #{buildingId} or d.building_id = #{buildingId} or e.building_id = #{buildingId})
|
547
|
549
|
</if>
|
|
@@ -561,7 +563,7 @@
|
561
|
563
|
DATE_FORMAT( t.create_date, '%Y-%m-%d' )
|
562
|
564
|
) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date, '%Y-%m-%d' )
|
563
|
565
|
LEFT JOIN (
|
564
|
|
- select COUNT(1) AS sharePersonNum, temp1.create_date from (
|
|
566
|
+ select temp1.sharePersonNum, temp1.create_date from (
|
565
|
567
|
SELECT COUNT( 1 ) AS sharePersonNum, t.create_date AS create_date, t.person_id
|
566
|
568
|
FROM
|
567
|
569
|
ta_share_count t
|
|
@@ -618,9 +620,10 @@
|
618
|
620
|
DATE_FORMAT( t.visit_time, '%Y-%m-%d' )
|
619
|
621
|
) AS temp2 ON temp_date.date = DATE_FORMAT( temp2.create_date, '%Y-%m-%d' )
|
620
|
622
|
LEFT JOIN (
|
|
623
|
+ select count(*)AS visitPersonNum , visitPersonCount.* from (
|
621
|
624
|
SELECT
|
622
|
|
- COUNT( 1 ) AS visitPersonNum,
|
623
|
|
- t.visit_time AS create_date
|
|
625
|
+ t.visit_time AS create_date,
|
|
626
|
+ t.person_id
|
624
|
627
|
FROM
|
625
|
628
|
ta_person_visit_record t
|
626
|
629
|
WHERE
|
|
@@ -641,12 +644,14 @@
|
641
|
644
|
AND t.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
642
|
645
|
</if>
|
643
|
646
|
GROUP BY
|
644
|
|
- DATE_FORMAT( t.visit_time, '%Y-%m-%d' ) , person_id
|
|
647
|
+ DATE_FORMAT(t.visit_time, '%Y-%m-%d'),
|
|
648
|
+ person_id) as visitPersonCount GROUP BY DATE_FORMAT(visitPersonCount.create_date, '%Y-%m-%d')
|
645
|
649
|
) AS temp3 ON temp_date.date = DATE_FORMAT( temp3.create_date, '%Y-%m-%d' )
|
646
|
650
|
LEFT JOIN (
|
|
651
|
+ select count(*) as addRegistNum,temp4.* from (
|
647
|
652
|
SELECT
|
648
|
|
- COUNT( 1 ) AS addRegistNum ,
|
649
|
|
- t.create_date AS create_date
|
|
653
|
+ t.create_date AS create_date,
|
|
654
|
+ t.person_id
|
650
|
655
|
FROM
|
651
|
656
|
ta_share_person_from t
|
652
|
657
|
WHERE
|
|
@@ -667,10 +672,9 @@
|
667
|
672
|
<if test="startDate == null or endDate == null">
|
668
|
673
|
AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
669
|
674
|
</if>
|
670
|
|
- GROUP BY
|
671
|
|
- DATE_FORMAT( t.create_date, '%Y-%m-%d' ) ,t.person_id, t.target_type
|
|
675
|
+ GROUP BY t.person_id, t.target_type
|
|
676
|
+ ) as temp4 GROUP BY DATE_FORMAT(temp4.create_date,'%Y-%m-%d')
|
672
|
677
|
) AS temp4 ON temp_date.date = DATE_FORMAT( temp4.create_date, '%Y-%m-%d' )
|
673
|
|
-
|
674
|
678
|
GROUP BY date
|
675
|
679
|
<if test="colKey == null or colKey == ''">
|
676
|
680
|
ORDER BY date desc
|
|
@@ -1014,6 +1018,12 @@
|
1014
|
1018
|
ON t.person_id = f.person_id
|
1015
|
1019
|
WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
1016
|
1020
|
and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
|
|
1021
|
+ <if test="activityId != null and activityId != ''">
|
|
1022
|
+ and t.be_share = #{activityId}
|
|
1023
|
+ </if>
|
|
1024
|
+ <if test="activityType != null and activityType != ''">
|
|
1025
|
+ and t.tagert_type = #{activityType}
|
|
1026
|
+ </if>
|
1017
|
1027
|
<if test="sharePersonType != null and sharePersonType != ''">
|
1018
|
1028
|
and f.person_type = #{sharePersonType}
|
1019
|
1029
|
</if>
|
|
@@ -1150,7 +1160,11 @@
|
1150
|
1160
|
</select>
|
1151
|
1161
|
|
1152
|
1162
|
<select id="selectActivityShareNum" resultType="com.huiju.estateagents.excel.ActivityStatistics.ShareNum">
|
1153
|
|
- select person.nickname as sharePersonName, ifnull(person.tel, '空') as sharePersonPhone , person.create_date as shareTime, ifnull(visitPersonNum.visitPersonNum, 0) as visitPersonNum, person.person_type as sharePersonType
|
|
1163
|
+ select person.nickname as sharePersonName,
|
|
1164
|
+ ifnull(person.tel, '空') as sharePersonPhone ,
|
|
1165
|
+ person.create_date as shareTime,
|
|
1166
|
+ ifnull(visitPersonNum.visitPersonNum, 0) as visitPersonNum,
|
|
1167
|
+ person.person_type as sharePersonType
|
1154
|
1168
|
FROM (
|
1155
|
1169
|
SELECT t.*, f.nickname, f.tel, f.person_type
|
1156
|
1170
|
FROM ta_share_count t
|
|
@@ -1167,7 +1181,13 @@
|
1167
|
1181
|
LEFT JOIN ta_person f
|
1168
|
1182
|
ON t.person_id = f.person_id
|
1169
|
1183
|
WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost')
|
1170
|
|
- and f.org_id = #{orgId}
|
|
1184
|
+ <if test="activityId != null and activityId != ''">
|
|
1185
|
+ and t.be_share = #{activityId}
|
|
1186
|
+ </if>
|
|
1187
|
+ <if test="activityType != null and activityType != ''">
|
|
1188
|
+ and t.tagert_type = #{activityType}
|
|
1189
|
+ </if>
|
|
1190
|
+ and t.org_id = #{orgId}
|
1171
|
1191
|
and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' )
|
1172
|
1192
|
and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
|
1173
|
1193
|
) as person
|
|
@@ -1239,7 +1259,14 @@
|
1239
|
1259
|
left join ta_person e on t.share_person = e.person_id
|
1240
|
1260
|
left join ta_user f on t.share_person = f.user_id
|
1241
|
1261
|
WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id = #{orgId} and t.status = 1
|
|
1262
|
+ and t.is_first_time = 1
|
1242
|
1263
|
and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' ) and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
|
1264
|
+ <if test="activityId != null and activityId != ''">
|
|
1265
|
+ and t.target_id = #{activityId}
|
|
1266
|
+ </if>
|
|
1267
|
+ <if test="activityType != null and activityType != ''">
|
|
1268
|
+ and t.target_type = concat(#{activityType}, '_share')
|
|
1269
|
+ </if>
|
1243
|
1270
|
<if test="personFrom != null and personFrom != ''">
|
1244
|
1271
|
and b.scene_id = #{personFrom}
|
1245
|
1272
|
</if>
|
|
@@ -1271,38 +1298,224 @@
|
1271
|
1298
|
</select>
|
1272
|
1299
|
|
1273
|
1300
|
<select id="selectActivityVisitNum" resultType="com.huiju.estateagents.excel.ActivityStatistics.VisitNum">
|
1274
|
|
- SELECT
|
|
1301
|
+ select
|
|
1302
|
+ a.nickname, a.phone,
|
|
1303
|
+ if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
|
|
1304
|
+ a.province,
|
|
1305
|
+ b1.scene_name as personFrom,
|
|
1306
|
+ d.name as realtyConsultant,
|
|
1307
|
+ d.phone as realtyConsultantPhone,
|
|
1308
|
+ t.visit_time as visitDate
|
|
1309
|
+ From (
|
|
1310
|
+ SELECT
|
|
1311
|
+ t.person_id, t.visit_time
|
|
1312
|
+ FROM
|
|
1313
|
+ ta_person_visit_record t
|
|
1314
|
+ WHERE
|
|
1315
|
+ t.`event` = 'detail'
|
|
1316
|
+ AND t.event_type IN (
|
|
1317
|
+ 'activity',
|
|
1318
|
+ 'help',
|
|
1319
|
+ 'group',
|
|
1320
|
+ 'h5'
|
|
1321
|
+ )
|
|
1322
|
+ <if test="activityId != null and activityId != ''">
|
|
1323
|
+ and t.target_id = #{activityId}
|
|
1324
|
+ </if>
|
|
1325
|
+ <if test="activityType != null and activityType != ''">
|
|
1326
|
+ and t.event_type = #{activityType}
|
|
1327
|
+ </if>
|
|
1328
|
+ AND t.org_id = #{orgId}
|
|
1329
|
+ AND t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
|
|
1330
|
+ AND t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
|
|
1331
|
+ ) t
|
|
1332
|
+ left join ta_person a on t.person_id = a.person_id
|
|
1333
|
+ left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId}
|
|
1334
|
+ left join td_wx_dict b1 on b.scene_id = b1.scene_id
|
|
1335
|
+ left join (
|
|
1336
|
+ select d.person_id, d.`name`, d.phone From ta_recommend_customer c
|
|
1337
|
+ left join ta_person d on c.recommend_person = d.person_id where c.org_id = #{orgId} group by d.person_id
|
|
1338
|
+ ) as d on t.person_id = d.person_id
|
|
1339
|
+ <where>
|
|
1340
|
+ <if test="personFrom != null and personFrom != ''">
|
|
1341
|
+ and b.scene_id = #{personFrom}
|
|
1342
|
+ </if>
|
|
1343
|
+ <if test="province != null and province != ''">
|
|
1344
|
+ and a.province = #{province}
|
|
1345
|
+ </if>
|
|
1346
|
+ <if test="realtyConsultant != null and realtyConsultant != ''">
|
|
1347
|
+ and d.name = #{realtyConsultant}
|
|
1348
|
+ </if>
|
|
1349
|
+ <if test="realtyConsultantPhone != null and realtyConsultantPhone != ''">
|
|
1350
|
+ and d.phone = #{realtyConsultantPhone}
|
|
1351
|
+ </if>
|
|
1352
|
+ </where>
|
|
1353
|
+ order by t.visit_time desc
|
|
1354
|
+ </select>
|
|
1355
|
+
|
|
1356
|
+ <select id="selectActivityVisitNumExport" resultType="com.huiju.estateagents.excel.ActivityStatistics.VisitNum">
|
|
1357
|
+ select
|
1275
|
1358
|
a.nickname, a.phone,
|
1276
|
1359
|
if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
|
1277
|
1360
|
a.province,
|
1278
|
1361
|
b1.scene_name as personFrom,
|
1279
|
1362
|
d.name as realtyConsultant,
|
1280
|
1363
|
d.phone as realtyConsultantPhone,
|
1281
|
|
- ifnull(e.nickname, f.user_name) as sharePersonName,
|
1282
|
|
- e.phone as sharePersonPhone,
|
1283
|
|
- t.create_date as visitDate
|
1284
|
|
- FROM ta_share_person_from t
|
1285
|
|
- left join ta_person a on t.person_id = a.person_id
|
1286
|
|
- left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = 84 and b.is_first_time =1
|
|
1364
|
+ t.visit_time as visitDate
|
|
1365
|
+ From (
|
|
1366
|
+ SELECT
|
|
1367
|
+ t.person_id, t.visit_time
|
|
1368
|
+ FROM
|
|
1369
|
+ ta_person_visit_record t
|
|
1370
|
+ WHERE
|
|
1371
|
+ t.`event` = 'detail'
|
|
1372
|
+ AND t.event_type IN (
|
|
1373
|
+ 'activity',
|
|
1374
|
+ 'help',
|
|
1375
|
+ 'group',
|
|
1376
|
+ 'h5'
|
|
1377
|
+ )
|
|
1378
|
+ AND t.org_id = #{orgId}
|
|
1379
|
+ AND t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
|
|
1380
|
+ AND t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
|
|
1381
|
+ ) t
|
|
1382
|
+ left join ta_person a on t.person_id = a.person_id
|
|
1383
|
+ left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId}
|
1287
|
1384
|
left join td_wx_dict b1 on b.scene_id = b1.scene_id
|
1288
|
|
- left join ta_recommend_customer c on c.person_id = t.person_id
|
1289
|
|
- left join ta_person d on c.recommend_person = d.person_id
|
1290
|
|
- left join ta_person e on t.share_person = e.person_id
|
1291
|
|
- left join ta_user f on t.share_person = f.user_id
|
1292
|
|
- WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id = #{orgId} and t.status = 1
|
1293
|
|
- and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' ) and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
1294
|
|
- <if test="personFrom != null and personFrom != ''">
|
1295
|
|
- and b.scene_id = #{personFrom}
|
1296
|
|
- </if>
|
1297
|
|
- <if test="province != null and province != ''">
|
1298
|
|
- and a.province = #{province}
|
1299
|
|
- </if>
|
1300
|
|
- <if test="realtyConsultant != null and realtyConsultant != ''">
|
1301
|
|
- and d.name = #{realtyConsultant}
|
1302
|
|
- </if>
|
1303
|
|
- <if test="realtyConsultantPhone != null and realtyConsultantPhone != ''">
|
1304
|
|
- and d.phone = #{realtyConsultantPhone}
|
|
1385
|
+ left join (
|
|
1386
|
+ select d.person_id, d.`name`, d.phone From ta_recommend_customer c
|
|
1387
|
+ left join ta_person d on c.recommend_person = d.person_id where c.org_id = #{orgId} group by d.person_id
|
|
1388
|
+ ) as d on t.person_id = d.person_id
|
|
1389
|
+ <where>
|
|
1390
|
+ <if test="personFrom != null and personFrom != ''">
|
|
1391
|
+ and b.scene_id = #{personFrom}
|
|
1392
|
+ </if>
|
|
1393
|
+ <if test="province != null and province != ''">
|
|
1394
|
+ and a.province = #{province}
|
|
1395
|
+ </if>
|
|
1396
|
+ <if test="realtyConsultant != null and realtyConsultant != ''">
|
|
1397
|
+ and d.name = #{realtyConsultant}
|
|
1398
|
+ </if>
|
|
1399
|
+ <if test="realtyConsultantPhone != null and realtyConsultantPhone != ''">
|
|
1400
|
+ and d.phone = #{realtyConsultantPhone}
|
|
1401
|
+ </if>
|
|
1402
|
+ </where>
|
|
1403
|
+ order by t.visit_time desc
|
|
1404
|
+ </select>
|
|
1405
|
+
|
|
1406
|
+ <select id="selectActivityVisitPersonNum" resultType="com.huiju.estateagents.excel.ActivityStatistics.VisitPersonNum">
|
|
1407
|
+ select
|
|
1408
|
+ a.nickname, a.phone,
|
|
1409
|
+ if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
|
|
1410
|
+ a.province,
|
|
1411
|
+ b1.scene_name as personFrom,
|
|
1412
|
+ d.name as realtyConsultant,
|
|
1413
|
+ d.phone as realtyConsultantPhone,
|
|
1414
|
+ t.create_date as visitDate,
|
|
1415
|
+ t.visitNum
|
|
1416
|
+ from (
|
|
1417
|
+ SELECT
|
|
1418
|
+ t.visit_time AS create_date,
|
|
1419
|
+ t.person_id,
|
|
1420
|
+ count(*) as visitNum
|
|
1421
|
+ FROM
|
|
1422
|
+ ta_person_visit_record t
|
|
1423
|
+ WHERE
|
|
1424
|
+ t.`event` = 'detail'
|
|
1425
|
+ AND t.event_type IN (
|
|
1426
|
+ 'activity',
|
|
1427
|
+ 'help',
|
|
1428
|
+ 'group',
|
|
1429
|
+ 'h5'
|
|
1430
|
+ )
|
|
1431
|
+ AND t.org_id = 84
|
|
1432
|
+ AND t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
|
|
1433
|
+ AND t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
|
|
1434
|
+ <if test="activityId != null and activityId != ''">
|
|
1435
|
+ and t.target_id = #{activityId}
|
|
1436
|
+ </if>
|
|
1437
|
+ <if test="activityType != null and activityType != ''">
|
|
1438
|
+ and t.event_type = #{activityType}
|
1305
|
1439
|
</if>
|
|
1440
|
+ GROUP BY
|
|
1441
|
+ t.person_id ) as t
|
|
1442
|
+ left join ta_person a on t.person_id = a.person_id
|
|
1443
|
+ left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId}
|
|
1444
|
+ left join td_wx_dict b1 on b.scene_id = b1.scene_id
|
|
1445
|
+ left join (
|
|
1446
|
+ select d.person_id, d.`name`, d.phone From ta_recommend_customer c
|
|
1447
|
+ left join ta_person d on c.recommend_person = d.person_id where c.org_id = #{orgId} group by d.person_id
|
|
1448
|
+ ) as d on t.person_id = d.person_id
|
|
1449
|
+ <where>
|
|
1450
|
+ <if test="personFrom != null and personFrom != ''">
|
|
1451
|
+ and b.scene_id = #{personFrom}
|
|
1452
|
+ </if>
|
|
1453
|
+ <if test="province != null and province != ''">
|
|
1454
|
+ and a.province = #{province}
|
|
1455
|
+ </if>
|
|
1456
|
+ <if test="realtyConsultant != null and realtyConsultant != ''">
|
|
1457
|
+ and d.name = #{realtyConsultant}
|
|
1458
|
+ </if>
|
|
1459
|
+ <if test="realtyConsultantPhone != null and realtyConsultantPhone != ''">
|
|
1460
|
+ and d.phone = #{realtyConsultantPhone}
|
|
1461
|
+ </if>
|
|
1462
|
+ </where>
|
|
1463
|
+ order by t.create_date desc
|
|
1464
|
+ </select>
|
|
1465
|
+
|
|
1466
|
+ <select id="selectActivityVisitPersonNumExport"
|
|
1467
|
+ resultType="com.huiju.estateagents.excel.ActivityStatistics.VisitPersonNum">
|
|
1468
|
+ select
|
|
1469
|
+ a.nickname, a.phone,
|
|
1470
|
+ if(a.gender = '1', '男', if(a.gender = '2', '女','未知') ) as gender,
|
|
1471
|
+ a.province,
|
|
1472
|
+ b1.scene_name as personFrom,
|
|
1473
|
+ d.name as realtyConsultant,
|
|
1474
|
+ d.phone as realtyConsultantPhone,
|
|
1475
|
+ t.create_date as visitDate,
|
|
1476
|
+ t.visitNum
|
|
1477
|
+ from (
|
|
1478
|
+ SELECT
|
|
1479
|
+ t.visit_time AS create_date,
|
|
1480
|
+ t.person_id,
|
|
1481
|
+ count(*) as visitNum
|
|
1482
|
+ FROM
|
|
1483
|
+ ta_person_visit_record t
|
|
1484
|
+ WHERE
|
|
1485
|
+ t.`event` = 'detail'
|
|
1486
|
+ AND t.event_type IN (
|
|
1487
|
+ 'activity',
|
|
1488
|
+ 'help',
|
|
1489
|
+ 'group',
|
|
1490
|
+ 'h5'
|
|
1491
|
+ )
|
|
1492
|
+ AND t.org_id = 84
|
|
1493
|
+ AND t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
|
|
1494
|
+ AND t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
|
|
1495
|
+ GROUP BY
|
|
1496
|
+ t.person_id ) as t
|
|
1497
|
+ left join ta_person a on t.person_id = a.person_id
|
|
1498
|
+ left join ta_person_from_record b on a.person_id = b.person_id and b.org_id = #{orgId}
|
|
1499
|
+ left join td_wx_dict b1 on b.scene_id = b1.scene_id
|
|
1500
|
+ left join (
|
|
1501
|
+ select d.person_id, d.`name`, d.phone From ta_recommend_customer c
|
|
1502
|
+ left join ta_person d on c.recommend_person = d.person_id where c.org_id = #{orgId} group by d.person_id
|
|
1503
|
+ ) as d on t.person_id = d.person_id
|
|
1504
|
+ <where>
|
|
1505
|
+ <if test="personFrom != null and personFrom != ''">
|
|
1506
|
+ and b.scene_id = #{personFrom}
|
|
1507
|
+ </if>
|
|
1508
|
+ <if test="province != null and province != ''">
|
|
1509
|
+ and a.province = #{province}
|
|
1510
|
+ </if>
|
|
1511
|
+ <if test="realtyConsultant != null and realtyConsultant != ''">
|
|
1512
|
+ and d.name = #{realtyConsultant}
|
|
1513
|
+ </if>
|
|
1514
|
+ <if test="realtyConsultantPhone != null and realtyConsultantPhone != ''">
|
|
1515
|
+ and d.phone = #{realtyConsultantPhone}
|
|
1516
|
+ </if>
|
|
1517
|
+ </where>
|
|
1518
|
+ order by t.create_date desc
|
1306
|
1519
|
</select>
|
1307
|
1520
|
|
1308
|
1521
|
</mapper>
|