|
@@ -1,446 +1,446 @@
|
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.TaPersonVisitRecordMapper">
|
4
|
|
-
|
5
|
|
- <sql id="columnSql">
|
6
|
|
- <trim suffixOverrides=",">
|
7
|
|
- t.record_id,
|
8
|
|
- t.person_id,
|
9
|
|
- c.person_type,
|
10
|
|
- t.visit_time,
|
11
|
|
- t.leave_time,
|
12
|
|
- t.visit_duration,
|
13
|
|
- t.event,
|
14
|
|
- t.data,
|
15
|
|
- t.activity,
|
16
|
|
- t.org_id,
|
17
|
|
- t.building_id,
|
18
|
|
- t.event_type,
|
19
|
|
- t.target_id,
|
20
|
|
- t.consultant_id,
|
21
|
|
- t.share_person_id,
|
22
|
|
- </trim>
|
23
|
|
- </sql>
|
24
|
|
-
|
25
|
|
- <select id="visitRecordByPersonId" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
26
|
|
- select
|
27
|
|
- t.* ,
|
28
|
|
- b.parent_type_id from ta_person_visit_record t
|
29
|
|
- left join td_biz_event_type b on t.event_type = b.type_id
|
30
|
|
- where t.person_id = #{personId}
|
31
|
|
- <if test="personBuildingList != null and personBuildingList.size > 0">
|
32
|
|
- AND (b.parent_type_id = 'public' or t.building_id in
|
33
|
|
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
|
34
|
|
- #{personBuilding.buildingId}
|
35
|
|
- </foreach>
|
36
|
|
- )
|
37
|
|
- </if>
|
38
|
|
- <if test="buildingId != null and buildingId != ''">
|
39
|
|
- AND (b.parent_type_id = 'public' or t.building_id = #{buildingId} )
|
40
|
|
- </if>
|
41
|
|
- order by t.visit_time desc
|
42
|
|
- </select>
|
43
|
|
-
|
44
|
|
- <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
45
|
|
- SELECT
|
46
|
|
- tpvr.record_id as recordId,
|
47
|
|
- tpvr.person_id as personId,
|
48
|
|
- tpvr.person_type as personType,
|
49
|
|
- tpvr.building_id as buildingId,
|
50
|
|
- tpvr.activity as activity,
|
51
|
|
- tpvr.event as event,
|
52
|
|
- tpvr.event_type as eventType,
|
53
|
|
- tpvr.visit_duration as visitDuration,
|
54
|
|
- (SELECT MIN(t.visit_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event and t.org_id = #{orgId} ) as visitTime,
|
55
|
|
- (SELECT MAX(t.leave_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event and t.org_id = #{orgId} ) as leaveTime,
|
56
|
|
- ifnull(tp.name, tp.nickname) as userName,
|
57
|
|
- tbe.event_name as eventName,
|
58
|
|
- COUNT(1) as accessCount
|
59
|
|
- FROM
|
60
|
|
- ta_person_visit_record tpvr
|
61
|
|
- LEFT JOIN ta_person tp ON tpvr.person_id = tp.person_id
|
62
|
|
- LEFT JOIN td_biz_event tbe on tpvr.event = tbe.event_code
|
63
|
|
- <trim prefix="where" prefixOverrides="and | or">
|
64
|
|
- tpvr.org_id = #{orgId}
|
65
|
|
- and tp.org_id = #{orgId}
|
66
|
|
- <if test="startDate != null and endDate != null">
|
67
|
|
- and tpvr.visit_time between #{startDate} and #{endDate}
|
68
|
|
- </if>
|
69
|
|
- <if test="buildingId != null and buildingId != ''">
|
70
|
|
- and tpvr.building_id = #{buildingId}
|
71
|
|
- </if>
|
72
|
|
- <if test="eventType != null and eventType != ''">
|
73
|
|
- and tpvr.event_type = #{eventType}
|
74
|
|
- </if>
|
75
|
|
- <if test="event != null and event != ''">
|
76
|
|
- and tpvr.event = #{event}
|
77
|
|
- </if>
|
78
|
|
- <if test="activity != null and activity != ''">
|
79
|
|
- and tpvr.activity = #{activity}
|
80
|
|
- </if>
|
81
|
|
- </trim>
|
82
|
|
-
|
83
|
|
- GROUP BY tpvr.person_id, tpvr.event
|
84
|
|
- ORDER BY accessCount DESC,tpvr.visit_time DESC
|
85
|
|
- </select>
|
86
|
|
- <select id="getPersonVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
87
|
|
- SELECT
|
88
|
|
- t.*,
|
89
|
|
- b.building_name
|
90
|
|
- FROM
|
91
|
|
- ta_person_visit_record t
|
92
|
|
- LEFT JOIN ta_building b ON t.building_id = b.building_id
|
93
|
|
- WHERE
|
94
|
|
- t.person_id = #{personId}
|
95
|
|
- ORDER BY
|
96
|
|
- t.visit_time DESC
|
97
|
|
- </select>
|
98
|
|
-
|
99
|
|
- <select id="getDurationByPersonId" resultType="java.lang.Integer">
|
100
|
|
- select SUM(visit_duration) from ta_person_visit_record where person_id = #{personId}
|
101
|
|
- </select>
|
102
|
|
-
|
103
|
|
- <select id="getFirstVisitTimeByPersonId" resultType="java.time.LocalDateTime">
|
104
|
|
- select visit_time from ta_person_visit_record where person_id = #{personId} order by visit_time asc limit 1
|
105
|
|
- </select>
|
106
|
|
- <select id="getWxVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
107
|
|
- SELECT
|
108
|
|
- t.* ,
|
109
|
|
- p.`name` as user_name,
|
110
|
|
- p.`nickname` as nickname,
|
111
|
|
- p.avatarurl,
|
112
|
|
- d.name as activity_name,
|
113
|
|
- d.create_date
|
114
|
|
- FROM
|
115
|
|
- ( SELECT * FROM ta_person_visit_record WHERE org_id = #{orgId} and event_type = #{eventType} AND consultant_id = #{userId} and person_id != #{personId} ORDER BY visit_time DESC LIMIT 999) t
|
116
|
|
- left JOIN ta_person p on t.person_id = p.person_id
|
117
|
|
- LEFT join ta_drainage d on t.target_id = d.drainage_id
|
118
|
|
- GROUP BY
|
119
|
|
- t.person_id
|
120
|
|
- ORDER BY
|
121
|
|
- t.visit_time DESC
|
122
|
|
- </select>
|
123
|
|
-
|
124
|
|
- <select id="getWxActivityVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
125
|
|
- SELECT
|
126
|
|
- t.share_from_id, t.share_person as consultant_id, t.share_person_type, t.person_id, t.target_type, t.target_id, t.create_date as visit_time, t.org_id ,t.building_id, t.status, t.is_first_time,
|
127
|
|
- p.`name` as user_name,
|
128
|
|
- p.`nickname` as nickname,
|
129
|
|
- p.avatarurl
|
130
|
|
- FROM
|
131
|
|
- ( SELECT * FROM ta_share_person_from WHERE org_id = #{orgId} and target_id = #{targetId} AND (share_person = #{userId} or share_person = #{personId}) and target_type = #{eventType} ORDER BY create_date DESC LIMIT 999) t
|
132
|
|
- left JOIN ta_person p on t.person_id = p.person_id
|
133
|
|
- where t.person_id != #{personId}
|
134
|
|
- GROUP BY
|
135
|
|
- t.person_id
|
136
|
|
- ORDER BY
|
137
|
|
- t.create_date DESC
|
138
|
|
- </select>
|
139
|
|
-
|
140
|
|
-
|
141
|
|
- <select id="getWxVisitRecordActivityList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
142
|
|
- SELECT
|
143
|
|
- t.*,
|
144
|
|
- d.NAME AS activity_name,
|
145
|
|
- d.create_date
|
146
|
|
- FROM
|
147
|
|
- ( SELECT * FROM ta_person_visit_record WHERE event_type = #{eventType} AND consultant_id = #{userId} AND person_id = #{personId} ORDER BY visit_time DESC ) t
|
148
|
|
- LEFT JOIN ta_drainage d ON t.target_id = d.drainage_id
|
149
|
|
- GROUP BY
|
150
|
|
- t.target_id
|
151
|
|
- ORDER BY
|
152
|
|
- t.visit_time DESC
|
153
|
|
- </select>
|
154
|
|
-
|
155
|
|
- <select id="getDrainageVisitRecord" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
156
|
|
- select * from (
|
157
|
|
- select
|
158
|
|
- t.share_person as share_person_id,
|
159
|
|
- t.person_id,
|
160
|
|
- c.person_type,
|
161
|
|
- t.create_date as visit_time,
|
162
|
|
- t.target_type as event_type,
|
163
|
|
- t.target_id as target_id,
|
164
|
|
- b.name as drainageName,
|
165
|
|
- d.building_name as buildingName,
|
166
|
|
- tn.news_name as newsName,
|
167
|
|
- tha.title as helpActivityName,
|
168
|
|
- tsa.activity_name as groupActivityName,
|
169
|
|
- tbd.title as activityName,
|
170
|
|
- b.drainage_id
|
171
|
|
- from ta_share_person_from t
|
172
|
|
- left join ta_drainage b on t.target_id = b.drainage_id
|
173
|
|
- left join ta_building d on t.target_id = d.building_id
|
174
|
|
- left join ta_news tn on t.target_id = tn.news_id
|
175
|
|
- left join ta_help_activity tha on t.target_id = tha.help_activity_id
|
176
|
|
- left join ta_share_activity tsa on t.target_id = tsa.group_activity_id
|
177
|
|
- left join ta_building_dynamic tbd on t.target_id = tbd.dynamic_id
|
178
|
|
- left join ta_person c on t.org_id = c.org_id and (t.share_person = c.person_id or t.share_person = c.user_id)
|
179
|
|
- where t.org_id = #{orgId}
|
180
|
|
- and t.target_type in ('h5_share','group_share','help_share','news_share','dynamic_share','building_share')
|
181
|
|
- <if test="eventType !=null and eventType != ''">
|
182
|
|
- and t.target_type = #{eventType}
|
183
|
|
- </if>
|
184
|
|
- <if test="activityName !=null and activityName != ''">
|
185
|
|
- and (
|
186
|
|
- (b.name like concat('%',#{activityName},'%') and t.target_type = 'h5_share')or (d.name like concat('%',#{activityName},'%') and t.target_type = 'building_share') or (tn.news_name like concat('%',#{activityName},'%') and t.target_type = 'news_share')
|
187
|
|
- or (tha.title like concat( '%', #{activityName}, '%' ) and t.target_type = 'help_share') or (tsa.activity_name like concat('%',#{activityName},'%') and t.target_type = 'group_share') or (tbd.title like concat('%',#{activityName},'%') and t.target_type = 'dynamic_share')
|
188
|
|
- )
|
189
|
|
- </if>
|
190
|
|
- <if test="shareName !=null and shareName != ''">
|
191
|
|
- and c.nickname like concat('%',#{shareName},'%')
|
192
|
|
- </if>
|
193
|
|
- <if test="shareTel !=null and shareTel != ''">
|
194
|
|
- and c.phone = #{shareTel}
|
195
|
|
- </if>
|
196
|
|
- <if test="personType == 'Realty Consultant'">
|
197
|
|
- and c.person_type = 'Realty Consultant'
|
198
|
|
- </if>
|
199
|
|
- <if test="personType == 'customer'">
|
200
|
|
- and c.person_type != 'Realty Consultant'
|
201
|
|
- </if>
|
202
|
|
- <if test="buildingId !=null and buildingId != ''">
|
203
|
|
- and d.building_id = #{buildingId}
|
204
|
|
- </if>
|
205
|
|
- <if test="personBuildingList != null and personBuildingList.size > 0">
|
206
|
|
- AND d.building_id in
|
207
|
|
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
|
208
|
|
- #{personBuilding.buildingId}
|
209
|
|
- </foreach>
|
210
|
|
- </if>
|
211
|
|
- order by t.create_date desc
|
212
|
|
- ) t
|
213
|
|
- group by t.person_id, t.target_id,t.event_type, t.share_person_id
|
214
|
|
- order by t.visit_time desc
|
215
|
|
- </select>
|
216
|
|
-
|
217
|
|
- <select id="getConsultantShareInfoList" resultType="com.huiju.estateagents.entity.TaConsultantInfo">
|
218
|
|
- select * From (
|
219
|
|
- select * from (
|
220
|
|
- select
|
221
|
|
- t.be_share as target_id,
|
222
|
|
- a.url as activity_img,
|
223
|
|
- a.building_name as activity_name,
|
224
|
|
- a.building_name,
|
225
|
|
- a.address,
|
226
|
|
- a.price,
|
227
|
|
- a.building_type_id,
|
228
|
|
- t.tagert_type as eventType,
|
229
|
|
- t.create_date as visit_time
|
230
|
|
- from ta_share t
|
231
|
|
- left join (select b.url, a.building_name,a.address,a.price,a.building_id,a.building_type_id from ta_building a left join ta_building_img b on a.building_id = b.building_id where b.img_type = 'list') a on t.be_share = a.building_id
|
232
|
|
- where t.tagert_type = 'project'
|
233
|
|
- and t.person_id = #{personId} order by t.create_date desc limit 9999
|
234
|
|
- ) t
|
235
|
|
- group by t.target_id
|
236
|
|
-
|
237
|
|
- union all
|
238
|
|
-
|
239
|
|
- select * from (
|
240
|
|
- select
|
241
|
|
- t.be_share as target_id,
|
242
|
|
- b.list_img_url as activity_img,
|
243
|
|
- b.title as activity_name,
|
244
|
|
- '1' as price,
|
245
|
|
- '2' as building_name,
|
246
|
|
- '3' as address,
|
247
|
|
- 1 as building_type_id,
|
248
|
|
- t.tagert_type as eventType,
|
249
|
|
- t.create_date as visit_time
|
250
|
|
- from ta_share t
|
251
|
|
- left join ta_building_dynamic b on t.be_share = b.dynamic_id
|
252
|
|
- where t.tagert_type = 'activity'
|
253
|
|
- and t.person_id = #{personId} order by t.create_date desc limit 9999
|
254
|
|
- ) t
|
255
|
|
- group by t.target_id
|
256
|
|
-
|
257
|
|
- union all
|
258
|
|
-
|
259
|
|
- select * from (
|
260
|
|
- select
|
261
|
|
- t.be_share as target_id,
|
262
|
|
- c.list_img as activity_img,
|
263
|
|
- c.title as activity_name,
|
264
|
|
- '1' as price,
|
265
|
|
- '2' as building_name,
|
266
|
|
- '3' as address,
|
267
|
|
- 1 as building_type_id,
|
268
|
|
- t.tagert_type as eventType,
|
269
|
|
- t.create_date as visit_time
|
270
|
|
- from ta_share t
|
271
|
|
- left join ta_help_activity c on t.be_share = c.help_activity_id
|
272
|
|
- where t.tagert_type = 'help'
|
273
|
|
- and t.person_id = #{personId} order by t.create_date desc limit 9999
|
274
|
|
- ) t
|
275
|
|
- group by t.target_id
|
276
|
|
-
|
277
|
|
- union all
|
278
|
|
-
|
279
|
|
- select * from (
|
280
|
|
- select
|
281
|
|
- t.be_share as target_id,
|
282
|
|
- d.list_img as activity_img,
|
283
|
|
- d.activity_name as activity_name,
|
284
|
|
- '1' as price,
|
285
|
|
- '2' as building_name,
|
286
|
|
- '3' as address,
|
287
|
|
- 1 as building_type_id,
|
288
|
|
- t.tagert_type as eventType,
|
289
|
|
- t.create_date as visit_time
|
290
|
|
- from ta_share t
|
291
|
|
- left join ta_share_activity d on t.be_share = d.group_activity_id
|
292
|
|
- where t.tagert_type = 'group'
|
293
|
|
- and t.person_id = #{personId} order by t.create_date desc limit 9999
|
294
|
|
- ) t
|
295
|
|
- group by t.target_id
|
296
|
|
-
|
297
|
|
- union all
|
298
|
|
-
|
299
|
|
- select * from (
|
300
|
|
- select
|
301
|
|
- t.be_share as target_id,
|
302
|
|
- e.news_img as activity_img,
|
303
|
|
- e.news_name as activity_name,
|
304
|
|
- '1' as price,
|
305
|
|
- '2' as building_name,
|
306
|
|
- '3' as address,
|
307
|
|
- 1 as building_type_id,
|
308
|
|
- t.tagert_type as eventType,
|
309
|
|
- t.create_date as visit_time
|
310
|
|
- from ta_share t
|
311
|
|
- left join ta_news e on t.be_share = e.news_id
|
312
|
|
- where t.tagert_type = 'news'
|
313
|
|
- and t.person_id = #{personId} order by t.create_date desc limit 9999
|
314
|
|
- ) t
|
315
|
|
- group by t.target_id
|
316
|
|
-
|
317
|
|
- union all
|
318
|
|
-
|
319
|
|
- select * from (
|
320
|
|
- select
|
321
|
|
- t.be_share as target_id,
|
322
|
|
- f.share_img as activity_img,
|
323
|
|
- f.`name` as activity_name,
|
324
|
|
- '1' as price,
|
325
|
|
- '2' as building_name,
|
326
|
|
- '3' as address,
|
327
|
|
- 1 as building_type_id,
|
328
|
|
- t.tagert_type as eventType,
|
329
|
|
- t.create_date as visit_time
|
330
|
|
- from ta_share t
|
331
|
|
- left join ta_drainage f on t.be_share = f.drainage_id
|
332
|
|
- where t.tagert_type = 'h5'
|
333
|
|
- and t.person_id = #{personId} order by t.create_date desc limit 9999
|
334
|
|
- ) t
|
335
|
|
- group by t.target_id
|
336
|
|
- union all
|
337
|
|
-
|
338
|
|
- select * from (
|
339
|
|
- select
|
340
|
|
- t.be_share as target_id,
|
341
|
|
- g.aerial_view_img as activity_img,
|
342
|
|
- g.sales_batch_name as activity_name,
|
343
|
|
- '1' as price,
|
344
|
|
- '2' as building_name,
|
345
|
|
- '3' as address,
|
346
|
|
- 1 as building_type_id,
|
347
|
|
- left(t.tagert_type,5) as eventType,
|
348
|
|
- t.create_date as visit_time
|
349
|
|
- from ta_share t
|
350
|
|
- left join ta_sales_batch g on t.be_share = g.sales_batch_id
|
351
|
|
- where t.tagert_type like CONCAT('house' , '%')
|
352
|
|
- and t.person_id = #{personId} order by t.create_date desc limit 9999
|
353
|
|
- ) t
|
354
|
|
- group by t.target_id
|
355
|
|
-
|
356
|
|
- union all
|
357
|
|
- select * from (
|
358
|
|
- SELECT
|
359
|
|
- t.be_share AS target_id,
|
360
|
|
- g.list_img AS activity_img,
|
361
|
|
- g.live_activity_title AS activity_name,
|
362
|
|
- '1' AS price,
|
363
|
|
- '2' AS building_name,
|
364
|
|
- '3' AS address,
|
365
|
|
- 1 AS building_type_id,
|
366
|
|
- LEFT ( t.tagert_type, 4 ) AS eventType,
|
367
|
|
- t.create_date AS visit_time
|
368
|
|
- FROM
|
369
|
|
- ta_share t
|
370
|
|
- LEFT JOIN ta_live_activity g ON t.be_share = g.live_activity_id
|
371
|
|
- WHERE
|
372
|
|
- t.tagert_type LIKE CONCAT( 'live', '%' )
|
373
|
|
- AND t.person_id = #{personId}
|
374
|
|
- ORDER BY
|
375
|
|
- t.create_date DESC
|
376
|
|
- LIMIT 9999
|
377
|
|
- ) t
|
378
|
|
- group by t.target_id
|
379
|
|
- ) t
|
380
|
|
- order by t.visit_time desc
|
381
|
|
- </select>
|
382
|
|
-
|
383
|
|
- <select id="countShareNumByEventType" resultType="java.lang.Integer">
|
384
|
|
- select count(DISTINCT t.person_id) from ta_share_person_from t
|
385
|
|
- left join ta_person a on t.person_id = a.person_id
|
386
|
|
- where
|
387
|
|
- (t.share_person = #{personId}
|
388
|
|
- <if test="userId != null and userId != ''">
|
389
|
|
- or t.share_person = #{userId}
|
390
|
|
- </if>
|
391
|
|
- )
|
392
|
|
- and t.org_id = #{orgId}
|
393
|
|
- and t.target_type = #{eventType}
|
394
|
|
- and t.target_id = #{targetId}
|
395
|
|
- and t.status = 1
|
396
|
|
- and t.person_id != #{personId}
|
397
|
|
- group by t.target_type
|
398
|
|
- </select>
|
399
|
|
-
|
400
|
|
- <select id="selectData" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
401
|
|
- select t.share_person_id, t.target_id,
|
402
|
|
- if(t.target_type = 'help' and t.event_type = 'activity', 'help', if(t.target_type = 'group' and t.event_type = 'activity' , 'group', t.event_type)) as target_type,
|
403
|
|
- a.nickname, a.avatarurl FROM
|
404
|
|
- ta_person_visit_record t
|
405
|
|
- LEFT JOIN ta_person a ON t.share_person_id = a.person_id
|
406
|
|
- LEFT JOIN ta_share_person_from b ON t.target_id = b.target_id and t.event_type = b.target_type + '_share'
|
407
|
|
- WHERE
|
408
|
|
- (
|
409
|
|
- ( t.consultant_id IS NOT NULL AND t.consultant_id != '' )
|
410
|
|
- OR ( t.share_person_id IS NOT NULL AND t.share_person_id != '' )
|
411
|
|
- )
|
412
|
|
- AND t.person_id != t.share_person_id
|
413
|
|
- AND t.`event` = 'detail'
|
414
|
|
- AND ( t.share_person_id != b.share_person OR t.consultant_id != b.share_person )
|
415
|
|
- GROUP BY
|
416
|
|
- t.target_id, t.event_type;
|
417
|
|
- </select>
|
418
|
|
-
|
419
|
|
- <select id="selectTapersonFromShare" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
420
|
|
- select t.share_person_id, if (t.consultant_id != '' and t.consultant_id is not null, 'Realty Consultant', 'customer') as person_type, t.person_id, b.target_type, t.target_id,t.org_id, t.building_id From ta_person_visit_record t
|
421
|
|
- left join ta_person a on t.share_person_id = a.person_id
|
422
|
|
- LEFT JOIN ta_share_person_from b ON t.target_id = b.target_id and t.event_type = b.target_type + '_share'
|
423
|
|
- where
|
424
|
|
- (
|
425
|
|
- ( t.consultant_id IS NOT NULL AND t.consultant_id != '' )
|
426
|
|
- OR ( t.share_person_id IS NOT NULL AND t.share_person_id != '' )
|
427
|
|
- )
|
428
|
|
- AND t.person_id != t.share_person_id
|
429
|
|
- AND t.`event` = 'detail'
|
430
|
|
- AND ( t.share_person_id != b.share_person OR t.consultant_id != b.share_person )
|
431
|
|
- GROUP BY
|
432
|
|
- t.target_id, t.event_type;
|
433
|
|
- </select>
|
434
|
|
-
|
435
|
|
- <select id="selectTodayVisitCount" resultType="java.lang.Integer">
|
436
|
|
- SELECT
|
437
|
|
- COUNT(1) as visit_count
|
438
|
|
- FROM
|
439
|
|
- ta_person_visit_record tp
|
440
|
|
- where tp.org_id = #{orgId} AND
|
441
|
|
- tp.event = 'start'
|
442
|
|
- AND DATE_FORMAT(tp.visit_time,'%Y-%m-%d') = DATE_FORMAT(#{nowDate},'%Y-%m-%d')
|
443
|
|
- </select>
|
444
|
|
-
|
445
|
|
-
|
446
|
|
-</mapper>
|
|
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.TaPersonVisitRecordMapper">
|
|
4
|
+
|
|
5
|
+ <sql id="columnSql">
|
|
6
|
+ <trim suffixOverrides=",">
|
|
7
|
+ t.record_id,
|
|
8
|
+ t.person_id,
|
|
9
|
+ c.person_type,
|
|
10
|
+ t.visit_time,
|
|
11
|
+ t.leave_time,
|
|
12
|
+ t.visit_duration,
|
|
13
|
+ t.event,
|
|
14
|
+ t.data,
|
|
15
|
+ t.activity,
|
|
16
|
+ t.org_id,
|
|
17
|
+ t.building_id,
|
|
18
|
+ t.event_type,
|
|
19
|
+ t.target_id,
|
|
20
|
+ t.consultant_id,
|
|
21
|
+ t.share_person_id,
|
|
22
|
+ </trim>
|
|
23
|
+ </sql>
|
|
24
|
+
|
|
25
|
+ <select id="visitRecordByPersonId" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
26
|
+ select
|
|
27
|
+ t.* ,
|
|
28
|
+ b.parent_type_id from ta_person_visit_record t
|
|
29
|
+ left join td_biz_event_type b on t.event_type = b.type_id
|
|
30
|
+ where t.person_id = #{personId}
|
|
31
|
+ <if test="personBuildingList != null and personBuildingList.size > 0">
|
|
32
|
+ AND (b.parent_type_id = 'public' or t.building_id in
|
|
33
|
+ <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
|
|
34
|
+ #{personBuilding.buildingId}
|
|
35
|
+ </foreach>
|
|
36
|
+ )
|
|
37
|
+ </if>
|
|
38
|
+ <if test="buildingId != null and buildingId != ''">
|
|
39
|
+ AND (b.parent_type_id = 'public' or t.building_id = #{buildingId} )
|
|
40
|
+ </if>
|
|
41
|
+ order by t.visit_time desc
|
|
42
|
+ </select>
|
|
43
|
+
|
|
44
|
+ <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
45
|
+ SELECT
|
|
46
|
+ tpvr.record_id as recordId,
|
|
47
|
+ tpvr.person_id as personId,
|
|
48
|
+ tpvr.person_type as personType,
|
|
49
|
+ tpvr.building_id as buildingId,
|
|
50
|
+ tpvr.activity as activity,
|
|
51
|
+ tpvr.event as event,
|
|
52
|
+ tpvr.event_type as eventType,
|
|
53
|
+ tpvr.visit_duration as visitDuration,
|
|
54
|
+ (SELECT MIN(t.visit_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event and t.org_id = #{orgId} ) as visitTime,
|
|
55
|
+ (SELECT MAX(t.leave_time) FROM ta_person_visit_record t WHERE t.person_id = tpvr.person_id and t.event = tpvr.event and t.org_id = #{orgId} ) as leaveTime,
|
|
56
|
+ ifnull(tp.name, tp.nickname) as userName,
|
|
57
|
+ tbe.event_name as eventName,
|
|
58
|
+ COUNT(1) as accessCount
|
|
59
|
+ FROM
|
|
60
|
+ ta_person_visit_record tpvr
|
|
61
|
+ LEFT JOIN ta_person tp ON tpvr.person_id = tp.person_id
|
|
62
|
+ LEFT JOIN td_biz_event tbe on tpvr.event = tbe.event_code
|
|
63
|
+ <trim prefix="where" prefixOverrides="and | or">
|
|
64
|
+ tpvr.org_id = #{orgId}
|
|
65
|
+ and tp.org_id = #{orgId}
|
|
66
|
+ <if test="startDate != null and endDate != null">
|
|
67
|
+ and tpvr.visit_time between #{startDate} and #{endDate}
|
|
68
|
+ </if>
|
|
69
|
+ <if test="buildingId != null and buildingId != ''">
|
|
70
|
+ and tpvr.building_id = #{buildingId}
|
|
71
|
+ </if>
|
|
72
|
+ <if test="eventType != null and eventType != ''">
|
|
73
|
+ and tpvr.event_type = #{eventType}
|
|
74
|
+ </if>
|
|
75
|
+ <if test="event != null and event != ''">
|
|
76
|
+ and tpvr.event = #{event}
|
|
77
|
+ </if>
|
|
78
|
+ <if test="activity != null and activity != ''">
|
|
79
|
+ and tpvr.activity = #{activity}
|
|
80
|
+ </if>
|
|
81
|
+ </trim>
|
|
82
|
+
|
|
83
|
+ GROUP BY tpvr.person_id, tpvr.event
|
|
84
|
+ ORDER BY accessCount DESC,tpvr.visit_time DESC
|
|
85
|
+ </select>
|
|
86
|
+ <select id="getPersonVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
87
|
+ SELECT
|
|
88
|
+ t.*,
|
|
89
|
+ b.building_name
|
|
90
|
+ FROM
|
|
91
|
+ ta_person_visit_record t
|
|
92
|
+ LEFT JOIN ta_building b ON t.building_id = b.building_id
|
|
93
|
+ WHERE
|
|
94
|
+ t.person_id = #{personId}
|
|
95
|
+ ORDER BY
|
|
96
|
+ t.visit_time DESC
|
|
97
|
+ </select>
|
|
98
|
+
|
|
99
|
+ <select id="getDurationByPersonId" resultType="java.lang.Integer">
|
|
100
|
+ select SUM(visit_duration) from ta_person_visit_record where person_id = #{personId}
|
|
101
|
+ </select>
|
|
102
|
+
|
|
103
|
+ <select id="getFirstVisitTimeByPersonId" resultType="java.time.LocalDateTime">
|
|
104
|
+ select visit_time from ta_person_visit_record where person_id = #{personId} order by visit_time asc limit 1
|
|
105
|
+ </select>
|
|
106
|
+ <select id="getWxVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
107
|
+ SELECT
|
|
108
|
+ t.* ,
|
|
109
|
+ p.`name` as user_name,
|
|
110
|
+ p.`nickname` as nickname,
|
|
111
|
+ p.avatarurl,
|
|
112
|
+ d.name as activity_name,
|
|
113
|
+ d.create_date
|
|
114
|
+ FROM
|
|
115
|
+ ( SELECT * FROM ta_person_visit_record WHERE org_id = #{orgId} and event_type = #{eventType} AND consultant_id = #{userId} and person_id != #{personId} ORDER BY visit_time DESC LIMIT 999) t
|
|
116
|
+ left JOIN ta_person p on t.person_id = p.person_id
|
|
117
|
+ LEFT join ta_drainage d on t.target_id = d.drainage_id
|
|
118
|
+ GROUP BY
|
|
119
|
+ t.person_id
|
|
120
|
+ ORDER BY
|
|
121
|
+ t.visit_time DESC
|
|
122
|
+ </select>
|
|
123
|
+
|
|
124
|
+ <select id="getWxActivityVisitRecordList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
125
|
+ SELECT
|
|
126
|
+ t.share_from_id, t.share_person as consultant_id, t.share_person_type, t.person_id, t.target_type, t.target_id, t.create_date as visit_time, t.org_id ,t.building_id, t.status, t.is_first_time,
|
|
127
|
+ p.`name` as user_name,
|
|
128
|
+ p.`nickname` as nickname,
|
|
129
|
+ p.avatarurl
|
|
130
|
+ FROM
|
|
131
|
+ ( SELECT * FROM ta_share_person_from WHERE org_id = #{orgId} and target_id = #{targetId} AND (share_person = #{userId} or share_person = #{personId}) and target_type = #{eventType} ORDER BY create_date DESC LIMIT 999) t
|
|
132
|
+ left JOIN ta_person p on t.person_id = p.person_id
|
|
133
|
+ where t.person_id != #{personId}
|
|
134
|
+ GROUP BY
|
|
135
|
+ t.person_id
|
|
136
|
+ ORDER BY
|
|
137
|
+ t.create_date DESC
|
|
138
|
+ </select>
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+ <select id="getWxVisitRecordActivityList" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
142
|
+ SELECT
|
|
143
|
+ t.*,
|
|
144
|
+ d.NAME AS activity_name,
|
|
145
|
+ d.create_date
|
|
146
|
+ FROM
|
|
147
|
+ ( SELECT * FROM ta_person_visit_record WHERE event_type = #{eventType} AND consultant_id = #{userId} AND person_id = #{personId} ORDER BY visit_time DESC ) t
|
|
148
|
+ LEFT JOIN ta_drainage d ON t.target_id = d.drainage_id
|
|
149
|
+ GROUP BY
|
|
150
|
+ t.target_id
|
|
151
|
+ ORDER BY
|
|
152
|
+ t.visit_time DESC
|
|
153
|
+ </select>
|
|
154
|
+
|
|
155
|
+ <select id="getDrainageVisitRecord" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
156
|
+ select * from (
|
|
157
|
+ select
|
|
158
|
+ t.share_person as share_person_id,
|
|
159
|
+ t.person_id,
|
|
160
|
+ c.person_type,
|
|
161
|
+ t.create_date as visit_time,
|
|
162
|
+ t.target_type as event_type,
|
|
163
|
+ t.target_id as target_id,
|
|
164
|
+ b.name as drainageName,
|
|
165
|
+ d.building_name as buildingName,
|
|
166
|
+ tn.news_name as newsName,
|
|
167
|
+ tha.title as helpActivityName,
|
|
168
|
+ tsa.activity_name as groupActivityName,
|
|
169
|
+ tbd.title as activityName,
|
|
170
|
+ b.drainage_id
|
|
171
|
+ from ta_share_person_from t
|
|
172
|
+ left join ta_drainage b on t.target_id = b.drainage_id
|
|
173
|
+ left join ta_building d on t.target_id = d.building_id
|
|
174
|
+ left join ta_news tn on t.target_id = tn.news_id
|
|
175
|
+ left join ta_help_activity tha on t.target_id = tha.help_activity_id
|
|
176
|
+ left join ta_share_activity tsa on t.target_id = tsa.group_activity_id
|
|
177
|
+ left join ta_building_dynamic tbd on t.target_id = tbd.dynamic_id
|
|
178
|
+ left join ta_person c on t.org_id = c.org_id and (t.share_person = c.person_id or t.share_person = c.user_id)
|
|
179
|
+ where t.org_id = #{orgId}
|
|
180
|
+ and t.target_type in ('h5_share','group_share','help_share','news_share','dynamic_share','building_share')
|
|
181
|
+ <if test="eventType !=null and eventType != ''">
|
|
182
|
+ and t.target_type = #{eventType}
|
|
183
|
+ </if>
|
|
184
|
+ <if test="activityName !=null and activityName != ''">
|
|
185
|
+ and (
|
|
186
|
+ (b.name like concat('%',#{activityName},'%') and t.target_type = 'h5_share')or (d.name like concat('%',#{activityName},'%') and t.target_type = 'building_share') or (tn.news_name like concat('%',#{activityName},'%') and t.target_type = 'news_share')
|
|
187
|
+ or (tha.title like concat( '%', #{activityName}, '%' ) and t.target_type = 'help_share') or (tsa.activity_name like concat('%',#{activityName},'%') and t.target_type = 'group_share') or (tbd.title like concat('%',#{activityName},'%') and t.target_type = 'dynamic_share')
|
|
188
|
+ )
|
|
189
|
+ </if>
|
|
190
|
+ <if test="shareName !=null and shareName != ''">
|
|
191
|
+ and c.nickname like concat('%',#{shareName},'%')
|
|
192
|
+ </if>
|
|
193
|
+ <if test="shareTel !=null and shareTel != ''">
|
|
194
|
+ and c.phone = #{shareTel}
|
|
195
|
+ </if>
|
|
196
|
+ <if test="personType == 'Realty Consultant'">
|
|
197
|
+ and c.person_type = 'Realty Consultant'
|
|
198
|
+ </if>
|
|
199
|
+ <if test="personType == 'customer'">
|
|
200
|
+ and c.person_type != 'Realty Consultant'
|
|
201
|
+ </if>
|
|
202
|
+ <if test="buildingId !=null and buildingId != ''">
|
|
203
|
+ and d.building_id = #{buildingId}
|
|
204
|
+ </if>
|
|
205
|
+ <if test="personBuildingList != null and personBuildingList.size > 0">
|
|
206
|
+ AND d.building_id in
|
|
207
|
+ <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
|
|
208
|
+ #{personBuilding.buildingId}
|
|
209
|
+ </foreach>
|
|
210
|
+ </if>
|
|
211
|
+ order by t.create_date desc
|
|
212
|
+ ) t
|
|
213
|
+ group by t.person_id, t.target_id,t.event_type, t.share_person_id
|
|
214
|
+ order by t.visit_time desc
|
|
215
|
+ </select>
|
|
216
|
+
|
|
217
|
+ <select id="getConsultantShareInfoList" resultType="com.huiju.estateagents.entity.TaConsultantInfo">
|
|
218
|
+ select * From (
|
|
219
|
+ select * from (
|
|
220
|
+ select
|
|
221
|
+ t.be_share as target_id,
|
|
222
|
+ a.url as activity_img,
|
|
223
|
+ a.building_name as activity_name,
|
|
224
|
+ a.building_name,
|
|
225
|
+ a.address,
|
|
226
|
+ a.price,
|
|
227
|
+ a.building_type_id,
|
|
228
|
+ t.tagert_type as eventType,
|
|
229
|
+ t.create_date as visit_time
|
|
230
|
+ from ta_share t
|
|
231
|
+ left join (select b.url, a.building_name,a.address,a.price,a.building_id,a.building_type_id from ta_building a left join ta_building_img b on a.building_id = b.building_id where b.img_type = 'list') a on t.be_share = a.building_id
|
|
232
|
+ where t.tagert_type = 'project'
|
|
233
|
+ and t.person_id = #{personId} order by t.create_date desc limit 9999
|
|
234
|
+ ) t
|
|
235
|
+ group by t.target_id
|
|
236
|
+
|
|
237
|
+ union all
|
|
238
|
+
|
|
239
|
+ select * from (
|
|
240
|
+ select
|
|
241
|
+ t.be_share as target_id,
|
|
242
|
+ b.list_img_url as activity_img,
|
|
243
|
+ b.title as activity_name,
|
|
244
|
+ '1' as price,
|
|
245
|
+ '2' as building_name,
|
|
246
|
+ '3' as address,
|
|
247
|
+ 1 as building_type_id,
|
|
248
|
+ t.tagert_type as eventType,
|
|
249
|
+ t.create_date as visit_time
|
|
250
|
+ from ta_share t
|
|
251
|
+ left join ta_building_dynamic b on t.be_share = b.dynamic_id
|
|
252
|
+ where t.tagert_type = 'activity'
|
|
253
|
+ and t.person_id = #{personId} order by t.create_date desc limit 9999
|
|
254
|
+ ) t
|
|
255
|
+ group by t.target_id
|
|
256
|
+
|
|
257
|
+ union all
|
|
258
|
+
|
|
259
|
+ select * from (
|
|
260
|
+ select
|
|
261
|
+ t.be_share as target_id,
|
|
262
|
+ c.list_img as activity_img,
|
|
263
|
+ c.title as activity_name,
|
|
264
|
+ '1' as price,
|
|
265
|
+ '2' as building_name,
|
|
266
|
+ '3' as address,
|
|
267
|
+ 1 as building_type_id,
|
|
268
|
+ t.tagert_type as eventType,
|
|
269
|
+ t.create_date as visit_time
|
|
270
|
+ from ta_share t
|
|
271
|
+ left join ta_help_activity c on t.be_share = c.help_activity_id
|
|
272
|
+ where t.tagert_type = 'help'
|
|
273
|
+ and t.person_id = #{personId} order by t.create_date desc limit 9999
|
|
274
|
+ ) t
|
|
275
|
+ group by t.target_id
|
|
276
|
+
|
|
277
|
+ union all
|
|
278
|
+
|
|
279
|
+ select * from (
|
|
280
|
+ select
|
|
281
|
+ t.be_share as target_id,
|
|
282
|
+ d.list_img as activity_img,
|
|
283
|
+ d.activity_name as activity_name,
|
|
284
|
+ '1' as price,
|
|
285
|
+ '2' as building_name,
|
|
286
|
+ '3' as address,
|
|
287
|
+ 1 as building_type_id,
|
|
288
|
+ t.tagert_type as eventType,
|
|
289
|
+ t.create_date as visit_time
|
|
290
|
+ from ta_share t
|
|
291
|
+ left join ta_share_activity d on t.be_share = d.group_activity_id
|
|
292
|
+ where t.tagert_type = 'group'
|
|
293
|
+ and t.person_id = #{personId} order by t.create_date desc limit 9999
|
|
294
|
+ ) t
|
|
295
|
+ group by t.target_id
|
|
296
|
+
|
|
297
|
+ union all
|
|
298
|
+
|
|
299
|
+ select * from (
|
|
300
|
+ select
|
|
301
|
+ t.be_share as target_id,
|
|
302
|
+ e.news_img as activity_img,
|
|
303
|
+ e.news_name as activity_name,
|
|
304
|
+ '1' as price,
|
|
305
|
+ '2' as building_name,
|
|
306
|
+ '3' as address,
|
|
307
|
+ 1 as building_type_id,
|
|
308
|
+ t.tagert_type as eventType,
|
|
309
|
+ t.create_date as visit_time
|
|
310
|
+ from ta_share t
|
|
311
|
+ left join ta_news e on t.be_share = e.news_id
|
|
312
|
+ where t.tagert_type = 'news'
|
|
313
|
+ and t.person_id = #{personId} order by t.create_date desc limit 9999
|
|
314
|
+ ) t
|
|
315
|
+ group by t.target_id
|
|
316
|
+
|
|
317
|
+ union all
|
|
318
|
+
|
|
319
|
+ select * from (
|
|
320
|
+ select
|
|
321
|
+ t.be_share as target_id,
|
|
322
|
+ f.share_img as activity_img,
|
|
323
|
+ f.`name` as activity_name,
|
|
324
|
+ '1' as price,
|
|
325
|
+ '2' as building_name,
|
|
326
|
+ '3' as address,
|
|
327
|
+ 1 as building_type_id,
|
|
328
|
+ t.tagert_type as eventType,
|
|
329
|
+ t.create_date as visit_time
|
|
330
|
+ from ta_share t
|
|
331
|
+ left join ta_drainage f on t.be_share = f.drainage_id
|
|
332
|
+ where t.tagert_type = 'h5'
|
|
333
|
+ and t.person_id = #{personId} order by t.create_date desc limit 9999
|
|
334
|
+ ) t
|
|
335
|
+ group by t.target_id
|
|
336
|
+ union all
|
|
337
|
+
|
|
338
|
+ select * from (
|
|
339
|
+ select
|
|
340
|
+ t.be_share as target_id,
|
|
341
|
+ g.aerial_view_img as activity_img,
|
|
342
|
+ g.sales_batch_name as activity_name,
|
|
343
|
+ '1' as price,
|
|
344
|
+ '2' as building_name,
|
|
345
|
+ '3' as address,
|
|
346
|
+ 1 as building_type_id,
|
|
347
|
+ left(t.tagert_type,5) as eventType,
|
|
348
|
+ t.create_date as visit_time
|
|
349
|
+ from ta_share t
|
|
350
|
+ left join ta_sales_batch g on t.be_share = g.sales_batch_id
|
|
351
|
+ where t.tagert_type like CONCAT('house' , '%')
|
|
352
|
+ and t.person_id = #{personId} order by t.create_date desc limit 9999
|
|
353
|
+ ) t
|
|
354
|
+ group by t.target_id
|
|
355
|
+
|
|
356
|
+ union all
|
|
357
|
+ select * from (
|
|
358
|
+ SELECT
|
|
359
|
+ t.be_share AS target_id,
|
|
360
|
+ g.list_img AS activity_img,
|
|
361
|
+ g.live_activity_title AS activity_name,
|
|
362
|
+ '1' AS price,
|
|
363
|
+ '2' AS building_name,
|
|
364
|
+ '3' AS address,
|
|
365
|
+ 1 AS building_type_id,
|
|
366
|
+ LEFT ( t.tagert_type, 4 ) AS eventType,
|
|
367
|
+ t.create_date AS visit_time
|
|
368
|
+ FROM
|
|
369
|
+ ta_share t
|
|
370
|
+ LEFT JOIN ta_live_activity g ON t.be_share = g.live_activity_id
|
|
371
|
+ WHERE
|
|
372
|
+ t.tagert_type LIKE CONCAT( 'live', '%' )
|
|
373
|
+ AND t.person_id = #{personId}
|
|
374
|
+ ORDER BY
|
|
375
|
+ t.create_date DESC
|
|
376
|
+ LIMIT 9999
|
|
377
|
+ ) t
|
|
378
|
+ group by t.target_id
|
|
379
|
+ ) t
|
|
380
|
+ order by t.visit_time desc
|
|
381
|
+ </select>
|
|
382
|
+
|
|
383
|
+ <select id="countShareNumByEventType" resultType="java.lang.Integer">
|
|
384
|
+ select count(DISTINCT t.person_id) from ta_share_person_from t
|
|
385
|
+ left join ta_person a on t.person_id = a.person_id
|
|
386
|
+ where
|
|
387
|
+ (t.share_person = #{personId}
|
|
388
|
+ <if test="userId != null and userId != ''">
|
|
389
|
+ or t.share_person = #{userId}
|
|
390
|
+ </if>
|
|
391
|
+ )
|
|
392
|
+ and t.org_id = #{orgId}
|
|
393
|
+ and t.target_type = #{eventType}
|
|
394
|
+ and t.target_id = #{targetId}
|
|
395
|
+ and t.status = 1
|
|
396
|
+ and t.person_id != #{personId}
|
|
397
|
+ group by t.target_type
|
|
398
|
+ </select>
|
|
399
|
+
|
|
400
|
+ <select id="selectData" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
401
|
+ select t.share_person_id, t.target_id,
|
|
402
|
+ if(t.target_type = 'help' and t.event_type = 'activity', 'help', if(t.target_type = 'group' and t.event_type = 'activity' , 'group', t.event_type)) as target_type,
|
|
403
|
+ a.nickname, a.avatarurl FROM
|
|
404
|
+ ta_person_visit_record t
|
|
405
|
+ LEFT JOIN ta_person a ON t.share_person_id = a.person_id
|
|
406
|
+ LEFT JOIN ta_share_person_from b ON t.target_id = b.target_id and t.event_type = b.target_type + '_share'
|
|
407
|
+ WHERE
|
|
408
|
+ (
|
|
409
|
+ ( t.consultant_id IS NOT NULL AND t.consultant_id != '' )
|
|
410
|
+ OR ( t.share_person_id IS NOT NULL AND t.share_person_id != '' )
|
|
411
|
+ )
|
|
412
|
+ AND t.person_id != t.share_person_id
|
|
413
|
+ AND t.`event` = 'detail'
|
|
414
|
+ AND ( t.share_person_id != b.share_person OR t.consultant_id != b.share_person )
|
|
415
|
+ GROUP BY
|
|
416
|
+ t.target_id, t.event_type;
|
|
417
|
+ </select>
|
|
418
|
+
|
|
419
|
+ <select id="selectTapersonFromShare" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
|
|
420
|
+ select t.share_person_id, if (t.consultant_id != '' and t.consultant_id is not null, 'Realty Consultant', 'customer') as person_type, t.person_id, b.target_type, t.target_id,t.org_id, t.building_id From ta_person_visit_record t
|
|
421
|
+ left join ta_person a on t.share_person_id = a.person_id
|
|
422
|
+ LEFT JOIN ta_share_person_from b ON t.target_id = b.target_id and t.event_type = b.target_type + '_share'
|
|
423
|
+ where
|
|
424
|
+ (
|
|
425
|
+ ( t.consultant_id IS NOT NULL AND t.consultant_id != '' )
|
|
426
|
+ OR ( t.share_person_id IS NOT NULL AND t.share_person_id != '' )
|
|
427
|
+ )
|
|
428
|
+ AND t.person_id != t.share_person_id
|
|
429
|
+ AND t.`event` = 'detail'
|
|
430
|
+ AND ( t.share_person_id != b.share_person OR t.consultant_id != b.share_person )
|
|
431
|
+ GROUP BY
|
|
432
|
+ t.target_id, t.event_type;
|
|
433
|
+ </select>
|
|
434
|
+
|
|
435
|
+ <select id="selectTodayVisitCount" resultType="java.lang.Integer">
|
|
436
|
+ SELECT
|
|
437
|
+ COUNT(1) as visit_count
|
|
438
|
+ FROM
|
|
439
|
+ ta_person_visit_record tp
|
|
440
|
+ where tp.org_id = #{orgId} AND
|
|
441
|
+ tp.event = 'start'
|
|
442
|
+ AND DATE_FORMAT(tp.visit_time,'%Y-%m-%d') = DATE_FORMAT(#{nowDate},'%Y-%m-%d')
|
|
443
|
+ </select>
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+</mapper>
|