Bläddra i källkod

查询统计 用户来源

魏熙美 5 år sedan
förälder
incheckning
7eb2e78e6e

+ 19
- 8
src/main/java/com/huiju/estateagents/controller/StatisticalController.java Visa fil

@@ -21,7 +21,7 @@ public class StatisticalController {
21 21
      * 首页统计
22 22
      * @return
23 23
      */
24
-    @GetMapping(value = "/indexStatistical")
24
+    @GetMapping(value = "/admin/indexStatistical")
25 25
     public ResponseBean indexStatistical() {
26 26
         return iStatisticalService.indexStatistical();
27 27
     }
@@ -30,7 +30,7 @@ public class StatisticalController {
30 30
      * 活跃用户数
31 31
      * @return
32 32
      */
33
-    @GetMapping(value = "/selectActiveUserCount")
33
+    @GetMapping(value = "/admin/selectActiveUserCount")
34 34
     public ResponseBean selectActiveUserCount(@RequestParam String dateType) {
35 35
         return iStatisticalService.selectActiveUserCount(dateType);
36 36
     }
@@ -39,7 +39,7 @@ public class StatisticalController {
39 39
      * 活跃用户数
40 40
      * @return
41 41
      */
42
-    @GetMapping(value = "/selectNewsUserCount")
42
+    @GetMapping(value = "/admin/selectNewsUserCount")
43 43
     public ResponseBean selectNewsUserCount(@RequestParam(required = false) Date startDate,
44 44
                                             @RequestParam(required = false) Date endDate) {
45 45
         return iStatisticalService.selectNewsUserCount(startDate, endDate);
@@ -49,7 +49,7 @@ public class StatisticalController {
49 49
      * 转化率 统计
50 50
      * @return
51 51
      */
52
-    @GetMapping(value = "/selectConversion")
52
+    @GetMapping(value = "/admin/selectConversion")
53 53
     public ResponseBean selectConversion(String conversion) {
54 54
         return iStatisticalService.selectConversion(conversion);
55 55
     }
@@ -58,7 +58,7 @@ public class StatisticalController {
58 58
      * 用户行为
59 59
      * @return
60 60
      */
61
-    @GetMapping(value = "/selectUserBehavior")
61
+    @GetMapping(value = "/admin/selectUserBehavior")
62 62
     public ResponseBean selectUserBehavior(@RequestParam(required = false) Date startDate,
63 63
                                             @RequestParam(required = false) Date endDate) {
64 64
         return iStatisticalService.selectUserBehavior(startDate, endDate);
@@ -69,7 +69,7 @@ public class StatisticalController {
69 69
      * 行为分析的 列表
70 70
      * @return
71 71
      */
72
-    @GetMapping(value = "/selectUserBehaviorAll")
72
+    @GetMapping(value = "/admin/selectUserBehaviorAll")
73 73
     public ResponseBean selectUserBehaviorAll(@RequestParam(required = false) Integer pageNum,
74 74
                                            @RequestParam(required = false) Integer pageCode) {
75 75
         return iStatisticalService.selectUserBehaviorAll(pageNum, pageCode);
@@ -79,7 +79,7 @@ public class StatisticalController {
79 79
      * 行为分析的 具体数据列表
80 80
      * @return
81 81
      */
82
-    @GetMapping(value = "/selectEventAll")
82
+    @GetMapping(value = "/admin/selectEventAll")
83 83
     public ResponseBean selectEventAll(@RequestParam(required = false) String event,
84 84
                                               @RequestParam(required = false) Integer personId) {
85 85
         return iStatisticalService.selectEventAll(event, personId);
@@ -89,9 +89,20 @@ public class StatisticalController {
89 89
      * 行为分析的 具体数据列表
90 90
      * @return
91 91
      */
92
-    @GetMapping(value = "/selectConversion/activity")
92
+    @GetMapping(value = "/admin/selectConversion/activity")
93 93
     public ResponseBean selectConversionAll(@RequestParam(value = "conversion") String conversion) {
94 94
         return iStatisticalService.selectConversion(conversion);
95 95
     }
96 96
 
97
+
98
+    /**
99
+     * 用户来源 统计首页
100
+     * @return
101
+     */
102
+    @GetMapping(value = "/admin/selectUserResource")
103
+    public ResponseBean selectUserResource() {
104
+        return iStatisticalService.selectUserResource();
105
+    }
106
+
107
+
97 108
 }

+ 23
- 4
src/main/java/com/huiju/estateagents/mapper/TaPersonMapper.java Visa fil

@@ -55,7 +55,7 @@ public interface TaPersonMapper extends BaseMapper<TaPerson> {
55 55
      * @param personType
56 56
      * @return
57 57
      */
58
-    @Select("select count(1) from ta_person where person_type = #{personType}")
58
+    @Select("select count(1) from ta_person where person_type != #{personType}")
59 59
     Integer selectUserCount(@Param("personType") String personType);
60 60
 
61 61
     /**
@@ -63,7 +63,7 @@ public interface TaPersonMapper extends BaseMapper<TaPerson> {
63 63
      * @param personType
64 64
      * @return
65 65
      */
66
-    @Select("select count(1) from ta_person where person_type = #{personType} and phone is not null")
66
+    @Select("select count(1) from ta_person where person_type != #{personType} and phone is not null")
67 67
     Integer selectRegisteredCount(@Param("personType") String personType);
68 68
 
69 69
     /**
@@ -106,7 +106,7 @@ public interface TaPersonMapper extends BaseMapper<TaPerson> {
106 106
      * @param personType
107 107
      * @return
108 108
      */
109
-    @Select("select sex, count(1) from ta_person where person_type = #{personType} GROUP BY sex")
109
+    @Select("select sex, count(1) from ta_person where person_type != #{personType} GROUP BY sex")
110 110
     List<Map<String, Object>> selectSexUser(@Param("personType") String personType);
111 111
 
112 112
 
@@ -115,8 +115,27 @@ public interface TaPersonMapper extends BaseMapper<TaPerson> {
115 115
      * @param personType
116 116
      * @return
117 117
      */
118
-    @Select("select city, count(1) from ta_person where person_type = #{personType} GROUP BY city")
118
+    @Select("select city, count(1) from ta_person where person_type != #{personType} GROUP BY city")
119 119
     List<Map<String, Object>> selectCityUser(@Param("personType") String personType);
120 120
 
121 121
 
122
+    // ------------- 用户来源 start ------------
123
+
124
+    /**
125
+     * 用户来源 的饼图
126
+     * @param recommendPersonType
127
+     * @return
128
+     */
129
+    Integer selectUserSourcePie(@Param("recommendPersonType") String recommendPersonType, @Param("personType") String personType);
130
+
131
+    /**
132
+     * 用户来源 柱状
133
+     * @return
134
+     */
135
+    List<Map<String, Object>> selectUserSourceColumnar(@Param("personType") String personType);
136
+
137
+
138
+    // ------------- 用户来源 end ------------
139
+
140
+
122 141
 }

+ 7
- 0
src/main/java/com/huiju/estateagents/service/IStatisticalService.java Visa fil

@@ -59,4 +59,11 @@ public interface IStatisticalService {
59 59
      * @return
60 60
      */
61 61
     ResponseBean selectConversion(String conversion);
62
+
63
+    /**
64
+     * 用户来源 首页
65
+     * @return
66
+     */
67
+    ResponseBean selectUserResource();
68
+
62 69
 }

+ 25
- 0
src/main/java/com/huiju/estateagents/service/impl/StatisticalServiceImpl.java Visa fil

@@ -212,4 +212,29 @@ public class StatisticalServiceImpl implements IStatisticalService {
212 212
         responseBean.addSuccess(result);
213 213
         return responseBean;
214 214
     }
215
+
216
+
217
+    @Override
218
+    public ResponseBean selectUserResource() {
219
+        ResponseBean responseBean = new ResponseBean();
220
+        // 用户来源 柱状
221
+        List<Map<String, Object>> mapList = taPersonMapper.selectUserSourceColumnar(CommConstant.PERSON_REALTY_CONSULTANT);
222
+
223
+        // 用户来源饼状
224
+        // 来源置业顾问, 来源全民经纪人,自由进入
225
+        Integer person_realty_consultant = taPersonMapper.selectUserSourcePie(CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.PERSON_REALTY_CONSULTANT);
226
+        Integer person_estate_agent = taPersonMapper.selectUserSourcePie(CommConstant.PERSON_ESTATE_AGENT, CommConstant.PERSON_REALTY_CONSULTANT);
227
+        Integer person_null = taPersonMapper.selectUserSourcePie(null, CommConstant.PERSON_REALTY_CONSULTANT);
228
+        Map<String, Object> map = new HashMap<>();
229
+        map.put("person_realty_consultant", person_realty_consultant);
230
+        map.put("person_estate_agent", person_estate_agent);
231
+        map.put("person_null", person_null);
232
+
233
+
234
+        Map<String, Object> result = new HashMap<>();
235
+        result.put("columnar", mapList);
236
+        result.put("pie", map);
237
+
238
+        return responseBean;
239
+    }
215 240
 }

+ 62
- 8
src/main/resources/mapper/TaPersonMapper.xml Visa fil

@@ -164,6 +164,7 @@ FROM
164 164
             FROM
165 165
             ta_person tp
166 166
             INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
167
+            where tp.person_type != #{personType}
167 168
         ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
168 169
     </select>
169 170
 
@@ -193,7 +194,7 @@ FROM
193 194
             FROM
194 195
             ta_person tp
195 196
             INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
196
-            where tp.person_type = #{personType}
197
+            where tp.person_type != #{personType}
197 198
             GROUP BY tpvr.activity
198 199
         ) AS temp ON temp_date.date = DATE_FORMAT( temp.visitTime , '%Y-%m-%d' )
199 200
     </select>
@@ -230,14 +231,14 @@ FROM
230 231
             FROM
231 232
                ta_person tp
232 233
             INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
233
-             where tp.person_type = #{personType}
234
+             where tp.person_type != #{personType}
234 235
         ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
235 236
     </select>
236 237
 
237
-    <select id="selectNewsUserCount" >
238
+    <select id="selectNewsUserCount" resultType="map">
238 239
         SELECT
239
-        consultant_count_table.date as date,
240
-        consultant_count_table.consultant_count as consultant_count,
240
+        authorization_count_table.date as date,
241
+        authorization_count_table.authorization_count as authorization_count,
241 242
         user_count_table.user_count as user_count
242 243
         FROM
243 244
         (
@@ -259,14 +260,15 @@ FROM
259 260
             ) AS temp_date
260 261
             LEFT JOIN (
261 262
                 SELECT
262
-                COUNT(1) as consultant_count,
263
+                COUNT(1) as authorization_count,
263 264
                 tpvr.visit_time AS visit_time
264 265
                 FROM
265 266
                 ta_person tp
266 267
                 INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
267
-                where tp.person_type = 'Realty Consultant'
268
+                where tp.person_type != #{personType}
269
+                and tp.phone is NOT NULL
268 270
             ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
269
-        ) as consultant_count_table
271
+        ) as authorization_count_table
270 272
         ,
271 273
         (SELECT
272 274
         *
@@ -291,10 +293,62 @@ FROM
291 293
             FROM
292 294
             ta_person tp
293 295
             INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
296
+            where tp.person_type != #{personType}
294 297
         ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
295 298
 
296 299
         ) as user_count_table
297 300
         GROUP BY date
298 301
     </select>
299 302
 
303
+    <select id="selectUserSourcePie">
304
+        select count(1)
305
+        FROM ta_person
306
+        WHERE person_type != #{personType}
307
+        <if test="recommendPersonType != null and recommendPersonType != ''">
308
+            and recommend_person_type = #{recommendPersonType}
309
+        </if>
310
+    </select>
311
+
312
+    <select id="selectUserSourceColumnar" resultType="map">
313
+        SELECT
314
+        tpf.from_name as from_name,
315
+        (
316
+            SELECT
317
+                COUNT(1)
318
+            FROM ta_person tps
319
+            LEFT JOIN td_person_from tpfs
320
+            ON tps.from_code = tpfs.from_code
321
+            WHERE tpfs.from_code = tpf.from_code and tps.phone is NOT NULL
322
+            and tps.person_type != #{personType}
323
+            <if test="startDate != null or endDate != null">
324
+                and tps.create_date BETWEEN #{startDate} and #{endDate}
325
+            </if>
326
+            <if test="startDate == null or endDate == null">
327
+                and tps.create_date BETWEEN DATE_SUB( tp.create_date, INTERVAL 7 DAY ) and now()
328
+            </if>
329
+        ) as registered,
330
+        (
331
+            SELECT
332
+                COUNT(1)
333
+            FROM ta_person tps
334
+            LEFT JOIN td_person_from tpfs
335
+            ON tps.from_code = tpfs.from_code
336
+            WHERE tpfs.from_code = tpf.from_code
337
+            and tps.person_type != #{personType}
338
+            <if test="startDate != null or endDate != null">
339
+                and tps.create_date BETWEEN #{startDate} and #{endDate}
340
+            </if>
341
+            <if test="startDate == null or endDate == null">
342
+                and tps.create_date BETWEEN DATE_SUB( tp.create_date, INTERVAL 7 DAY ) and now()
343
+            </if>
344
+        ) as user_count
345
+
346
+        FROM td_person_from tpf
347
+        LEFT JOIN ta_person tp
348
+        ON tp.from_code = tpf.from_code
349
+        where tp.person_type != #{personType}
350
+        GROUP BY tpf.from_code
351
+    </select>
352
+
353
+
300 354
 </mapper>