魏熙美 5 年前
父节点
当前提交
de15cf9b5d

+ 8
- 11
src/main/java/com/huiju/estateagents/mapper/TaPersonMapper.java 查看文件

52
 
52
 
53
     /**
53
     /**
54
      * 总用户数
54
      * 总用户数
55
-     * @param personType
56
      * @return
55
      * @return
57
      */
56
      */
58
     @ResultType(Integer.class)
57
     @ResultType(Integer.class)
59
-    @Select("select count(1) from ta_person where org_id = #{org} AND ifnull(person_type, '') != #{personType}")
60
-    Integer selectUserCount(@Param("org") Integer orgId, @Param("personType") String personType);
58
+    @Select("select count(1) from ta_person where org_id = #{org} AND person_type IN ('customer','drift','estate agent')")
59
+    Integer selectUserCount(@Param("org") Integer orgId);
61
 
60
 
62
     /**
61
     /**
63
      * 总注册数
62
      * 总注册数
64
-     * @param personType
65
      * @return
63
      * @return
66
      */
64
      */
67
     @ResultType(Integer.class)
65
     @ResultType(Integer.class)
68
-    @Select("select count(1) from ta_person where org_id = #{org} AND ifnull(person_type, '') != #{personType} and phone is not null")
69
-    Integer selectRegisteredCount(@Param("org") Integer orgId, @Param("personType") String personType);
66
+    @Select("select count(1) from ta_person where org_id = #{org} AND person_type IN ('customer','drift','estate agent') and phone is not null")
67
+    Integer selectRegisteredCount(@Param("org") Integer orgId);
70
 
68
 
71
     /**
69
     /**
72
      * 根据时间段查询
70
      * 根据时间段查询
115
      *
113
      *
116
      *  据说 1 男  2 女
114
      *  据说 1 男  2 女
117
      *
115
      *
118
-     * @param personType
119
      * @return
116
      * @return
120
      */
117
      */
121
-    @Select("select count(1) as sex_count from ta_person where org_id = #{org} AND ifnull(person_type, '') != #{personType} and gender = #{gender}")
122
-    Integer selectSexUser(@Param("org") Integer orgId, @Param("personType") String personType, @Param("gender") Integer gender);
118
+    @Select("select count(1) as sex_count from ta_person where org_id = #{org} AND person_type IN ('customer','drift','estate agent')  and gender = #{gender}")
119
+    Integer selectSexUser(@Param("org") Integer orgId, @Param("gender") Integer gender);
123
 
120
 
124
 
121
 
