|
@@ -3,86 +3,116 @@
|
3
|
3
|
<mapper namespace="com.huiju.estateagents.statistic.mapper.TaActicityStaticMapper">
|
4
|
4
|
|
5
|
5
|
<select id="selectSharePersonNum" resultType="java.lang.Integer">
|
6
|
|
- select count(*) From ta_share_count t
|
7
|
|
- left join ta_help_activity a on t.be_share = a.help_activity_id
|
8
|
|
- left join ta_share_activity b on t.be_share = b.share_id
|
9
|
|
- left join ta_live_activity c on t.be_share = c.live_activity_id
|
10
|
|
- left join ta_drainage d on t.be_share = d.drainage_id
|
11
|
|
- left join ta_building_dynamic e on t.be_share = e.dynamic_id
|
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 t.org_id = #{orgId}
|
|
6
|
+ SELECT count(1) as sharePersonNum
|
|
7
|
+ FROM (
|
|
8
|
+ SELECT count(DISTINCT(t.person_id))
|
|
9
|
+ FROM ta_share_count t
|
|
10
|
+ LEFT JOIN ta_help_activity a
|
|
11
|
+ ON t.be_share = a.help_activity_id
|
|
12
|
+ LEFT JOIN ta_share_activity b
|
|
13
|
+ ON t.be_share = b.share_id
|
|
14
|
+ LEFT JOIN ta_live_activity c
|
|
15
|
+ ON t.be_share = c.live_activity_id
|
|
16
|
+ LEFT JOIN ta_drainage d
|
|
17
|
+ ON t.be_share = d.drainage_id
|
|
18
|
+ LEFT JOIN ta_building_dynamic e
|
|
19
|
+ ON t.be_share = e.dynamic_id
|
|
20
|
+ LEFT JOIN ta_person f
|
|
21
|
+ ON t.person_id = f.person_id
|
|
22
|
+ WHERE
|
|
23
|
+ t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
14
|
24
|
<if test="buildingId != null and buildingId != ''">
|
15
|
25
|
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
|
26
|
</if>
|
17
|
27
|
<if test="targetType != null and targetType != ''">
|
18
|
28
|
and t.tagert_type = #{targetType}
|
19
|
29
|
</if>
|
20
|
|
- <if test="startDate != null">
|
21
|
|
- and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
|
30
|
+ <if test="startDate != null ">
|
|
31
|
+ and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
|
22
|
32
|
</if>
|
23
|
|
- <if test="endDate != null">
|
24
|
|
- and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
|
33
|
+ <if test="endDate != null ">
|
|
34
|
+ and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
|
|
35
|
+ </if>
|
|
36
|
+ <if test="startDate == null or endDate == null ">
|
|
37
|
+ AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
25
|
38
|
</if>
|
|
39
|
+ GROUP BY DATE_FORMAT( t.create_date, '%Y-%m-%d' ) ,t.person_id
|
|
40
|
+ ) as temp1
|
26
|
41
|
</select>
|
27
|
42
|
|
28
|
43
|
<select id="selectShareNum" resultType="java.lang.Integer">
|
29
|
|
- select count(*) from (
|
30
|
|
- select DISTINCT t.person_id From ta_share_count t
|
|
44
|
+ SELECT
|
|
45
|
+ COUNT( 1 ) AS shareNum
|
|
46
|
+ FROM
|
|
47
|
+ ta_share_count t
|
31
|
48
|
left join ta_help_activity a on t.be_share = a.help_activity_id
|
32
|
49
|
left join ta_share_activity b on t.be_share = b.share_id
|
33
|
50
|
left join ta_live_activity c on t.be_share = c.live_activity_id
|
34
|
51
|
left join ta_drainage d on t.be_share = d.drainage_id
|
35
|
52
|
left join ta_building_dynamic e on t.be_share = e.dynamic_id
|
36
|
53
|
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 t.org_id = #{orgId}
|
|
54
|
+ WHERE
|
|
55
|
+ t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
38
|
56
|
<if test="buildingId != null and buildingId != ''">
|
39
|
57
|
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
|
58
|
</if>
|
41
|
59
|
<if test="targetType != null and targetType != ''">
|
42
|
60
|
and t.tagert_type = #{targetType}
|
43
|
61
|
</if>
|
44
|
|
- <if test="startDate != null">
|
45
|
|
- and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
|
62
|
+ <if test="startDate != null ">
|
|
63
|
+ and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
|
46
|
64
|
</if>
|
47
|
|
- <if test="endDate != null">
|
48
|
|
- and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
|
65
|
+ <if test="endDate != null ">
|
|
66
|
+ and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
|
|
67
|
+ </if>
|
|
68
|
+ <if test="startDate == null or endDate == null ">
|
|
69
|
+ AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
49
|
70
|
</if>
|
50
|
|
- ) c
|
51
|
71
|
</select>
|
52
|
72
|
|
53
|
73
|
<select id="selectVisitPersonNum" resultType="java.lang.Integer">
|
54
|
|
- select count(*) from ta_person_visit_record t
|
55
|
|
- where t.`event` = 'detail' and t.event_type in ('activity','help','group','h5') and t.org_id = #{orgId}
|
|
74
|
+ select count(*)AS visitPersonNum from (
|
|
75
|
+ SELECT
|
|
76
|
+ t.visit_time AS create_date,
|
|
77
|
+ t.person_id
|
|
78
|
+ FROM
|
|
79
|
+ ta_person_visit_record t
|
|
80
|
+ WHERE
|
|
81
|
+ t.`event` = 'detail' and t.event_type in ('activity','help','group','h5') and t.org_id = #{orgId}
|
56
|
82
|
<if test="buildingId != null and buildingId != ''">
|
57
|
|
- and t.building_id = #{buildingId}
|
|
83
|
+ and t.building_id = #{buildingId}
|
58
|
84
|
</if>
|
59
|
85
|
<if test="targetType != null and targetType != ''">
|
60
|
|
- and t.target_type = #{targetType}
|
|
86
|
+ and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' else t.target_type = #{targetType} end)
|
61
|
87
|
</if>
|
62
|
88
|
<if test="startDate != null">
|
63
|
|
- and t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
|
89
|
+ and t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
|
64
|
90
|
</if>
|
65
|
91
|
<if test="endDate != null">
|
66
|
|
- and t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
|
92
|
+ and t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
|
|
93
|
+ </if>
|
|
94
|
+ <if test="startDate == null or endDate == null">
|
|
95
|
+ AND t.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
|
67
|
96
|
</if>
|
|
97
|
+ GROUP BY
|
|
98
|
+ DATE_FORMAT(t.visit_time, '%Y-%m-%d'),
|
|
99
|
+ person_id) as visitPersonCount
|
68
|
100
|
</select>
|
69
|
101
|
|
70
|
102
|
<select id="selectVisitNum" resultType="java.lang.Integer">
|
71
|
|
- select count(*) From (
|
72
|
|
- select DISTINCT t.person_id from ta_person_visit_record t where t.`event` = 'detail' and t.event_type in ('activity','help','group','h5') and t.org_id = #{orgId}
|
|
103
|
+ select count(*) from ta_person_visit_record t where t.`event` = 'detail' and t.event_type in ('activity','help','group','h5') and t.org_id = #{orgId}
|
73
|
104
|
<if test="buildingId != null and buildingId != ''">
|
74
|
105
|
and t.building_id = #{buildingId}
|
75
|
106
|
</if>
|
76
|
107
|
<if test="targetType != null and targetType != ''">
|
77
|
|
- and t.target_type = #{targetType}
|
|
108
|
+ and (case when #{targetType} = 'activity' then t.target_type = 'dynamic' else t.target_type = #{targetType} end)
|
78
|
109
|
</if>
|
79
|
110
|
<if test="startDate != null">
|
80
|
|
- and t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
|
111
|
+ and t.visit_time >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
|
81
|
112
|
</if>
|
82
|
113
|
<if test="endDate != null">
|
83
|
|
- and t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
|
114
|
+ and t.visit_time <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
|
84
|
115
|
</if>
|
85
|
|
- ) c;
|
86
|
116
|
</select>
|
87
|
117
|
|
88
|
118
|
<select id="selectShareCount" resultType="java.util.Map">
|
|
@@ -851,6 +881,7 @@
|
851
|
881
|
select count(*) as addRegistNum ,addRegistNum.target_id, addRegistNum.target_type From (
|
852
|
882
|
select count(*), a.* From ta_share_person_from a where a.target_type IN ( 'dynamic_share', 'h5_share', 'help_share', 'live_share', 'group_share' ) and a.org_id = #{orgId}
|
853
|
883
|
and a.status = 1
|
|
884
|
+ and t.is_first_time = 1
|
854
|
885
|
<if test="targetType != null and targetType != ''">
|
855
|
886
|
and a.target_type = #{targetType}
|
856
|
887
|
</if>
|
|
@@ -1008,6 +1039,7 @@
|
1008
|
1039
|
select count(*) as addRegistNum ,addRegistNum.target_id, addRegistNum.target_type From (
|
1009
|
1040
|
select count(*), a.* From ta_share_person_from a where a.target_type IN ( 'dynamic_share', 'h5_share', 'help_share', 'live_share', 'group_share' ) and a.org_id = #{orgId}
|
1010
|
1041
|
and a.status = 1
|
|
1042
|
+ and a.is_first_time = 1
|
1011
|
1043
|
<if test="startDate != null ">
|
1012
|
1044
|
and a.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
1013
|
1045
|
</if>
|
|
@@ -1057,6 +1089,15 @@
|
1057
|
1089
|
ON t.person_id = f.person_id
|
1058
|
1090
|
WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
1059
|
1091
|
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' )
|
|
1092
|
+ <if test="buildingId != null and buildingId != ''">
|
|
1093
|
+ and (
|
|
1094
|
+ a.building_id = #{buildingId}
|
|
1095
|
+ or b.building_id = #{buildingId}
|
|
1096
|
+ or c.building_id = #{buildingId}
|
|
1097
|
+ or d.building_id = #{buildingId}
|
|
1098
|
+ or e.building_id = #{buildingId}
|
|
1099
|
+ )
|
|
1100
|
+ </if>
|
1060
|
1101
|
<if test="activityId != null and activityId != ''">
|
1061
|
1102
|
and t.be_share = #{activityId}
|
1062
|
1103
|
</if>
|
|
@@ -1137,7 +1178,9 @@
|
1137
|
1178
|
when person.person_type = 'customer' then '客户'
|
1138
|
1179
|
when person.person_type = 'drift' then '游客'
|
1139
|
1180
|
when person.person_type = 'Realty Consultant' then '置业顾问'
|
1140
|
|
- end as sharePersonType from (
|
|
1181
|
+ end as sharePersonType,
|
|
1182
|
+ person.person_id
|
|
1183
|
+ from (
|
1141
|
1184
|
SELECT t.*, f.nickname, f.phone, f.person_type
|
1142
|
1185
|
FROM ta_share_count t
|
1143
|
1186
|
LEFT JOIN ta_help_activity a
|
|
@@ -1154,6 +1197,21 @@
|
1154
|
1197
|
ON t.person_id = f.person_id
|
1155
|
1198
|
WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
|
1156
|
1199
|
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' )
|
|
1200
|
+ <if test="buildingId != null and buildingId != ''">
|
|
1201
|
+ and (
|
|
1202
|
+ a.building_id = #{buildingId}
|
|
1203
|
+ or b.building_id = #{buildingId}
|
|
1204
|
+ or c.building_id = #{buildingId}
|
|
1205
|
+ or d.building_id = #{buildingId}
|
|
1206
|
+ or e.building_id = #{buildingId}
|
|
1207
|
+ )
|
|
1208
|
+ </if>
|
|
1209
|
+ <if test="activityId != null and activityId != ''">
|
|
1210
|
+ and t.be_share = #{activityId}
|
|
1211
|
+ </if>
|
|
1212
|
+ <if test="activityType != null and activityType != ''">
|
|
1213
|
+ and t.tagert_type = #{activityType}
|
|
1214
|
+ </if>
|
1157
|
1215
|
<if test="sharePersonType != null and sharePersonType != ''">
|
1158
|
1216
|
and f.person_type = #{sharePersonType}
|
1159
|
1217
|
</if>
|
|
@@ -1163,7 +1221,7 @@
|
1163
|
1221
|
<if test="sharePhone != null and sharePhone != ''">
|
1164
|
1222
|
and f.phone = #{sharePhone}
|
1165
|
1223
|
</if>
|
1166
|
|
- GROUP BY t.person_id, t.person_id
|
|
1224
|
+ GROUP BY t.person_id
|
1167
|
1225
|
) as person
|
1168
|
1226
|
|
1169
|
1227
|
left join (
|
|
@@ -1199,16 +1257,16 @@
|
1199
|
1257
|
) as visitNum on visitNum.person_id = person.person_id
|
1200
|
1258
|
|
1201
|
1259
|
left join (
|
1202
|
|
- select count(1) as visitPersonNum, visitNum.share_person as person_id From (
|
1203
|
|
- select count(1), t.share_person From ta_share_person_from t
|
1204
|
|
- left join
|
1205
|
|
- (
|
1206
|
|
- select a.person_id, b.user_id From ta_person a left join ta_user b on a.user_id = b.user_id where a.org_id = #{orgId}
|
1207
|
|
- ) as a on t.share_person = a.person_id or t.share_person = a.user_id
|
1208
|
|
- where 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' )
|
1209
|
|
- and t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share')
|
1210
|
|
- group by t.person_id, t.share_person
|
1211
|
|
- ) as visitNum group by visitNum.share_person
|
|
1260
|
+ select count(1) as visitPersonNum, visitNum.share_person as person_id From (
|
|
1261
|
+ select count(1), t.share_person From ta_share_person_from t
|
|
1262
|
+ left join
|
|
1263
|
+ (
|
|
1264
|
+ select a.person_id, b.user_id From ta_person a left join ta_user b on a.user_id = b.user_id where a.org_id = #{orgId}
|
|
1265
|
+ ) as a on t.share_person = a.person_id or t.share_person = a.user_id
|
|
1266
|
+ where 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' )
|
|
1267
|
+ and t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share')
|
|
1268
|
+ group by t.person_id, t.share_person
|
|
1269
|
+ ) as visitNum group by visitNum.share_person
|
1212
|
1270
|
) as visitPersonNum on visitPersonNum.person_id = person.person_id
|
1213
|
1271
|
<if test="colKey == null or colKey == ''">
|
1214
|
1272
|
order by person.create_date desc
|
|
@@ -1246,6 +1304,15 @@
|
1246
|
1304
|
<if test="activityType != null and activityType != ''">
|
1247
|
1305
|
and t.tagert_type = #{activityType}
|
1248
|
1306
|
</if>
|
|
1307
|
+ <if test="buildingId != null and buildingId != ''">
|
|
1308
|
+ and (
|
|
1309
|
+ a.building_id = #{buildingId}
|
|
1310
|
+ or b.building_id = #{buildingId}
|
|
1311
|
+ or c.building_id = #{buildingId}
|
|
1312
|
+ or d.building_id = #{buildingId}
|
|
1313
|
+ or e.building_id = #{buildingId}
|
|
1314
|
+ )
|
|
1315
|
+ </if>
|
1249
|
1316
|
and t.org_id = #{orgId}
|
1250
|
1317
|
and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' )
|
1251
|
1318
|
and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
|
|
@@ -1299,14 +1366,41 @@
|
1299
|
1366
|
LEFT JOIN ta_person f
|
1300
|
1367
|
ON t.person_id = f.person_id
|
1301
|
1368
|
WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost')
|
1302
|
|
- and f.org_id = #{orgId}
|
|
1369
|
+ <if test="activityId != null and activityId != ''">
|
|
1370
|
+ and t.be_share = #{activityId}
|
|
1371
|
+ </if>
|
|
1372
|
+ <if test="activityType != null and activityType != ''">
|
|
1373
|
+ and t.tagert_type = #{activityType}
|
|
1374
|
+ </if>
|
|
1375
|
+ <if test="buildingId != null and buildingId != ''">
|
|
1376
|
+ and (
|
|
1377
|
+ a.building_id = #{buildingId}
|
|
1378
|
+ or b.building_id = #{buildingId}
|
|
1379
|
+ or c.building_id = #{buildingId}
|
|
1380
|
+ or d.building_id = #{buildingId}
|
|
1381
|
+ or e.building_id = #{buildingId}
|
|
1382
|
+ )
|
|
1383
|
+ </if>
|
|
1384
|
+ and t.org_id = #{orgId}
|
1303
|
1385
|
and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' )
|
1304
|
1386
|
and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
|
|
1387
|
+ <if test="personId != null and personId != ''">
|
|
1388
|
+ and t.person_id = #{personId}
|
|
1389
|
+ </if>
|
1305
|
1390
|
) as person
|
1306
|
1391
|
LEFT JOIN (
|
1307
|
1392
|
SELECT count(*) as visitPersonNum,t.share_person as person_id
|
1308
|
1393
|
FROM ta_share_person_from t
|
1309
|
|
- where t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id = #{orgId} group by t.person_id
|
|
1394
|
+ where t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id = #{orgId}
|
|
1395
|
+ <if test="personId != null and personId != ''">
|
|
1396
|
+ and t.share_person = #{personId}
|
|
1397
|
+ </if>
|
|
1398
|
+ <if test="startDate != null ">
|
|
1399
|
+ and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
|
|
1400
|
+ </if>
|
|
1401
|
+ <if test="endDate != null ">
|
|
1402
|
+ and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
|
1403
|
+ </if>
|
1310
|
1404
|
) as visitPersonNum
|
1311
|
1405
|
ON visitPersonNum.person_id = person.person_id order by person.create_date desc
|
1312
|
1406
|
</select>
|
|
@@ -1362,7 +1456,9 @@
|
1362
|
1456
|
left join ta_person d on c.recommend_person = d.person_id
|
1363
|
1457
|
left join ta_person e on t.share_person = e.person_id
|
1364
|
1458
|
left join ta_user f on t.share_person = f.user_id
|
1365
|
|
- WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id = #{orgId} and t.status = 1
|
|
1459
|
+ WHERE t.target_type in ('dynamic_share','h5_share','help_share','live_share', 'group_share') and t.org_id = #{orgId}
|
|
1460
|
+ and t.status = 1
|
|
1461
|
+ and t.is_first_time = 1
|
1366
|
1462
|
and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d' ) and t.create_date <= DATE_FORMAT(#{endDate}, '%Y-%m-%d' )
|
1367
|
1463
|
<if test="personFrom != null and personFrom != ''">
|
1368
|
1464
|
and b.scene_id = #{personFrom}
|