|
@@ -0,0 +1,183 @@
|
|
1
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
3
|
+<mapper namespace="com.huiju.estateagents.mapper.ActivityManageMapper">
|
|
4
|
+
|
|
5
|
+ <select id = "getStatisticDataByType" resultType="com.huiju.estateagents.bo.request.ActivityStatisticResponseBO">
|
|
6
|
+ select
|
|
7
|
+ -- 活动分享人数
|
|
8
|
+ (SELECT count(DISTINCT b.person_id) FROM ta_share_count b
|
|
9
|
+ WHERE b.org_id = a.org_id
|
|
10
|
+ <choose>
|
|
11
|
+ <when test=" type == 'live'">
|
|
12
|
+ AND b.tagert_type like concat('%',a.target_type,'%')
|
|
13
|
+ </when>
|
|
14
|
+ <otherwise>
|
|
15
|
+ AND b.tagert_type = a.target_type
|
|
16
|
+ </otherwise>
|
|
17
|
+ </choose>
|
|
18
|
+ AND b.be_share = a.target_id
|
|
19
|
+ ) as share_persons,
|
|
20
|
+
|
|
21
|
+ -- 活动分享次数
|
|
22
|
+ (SELECT count(*) FROM ta_share_count c
|
|
23
|
+ WHERE c.org_id = a.org_id
|
|
24
|
+ <choose>
|
|
25
|
+ <when test=" type == 'live'">
|
|
26
|
+ AND c.tagert_type like concat('%',a.target_type,'%')
|
|
27
|
+ </when>
|
|
28
|
+ <otherwise>
|
|
29
|
+ AND c.tagert_type = a.target_type
|
|
30
|
+ </otherwise>
|
|
31
|
+ </choose>
|
|
32
|
+ AND c.be_share = a.target_id
|
|
33
|
+ ) as share_num,
|
|
34
|
+
|
|
35
|
+ -- 活动访问人数
|
|
36
|
+ (select count( DISTINCT d.person_id ) from ta_person_visit_record d
|
|
37
|
+ WHERE d.org_id = a.org_id
|
|
38
|
+ <choose>
|
|
39
|
+ <when test=" type == 'live'">
|
|
40
|
+ AND d.target_type like concat('%',REPLACE(a.target_type, 'activity', 'dynamic'),'%')
|
|
41
|
+ </when>
|
|
42
|
+ <otherwise>
|
|
43
|
+ AND d.target_type = REPLACE(a.target_type, 'activity', 'dynamic')
|
|
44
|
+ </otherwise>
|
|
45
|
+ </choose>
|
|
46
|
+ AND d.target_id = a.target_id
|
|
47
|
+ AND d.`event` = 'detail'
|
|
48
|
+ ) as visit_persons,
|
|
49
|
+
|
|
50
|
+ -- 活动访问次数
|
|
51
|
+ (select count(*) from ta_person_visit_record e
|
|
52
|
+ WHERE e.org_id = a.org_id
|
|
53
|
+ <choose>
|
|
54
|
+ <when test=" type == 'live'">
|
|
55
|
+ AND e.target_type like concat('%',REPLACE(a.target_type, 'activity', 'dynamic'),'%')
|
|
56
|
+ </when>
|
|
57
|
+ <otherwise>
|
|
58
|
+ AND e.target_type = REPLACE(a.target_type, 'activity', 'dynamic')
|
|
59
|
+ </otherwise>
|
|
60
|
+ </choose>
|
|
61
|
+ AND e.target_id = a.target_id
|
|
62
|
+ AND e.`event` = 'detail'
|
|
63
|
+ ) as visit_num,
|
|
64
|
+
|
|
65
|
+ -- 分享新增用户
|
|
66
|
+ (select count(*) from ta_share_person_from f
|
|
67
|
+ where f.org_id = a.org_id
|
|
68
|
+ <choose>
|
|
69
|
+ <when test=" type == 'live'">
|
|
70
|
+ AND f.target_type = concat('%',REPLACE(a.target_type, 'activity', 'dynamic'), '_share%')
|
|
71
|
+ </when>
|
|
72
|
+ <otherwise>
|
|
73
|
+ AND f.target_type = concat(REPLACE(a.target_type, 'activity', 'dynamic'), '_share')
|
|
74
|
+ </otherwise>
|
|
75
|
+ </choose>
|
|
76
|
+ AND f.target_id = a.target_id
|
|
77
|
+ AND f.`status` > 0
|
|
78
|
+ AND f.is_first_time = 1
|
|
79
|
+ ) as new_persons,
|
|
80
|
+
|
|
81
|
+ -- 分享新增客户
|
|
82
|
+ (select count(*) from ta_share_person_from g
|
|
83
|
+ inner join ta_person h on h.person_id = g.person_id
|
|
84
|
+ where g.org_id = a.org_id
|
|
85
|
+ <choose>
|
|
86
|
+ <when test=" type == 'live'">
|
|
87
|
+ AND g.target_type = concat('%',REPLACE(a.target_type, 'activity', 'dynamic'), '_share%')
|
|
88
|
+ </when>
|
|
89
|
+ <otherwise>
|
|
90
|
+ AND g.target_type = concat(REPLACE(a.target_type, 'activity', 'dynamic'), '_share')
|
|
91
|
+ </otherwise>
|
|
92
|
+ </choose>
|
|
93
|
+ AND g.target_id = a.target_id
|
|
94
|
+ AND g.`status` > 0
|
|
95
|
+ AND g.is_first_time = 1
|
|
96
|
+ AND h.phone is not null
|
|
97
|
+ ) as new_customers
|
|
98
|
+
|
|
99
|
+ from (
|
|
100
|
+ <if test=" type == 'activity' ">
|
|
101
|
+ SELECT
|
|
102
|
+ t.org_id,
|
|
103
|
+ t.building_id,
|
|
104
|
+ s.building_name,
|
|
105
|
+ t.dynamic_id AS target_id,
|
|
106
|
+ t.title AS target_name,
|
|
107
|
+ 'activity' AS target_type
|
|
108
|
+ FROM
|
|
109
|
+ ta_building_dynamic t
|
|
110
|
+ LEFT JOIN ta_building s ON s.building_id = t.building_id
|
|
111
|
+ WHERE
|
|
112
|
+ t.`status` > - 1
|
|
113
|
+ AND t.dynamic_id = #{id}
|
|
114
|
+ </if>
|
|
115
|
+
|
|
116
|
+ <if test=" type == 'h5' " >
|
|
117
|
+ SELECT
|
|
118
|
+ t.org_id,
|
|
119
|
+ t.building_id,
|
|
120
|
+ s.building_name,
|
|
121
|
+ t.drainage_id AS target_id,
|
|
122
|
+ t.`name` AS target_name,
|
|
123
|
+ 'h5' AS target_type
|
|
124
|
+ FROM
|
|
125
|
+ ta_drainage t
|
|
126
|
+ LEFT JOIN ta_building s ON s.building_id = t.building_id
|
|
127
|
+ WHERE
|
|
128
|
+ t.`status` > - 1
|
|
129
|
+ AND t.drainage_id = #{id}
|
|
130
|
+ </if>
|
|
131
|
+
|
|
132
|
+ <if test=" type == 'help' ">
|
|
133
|
+ SELECT
|
|
134
|
+ t.org_id,
|
|
135
|
+ t.building_id,
|
|
136
|
+ s.building_name,
|
|
137
|
+ t.help_activity_id AS target_id,
|
|
138
|
+ t.title AS target_name,
|
|
139
|
+ 'help' AS target_type
|
|
140
|
+ FROM
|
|
141
|
+ ta_help_activity t
|
|
142
|
+ LEFT JOIN ta_building s ON s.building_id = t.building_id
|
|
143
|
+ WHERE
|
|
144
|
+ t.`status` > - 1
|
|
145
|
+ AND t.help_activity_id = #{id}
|
|
146
|
+ </if>
|
|
147
|
+
|
|
148
|
+ <if test=" type == 'group' ">
|
|
149
|
+ SELECT
|
|
150
|
+ t.org_id,
|
|
151
|
+ t.building_id,
|
|
152
|
+ s.building_name,
|
|
153
|
+ t.group_activity_id AS target_id,
|
|
154
|
+ t.activity_name AS target_name,
|
|
155
|
+ 'group' AS target_type
|
|
156
|
+ FROM
|
|
157
|
+ ta_share_activity t
|
|
158
|
+ LEFT JOIN ta_building s ON s.building_id = t.building_id
|
|
159
|
+ WHERE
|
|
160
|
+ t.`status` > - 1
|
|
161
|
+ AND t.group_activity_id = #{id}
|
|
162
|
+ </if>
|
|
163
|
+
|
|
164
|
+ <if test=" type == 'live' ">
|
|
165
|
+ SELECT
|
|
166
|
+ t.org_id,
|
|
167
|
+ t.building_id,
|
|
168
|
+ s.building_name,
|
|
169
|
+ t.live_activity_id AS target_id,
|
|
170
|
+ t.live_activity_title AS target_name,
|
|
171
|
+ 'live' AS target_type
|
|
172
|
+ FROM
|
|
173
|
+ ta_live_activity t
|
|
174
|
+ LEFT JOIN ta_building s ON s.building_id = t.building_id
|
|
175
|
+ WHERE
|
|
176
|
+ t.`status` > -1
|
|
177
|
+ AND t.live_activity_id = #{id}
|
|
178
|
+ AND t.org_id = #{orgId}
|
|
179
|
+ </if>
|
|
180
|
+ ) a
|
|
181
|
+ </select>
|
|
182
|
+
|
|
183
|
+</mapper>
|