125
     /**
122
     /**
140
             "on a.city = b.id " +
137
             "on a.city = b.id " +
141
             "WHERE " +
138
             "WHERE " +
142
             "   a.org_id = #{org} " +
139
             "   a.org_id = #{org} " +
143
-            "	AND ifnull(a.person_type, '') != #{personType} " +
140
+            "	AND a.person_type IN ('customer','drift','estate agent')  " +
144
             "GROUP BY " +
141
             "GROUP BY " +
145
             "	a.city ")
142
             "	a.city ")
146
-    List<Map<String, Object>> selectCityUser(@Param("org") Integer orgId, @Param("personType") String personType);
143
+    List<Map<String, Object>> selectCityUser(@Param("org") Integer orgId);
147
 
144
 
148
 
145
 
149
     // ------------- 用户来源 start ------------
146
     // ------------- 用户来源 start ------------

+ 12
- 12
src/main/java/com/huiju/estateagents/service/impl/StatisticalServiceImpl.java 查看文件

52
         Map<String,Object> map = new HashMap<>();
52
         Map<String,Object> map = new HashMap<>();
53
 
53
 
54
         // 总用户数
54
         // 总用户数
55
-        Integer selectUserCount = taPersonMapper.selectUserCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT);
55
+        Integer selectUserCount = taPersonMapper.selectUserCount(orgId);
56
 
56
 
57
         // 注册数
57
         // 注册数
58
-        Integer selectRegisteredCount = taPersonMapper.selectRegisteredCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT);
58
+        Integer selectRegisteredCount = taPersonMapper.selectRegisteredCount(orgId);
59
 
59
 
60
         // 最近七天
60
         // 最近七天
61
         Integer selectRecentlyCount = taPersonMapper.selectRecentlyCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT, null, null);
61
         Integer selectRecentlyCount = taPersonMapper.selectRecentlyCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT, null, null);
71
 
71
 
72
         // 性别比例
72
         // 性别比例
73
         // 1 男 2 女
73
         // 1 男 2 女
74
-        Integer selectSexMale = taPersonMapper.selectSexUser(orgId, CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.SEX_MALE);
75
-        Integer selectSexFemale = taPersonMapper.selectSexUser(orgId, CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.SEX_FEMALE);
74
+        Integer selectSexMale = taPersonMapper.selectSexUser(orgId, CommConstant.SEX_MALE);
75
+        Integer selectSexFemale = taPersonMapper.selectSexUser(orgId, CommConstant.SEX_FEMALE);
76
         Map<String, Object> selectSexMaleMap = new HashMap<>();
76
         Map<String, Object> selectSexMaleMap = new HashMap<>();
77
         selectSexMaleMap.put("name", "男");
77
         selectSexMaleMap.put("name", "男");
78
         selectSexMaleMap.put("value", selectSexMale);
78
         selectSexMaleMap.put("value", selectSexMale);
84
         selectSexUser.add(selectSexFemaleMap);
84
         selectSexUser.add(selectSexFemaleMap);
85
 
85
 
86
         // 城市比例
86
         // 城市比例
87
-        List<Map<String, Object>> selectCityUser = taPersonMapper.selectCityUser(orgId, CommConstant.PERSON_REALTY_CONSULTANT);
87
+        List<Map<String, Object>> selectCityUser = taPersonMapper.selectCityUser(orgId);
88
 
88
 
89
         // 转化率, 当前 默认项目收藏
89
         // 转化率, 当前 默认项目收藏
90
         Map<String, Object> selectBuildingStatistical = taBuildingMapper.selectBuildingStatistical(orgId, "save");
90
         Map<String, Object> selectBuildingStatistical = taBuildingMapper.selectBuildingStatistical(orgId, "save");
235
 
235
 
236
             case CommConstant.AUTHORIZATION_PHONE:
236
             case CommConstant.AUTHORIZATION_PHONE:
237
                 // 总用户数
237
                 // 总用户数
238
-                Integer selectUserCount = taPersonMapper.selectUserCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT);
238
+                Integer selectUserCount = taPersonMapper.selectUserCount(orgId);
239
 
239
 
240
                 // 注册数
240
                 // 注册数
241
-                Integer selectRegisteredCount = taPersonMapper.selectRegisteredCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT);
241
+                Integer selectRegisteredCount = taPersonMapper.selectRegisteredCount(orgId);
242
                 Map<String, Object> userMap = new HashMap<>();
242
                 Map<String, Object> userMap = new HashMap<>();
243
                 userMap.put("pvNum", selectUserCount);
243
                 userMap.put("pvNum", selectUserCount);
244
                 userMap.put("registeredCount", selectRegisteredCount);
244
                 userMap.put("registeredCount", selectRegisteredCount);
284
     public ResponseBean selectUserCount(Integer orgId) {
284
     public ResponseBean selectUserCount(Integer orgId) {
285
         ResponseBean responseBean = new ResponseBean();
285
         ResponseBean responseBean = new ResponseBean();
286
         // 总用户数
286
         // 总用户数
287
-        Integer selectUserCount = taPersonMapper.selectUserCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT);
287
+        Integer selectUserCount = taPersonMapper.selectUserCount(orgId);
288
         Map<String, Object> map = new HashMap<>();
288
         Map<String, Object> map = new HashMap<>();
289
         map.put("selectUserCount", selectUserCount);
289
         map.put("selectUserCount", selectUserCount);
290
         responseBean.addSuccess(map);
290
         responseBean.addSuccess(map);
295
     public ResponseBean selectRegisteredCount(Integer orgId) {
295
     public ResponseBean selectRegisteredCount(Integer orgId) {
296
         ResponseBean responseBean = new ResponseBean();
296
         ResponseBean responseBean = new ResponseBean();
297
         // 注册数
297
         // 注册数
298
-        Integer selectRegisteredCount = taPersonMapper.selectRegisteredCount(orgId, CommConstant.PERSON_REALTY_CONSULTANT);
298
+        Integer selectRegisteredCount = taPersonMapper.selectRegisteredCount(orgId);
299
         Map<String, Object> map = new HashMap<>();
299
         Map<String, Object> map = new HashMap<>();
300
         map.put("selectRegisteredCount", selectRegisteredCount);
300
         map.put("selectRegisteredCount", selectRegisteredCount);
301
         responseBean.addSuccess(map);
301
         responseBean.addSuccess(map);
319
 
319
 
320
         // 性别比例
320
         // 性别比例
321
         // 1 男 2 女
321
         // 1 男 2 女
322
-        Integer selectSexMale = taPersonMapper.selectSexUser(orgId, CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.SEX_MALE);
323
-        Integer selectSexFemale = taPersonMapper.selectSexUser(orgId, CommConstant.PERSON_REALTY_CONSULTANT, CommConstant.SEX_FEMALE);
322
+        Integer selectSexMale = taPersonMapper.selectSexUser(orgId, CommConstant.SEX_MALE);
323
+        Integer selectSexFemale = taPersonMapper.selectSexUser(orgId, CommConstant.SEX_FEMALE);
324
         Map<String, Object> selectSexMaleMap = new HashMap<>();
324
         Map<String, Object> selectSexMaleMap = new HashMap<>();
325
         selectSexMaleMap.put("name", "男");
325
         selectSexMaleMap.put("name", "男");
326
         selectSexMaleMap.put("value", selectSexMale);
326
         selectSexMaleMap.put("value", selectSexMale);
342
         ResponseBean responseBean = new ResponseBean();
342
         ResponseBean responseBean = new ResponseBean();
343
 
343
 
344
         // 城市比例
344
         // 城市比例
345
-        List<Map<String, Object>> selectCityUser = taPersonMapper.selectCityUser(orgId, CommConstant.PERSON_REALTY_CONSULTANT);
345
+        List<Map<String, Object>> selectCityUser = taPersonMapper.selectCityUser(orgId);
346
         Map<String, Object> map = new HashMap<>();
346
         Map<String, Object> map = new HashMap<>();
347
         map.put("selectCityUser", selectCityUser);
347
         map.put("selectCityUser", selectCityUser);
348
         responseBean.addSuccess(map);
348
         responseBean.addSuccess(map);

+ 11
- 12
src/main/resources/mapper/TaPersonMapper.xml 查看文件

157
         FROM
157
         FROM
158
         ta_person tp
158
         ta_person tp
159
         where tp.org_id = #{org} AND
159
         where tp.org_id = #{org} AND
160
-          ifnull(tp.person_type, '') != #{personType}
160
+        tp.person_type IN ('customer','drift','estate agent')
161
 
161
 
162
         <if test="startDate != null or endDate != null">
162
         <if test="startDate != null or endDate != null">
163
             AND  tp.create_date BETWEEN #{startDate} and #{endDate}
163
             AND  tp.create_date BETWEEN #{startDate} and #{endDate}
196
             FROM
196
             FROM
197
               ta_person tp
197
               ta_person tp
198
             INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
198
             INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
199
-            where tp.org_id = #{org} AND ifnull(tp.person_type, '') != #{personType}
199
+            where tp.org_id = #{org} AND tp.person_type IN ('customer','drift','estate agent')
200
             <if test="buildingId != null and buildingId != ''">
200
             <if test="buildingId != null and buildingId != ''">
201
                 and tpvr.building_id = #{buildingId}
201
                 and tpvr.building_id = #{buildingId}
202
             </if>
202
             </if>
254
              LEFT JOIN
254
              LEFT JOIN
255
             ( SELECT *, MAX(visit_time) as max_visit_time FROM ta_person_visit_record GROUP BY  person_id  ) as tpvr
255
             ( SELECT *, MAX(visit_time) as max_visit_time FROM ta_person_visit_record GROUP BY  person_id  ) as tpvr
256
             ON tp.person_id = tpvr.person_id
256
             ON tp.person_id = tpvr.person_id
257
-             where tp.org_id = #{org} AND ifnull(tp.person_type, '') != #{personType}
257
+             where tp.org_id = #{org} AND tp.person_type IN ('customer','drift','estate agent')
258
              GROUP BY DATE_FORMAT( tpvr.max_visit_time , '%Y-%m-%d' )
258
              GROUP BY DATE_FORMAT( tpvr.max_visit_time , '%Y-%m-%d' )
259
         ) AS temp ON
259
         ) AS temp ON
260
         <if test="dateType == 'month'.toString()">
260
         <if test="dateType == 'month'.toString()">
297
                         tp.create_date as create_date
297
                         tp.create_date as create_date
298
                     FROM
298
                     FROM
299
                       ta_person tp
299
                       ta_person tp
300
-                    where ifnull(tp.person_type, '') != #{personType} and tp.org_id = #{orgId}
300
+                    where tp.person_type IN ('customer','drift','estate agent') and tp.org_id = #{orgId}
301
                     and tp.phone is NOT NULL
301
                     and tp.phone is NOT NULL
302
                     <if test="startDate != null or endDate != null">
302
                     <if test="startDate != null or endDate != null">
303
                         AND tp.create_date BETWEEN #{startDate} and #{endDate}
303
                         AND tp.create_date BETWEEN #{startDate} and #{endDate}
335
                     tp.create_date as create_date
335
                     tp.create_date as create_date
336
                 FROM
336
                 FROM
337
                  ta_person tp
337
                  ta_person tp
338
-                where ifnull(tp.person_type, '') != #{personType} and tp.org_id = #{orgId}
338
+                where tp.person_type IN ('customer','drift','estate agent') and tp.org_id = #{orgId}
339
                 <if test="startDate != null or endDate != null">
339
                 <if test="startDate != null or endDate != null">
340
                     AND tp.create_date BETWEEN #{startDate} and #{endDate}
340
                     AND tp.create_date BETWEEN #{startDate} and #{endDate}
341
                 </if>
341
                 </if>
355
     <select id="selectUserSourcePie" resultType="integer">
355
     <select id="selectUserSourcePie" resultType="integer">
356
         select count(1)
356
         select count(1)
357
         FROM ta_person
357
         FROM ta_person
358
-        WHERE org_id = #{org} AND
359
-          ifnull(person_type, '') != #{personType}
358
+        WHERE org_id = #{org} AND person_type IN ('customer','drift','estate agent')
360
         <if test="recommendPersonType != null and recommendPersonType != ''">
359
         <if test="recommendPersonType != null and recommendPersonType != ''">
361
             and recommend_person_type = #{recommendPersonType}
360
             and recommend_person_type = #{recommendPersonType}
362
         </if>
361
         </if>
373
             ON tps.from_code = tpfs.from_code
372
             ON tps.from_code = tpfs.from_code
374
             WHERE tpfs.from_code = tpf.from_code and tps.phone is NOT NULL
373
             WHERE tpfs.from_code = tpf.from_code and tps.phone is NOT NULL
375
             AND tps.org_id = #{org}
374
             AND tps.org_id = #{org}
376
-            and ifnull(tps.person_type, '') != #{personType}
375
+            and tps.person_type IN ('customer','drift','estate agent')
377
             <if test="startDate != null or endDate != null">
376
             <if test="startDate != null or endDate != null">
378
                 and tps.create_date BETWEEN #{startDate} and #{endDate}
377
                 and tps.create_date BETWEEN #{startDate} and #{endDate}
379
             </if>
378
             </if>
389
             ON tps.from_code = tpfs.from_code
388
             ON tps.from_code = tpfs.from_code
390
             WHERE tpfs.from_code = tpf.from_code
389
             WHERE tpfs.from_code = tpf.from_code
391
             AND tps.org_id = #{org}
390
             AND tps.org_id = #{org}
392
-            and ifnull(tps.person_type, '') != #{personType}
391
+            and tps.person_type IN ('customer','drift','estate agent')
393
             <if test="startDate != null or endDate != null">
392
             <if test="startDate != null or endDate != null">
394
                 and tps.create_date BETWEEN #{startDate} and #{endDate}
393
                 and tps.create_date BETWEEN #{startDate} and #{endDate}
395
             </if>
394
             </if>
401
         FROM td_person_from tpf
400
         FROM td_person_from tpf
402
         LEFT JOIN ta_person tp
401
         LEFT JOIN ta_person tp
403
         ON tp.from_code = tpf.from_code
402
         ON tp.from_code = tpf.from_code
404
-        where tp.org_id = #{org} AND ifnull(tp.person_type, '') != #{personType}
403
+        where tp.org_id = #{org} AND tp.person_type IN ('customer','drift','estate agent')
405
         GROUP BY tpf.from_code
404
         GROUP BY tpf.from_code
406
     </select>
405
     </select>
407
 
406
 
445
             ON tps.from_code = tpfs.from_code
444
             ON tps.from_code = tpfs.from_code
446
             WHERE tpfs.from_code = tps.from_code
445
             WHERE tpfs.from_code = tps.from_code
447
             AND tps.org_id = #{org}
446
             AND tps.org_id = #{org}
448
-            and ifnull(tps.person_type, '') != 'Realty Consultant'
447
+            and tps.person_type IN ('customer','drift','estate agent')
449
             AND tps.create_date BETWEEN #{startDate} AND #{endDate}
448
             AND tps.create_date BETWEEN #{startDate} AND #{endDate}
450
 
449
 
451
             GROUP BY tpfs.from_code
450
             GROUP BY tpfs.from_code
463
             ON tps.from_code = tpfs.from_code
462
             ON tps.from_code = tpfs.from_code
464
             WHERE tpfs.from_code = tps.from_code
463
             WHERE tpfs.from_code = tps.from_code
465
                 AND tps.org_id = #{org}
464
                 AND tps.org_id = #{org}
466
-                and ifnull(tps.person_type, '') != 'Realty Consultant'
465
+                and tps.person_type IN ('customer','drift','estate agent')
467
                 AND tps.create_date BETWEEN #{startDate} AND #{endDate}
466
                 AND tps.create_date BETWEEN #{startDate} AND #{endDate}
468
                 and tps.phone is not null
467
                 and tps.phone is not null
469
             GROUP BY tpfs.from_code
468
             GROUP BY tpfs.from_code