Browse Source

用户行为

魏熙美 5 years ago
parent
commit
a2b3c8b24d

+ 5
- 2
src/main/java/com/huiju/estateagents/controller/StatisticalController.java View File

65
                                            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
65
                                            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
66
                                            @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
66
                                            @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate startDate,
67
                                            @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
67
                                            @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)  LocalDate endDate,
68
-                                           @RequestParam(value = "buildingId", required = false) String buildingId) {
69
-        return iStatisticalService.selectUserBehavior(pageNum, pageSize, startDate, endDate, buildingId);
68
+                                           @RequestParam(value = "buildingId", required = false) String buildingId,
69
+                                           @RequestParam(value = "eventType", required = false) String eventType,
70
+                                           @RequestParam(value = "event", required = false) String event,
71
+                                           @RequestParam(value = "activity", required = false) String activity) {
72
+        return iStatisticalService.selectUserBehavior(pageNum, pageSize, startDate, endDate, buildingId, eventType, event, activity);
70
     }
73
     }
71
 
74
 
72
     /**
75
     /**

+ 16
- 0
src/main/java/com/huiju/estateagents/entity/TaPersonVisitRecord.java View File

81
 
81
 
82
     private String targetId;
82
     private String targetId;
83
 
83
 
84
+    /**
85
+     * 用户名称
86
+     */
87
+    @TableField(exist = false)
88
+    private String userName;
89
+
90
+    /**
91
+     * 事件名称
92
+     */
93
+    @TableField(exist = false)
94
+    private String eventName;
84
 
95
 
96
+    /**
97
+     * 访问次数
98
+     */
99
+    @TableField(exist = false)
100
+    private Integer accessCount;
85
 
101
 
86
 }
102
 }

+ 7
- 1
src/main/java/com/huiju/estateagents/mapper/TaPersonMapper.java View File

86
      * @param endDate
86
      * @param endDate
87
      * @return
87
      * @return
88
      */
88
      */
89
-    List<PersonPO> selectUserBehavior(@Param("personType") String personType, @Param("startDate")LocalDate startDate, @Param("endDate")LocalDate endDate, @Param("buildingId") String buildingId);
89
+    List<PersonPO> selectUserBehavior(@Param("personType") String personType,
90
+                                      @Param("startDate")LocalDate startDate,
91
+                                      @Param("endDate")LocalDate endDate,
92
+                                      @Param("buildingId") String buildingId,
93
+                                      @Param("eventType") String eventType,
94
+                                      @Param("event") String event,
95
+                                      @Param("activity") String activity);
90
 
96
 
91
     /**
97
     /**
92
      * 活跃用户数 / 最近新增的用户数
98
      * 活跃用户数 / 最近新增的用户数

+ 5
- 1
src/main/java/com/huiju/estateagents/mapper/TaPersonVisitRecordMapper.java View File

30
      * @param page
30
      * @param page
31
      * @return
31
      * @return
32
      */
32
      */
33
-    IPage<TaPersonVisitRecord> selectAll(IPage<TaPersonVisitRecord> page, String buildingId);
33
+    IPage<TaPersonVisitRecord> selectAll(IPage<TaPersonVisitRecord> page,
34
+                                         @Param("buildingId") String buildingId,
35
+                                         @Param("eventType") String eventType,
36
+                                         @Param("event") String event,
37
+                                         @Param("activity") String activity);
34
 
38
 
35
 
39
 
36
     /**
40
     /**

+ 8
- 1
src/main/java/com/huiju/estateagents/service/IStatisticalService.java View File

69
      * @param endDate
69
      * @param endDate
70
      * @return
70
      * @return
71
      */
71
      */
72
-    ResponseBean selectUserBehavior(Integer pageNum, Integer pageSize, LocalDate startDate,LocalDate endDate, String buildingId);
72
+    ResponseBean selectUserBehavior(Integer pageNum,
73
+                                    Integer pageSize,
74
+                                    LocalDate startDate,
75
+                                    LocalDate endDate,
76
+                                    String buildingId,
77
+                                    String eventType,
78
+                                    String event,
79
+                                    String activity);
73
 
80
 
74
     /**
81
     /**
75
      * 行为分析的 具体数据列表
82
      * 行为分析的 具体数据列表

+ 11
- 4
src/main/java/com/huiju/estateagents/service/impl/StatisticalServiceImpl.java View File

61
         Integer selectRecentlyCount = taPersonMapper.selectRecentlyCount(CommConstant.PERSON_REALTY_CONSULTANT, null, null);
61
         Integer selectRecentlyCount = taPersonMapper.selectRecentlyCount(CommConstant.PERSON_REALTY_CONSULTANT, null, null);
62
 
62
 
63
         // 用户行为
63
         // 用户行为
64
-        List<PersonPO> selectUserBehavior = taPersonMapper.selectUserBehavior(CommConstant.PERSON_REALTY_CONSULTANT, null, null, null);
64
+        List<PersonPO> selectUserBehavior = taPersonMapper.selectUserBehavior(CommConstant.PERSON_REALTY_CONSULTANT, null, null, null, null, null, null);
65
 
65
 
66
         // 用户活跃数
66
         // 用户活跃数
67
         List<Map<String, Object>> selectActiveUserCount = taPersonMapper.selectActiveUserCount(CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.DAY, null, null);
67
         List<Map<String, Object>> selectActiveUserCount = taPersonMapper.selectActiveUserCount(CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.DAY, null, null);
163
     }
163
     }
164
 
164
 
165
     @Override
165
     @Override
166
-    public ResponseBean selectUserBehavior(Integer pageNum, Integer pageSize, LocalDate startDate, LocalDate endDate, String buildingId) {
166
+    public ResponseBean selectUserBehavior(Integer pageNum,
167
+                                           Integer pageSize,
168
+                                           LocalDate startDate,
169
+                                           LocalDate endDate,
170
+                                           String buildingId,
171
+                                           String eventType,
172
+                                           String event,
173
+                                           String activity) {
167
         ResponseBean responseBean = new ResponseBean();
174
         ResponseBean responseBean = new ResponseBean();
168
 
175
 
169
         // 用户行为
176
         // 用户行为
170
-        List<PersonPO> selectUserBehavior = taPersonMapper.selectUserBehavior(CommConstant.PERSON_REALTY_CONSULTANT, startDate, endDate, buildingId);
177
+        List<PersonPO> selectUserBehavior = taPersonMapper.selectUserBehavior(CommConstant.PERSON_REALTY_CONSULTANT, startDate, endDate, buildingId, eventType, event, activity);
171
 
178
 
172
         IPage<TaPersonVisitRecord> page = new Page<>(pageNum, pageSize);
179
         IPage<TaPersonVisitRecord> page = new Page<>(pageNum, pageSize);
173
-        IPage<TaPersonVisitRecord> visitRecordIPage = taPersonVisitRecordMapper.selectAll(page, buildingId);
180
+        IPage<TaPersonVisitRecord> visitRecordIPage = taPersonVisitRecordMapper.selectAll(page, buildingId, eventType, event, activity);
174
 
181
 
175
         Map<String, Object> map = new HashMap<>();
182
         Map<String, Object> map = new HashMap<>();
176
         map.put("selectUserBehavior", selectUserBehavior);
183
         map.put("selectUserBehavior", selectUserBehavior);

+ 10
- 0
src/main/resources/mapper/TaPersonMapper.xml View File

202
         <if test="buildingId != null and buildingId != ''">
202
         <if test="buildingId != null and buildingId != ''">
203
             and tpvr.building_id = #{buildingId}
203
             and tpvr.building_id = #{buildingId}
204
         </if>
204
         </if>
205
+        <if test="eventType != null and eventType != ''">
206
+            and tpvr.event_type = #{eventType}
207
+        </if>
208
+        <if test="event != null and event != ''">
209
+            and tpvr.event = #{event}
210
+        </if>
211
+        <if test="activity != null and activity != ''">
212
+            and tpvr.activity = #{activity}
213
+        </if>
214
+
205
         GROUP BY  tpvr.event_type, DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' )
215
         GROUP BY  tpvr.event_type, DATE_FORMAT( tpvr.visit_time , '%Y-%m-%d' )
206
         ) AS temp ON temp_date.date = temp.date and temp_date.type_id = temp.event_type
216
         ) AS temp ON temp_date.date = temp.date and temp_date.type_id = temp.event_type
207
     </select>
217
     </select>

+ 16
- 5
src/main/resources/mapper/TaPersonVisitRecordMapper.xml View File

6
         where person_id = #{personId}
6
         where person_id = #{personId}
7
     </select>
7
     </select>
8
 
8
 
9
-    <select id="selectAll">
9
+    <select id="selectAll" resultType="com.huiju.estateagents.entity.TaPersonVisitRecord">
10
         SELECT
10
         SELECT
11
             tpvr.*,
11
             tpvr.*,
12
-            tp.name,
12
+            tp.name as userName,
13
+            tbe.event_name as eventName,
13
             COUNT(1) as accessCount
14
             COUNT(1) as accessCount
14
         FROM
15
         FROM
15
             ta_person_visit_record tpvr
16
             ta_person_visit_record tpvr
16
             LEFT JOIN ta_person tp ON tpvr.person_id = tp.person_id
17
             LEFT JOIN ta_person tp ON tpvr.person_id = tp.person_id
17
-            <where>
18
+            <trim prefix="where" prefixOverrides="and | or">
18
                 <if test="buildingId != null and buildingId != ''">
19
                 <if test="buildingId != null and buildingId != ''">
19
-                    tpvr.building_id = #{buildingId}
20
+                    and tpvr.building_id = #{buildingId}
20
                 </if>
21
                 </if>
21
-            </where>
22
+                <if test="eventType != null and eventType != ''">
23
+                    and tpvr.event_type = #{eventType}
24
+                </if>
25
+                <if test="event != null and event != ''">
26
+                    and tpvr.event = #{event}
27
+                </if>
28
+                <if test="activity != null and activity != ''">
29
+                    and tpvr.activity = #{activity}
30
+                </if>
31
+            </trim>
32
+            LEFT JOIN td_biz_event tbe on tpvr.event = tbe.event_code
22
         GROUP BY tpvr.person_id, tpvr.event
33
         GROUP BY tpvr.person_id, tpvr.event
23
     </select>
34
     </select>
24
 
35