魏熙美 5 years ago
parent
commit
af80baa87b

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

@@ -127,8 +127,8 @@ public interface TaPersonMapper extends BaseMapper<TaPerson> {
127 127
      */
128 128
     @ResultType(Map.class)
129 129
     @Select("SELECT " +
130
-            "b.NAME AS city," +
131
-            "count(a.person_id) AS city_count" +
130
+            "ifnull(b.NAME, '其他') AS city, " +
131
+            "count(a.person_id) AS city_count " +
132 132
             " FROM" +
133 133
             " ta_person a" +
134 134
             " LEFT JOIN ( select t.*, s.pinyin as province from td_city t JOIN td_city s on t.parentid = s.id) b ON a.city = b.pinyin and a.province = b.province where ifnull(a.person_type, '') != #{personType} and a.city is not null GROUP BY a.city")

+ 40
- 39
src/main/resources/mapper/TaPersonMapper.xml View File

@@ -146,32 +146,17 @@ FROM
146 146
 
147 147
     <select id="selectRecentlyCount" resultType="integer" >
148 148
         SELECT
149
-          ifnull(SUM(activity_count), 0) as activity_count
149
+            COUNT(1) as activity_count
150 150
         FROM
151
-        (
152
-            SELECT
153
-              DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
154
-            FROM
155
-              sequence a
156
-
157
-              <trim prefix="where">
158
-                  <if test="startDate != null or endDate != null">
159
-                      a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
160
-                  </if>
161
-                  <if test="startDate == null or endDate == null">
162
-                      a.rownum <![CDATA[ <= ]]>  7
163
-                  </if>
164
-              </trim>
151
+        ta_person tp
152
+        where ifnull(tp.person_type, '') != #{personType}
165 153
 
166
-        ) AS temp_date
167
-        LEFT JOIN (
168
-            SELECT
169
-            COUNT(1) as activity_count,
170
-            tp.create_date AS create_date
171
-            FROM
172
-            ta_person tp
173
-            where ifnull(tp.person_type, '') != #{personType}
174
-        ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
154
+        <if test="startDate != null or endDate != null">
155
+            AND  tp.create_date BETWEEN #{startDate} and #{endDate}
156
+        </if>
157
+        <if test="startDate == null or endDate == null">
158
+            AND tp.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
159
+        </if>
175 160
     </select>
176 161
 
177 162
 
@@ -295,14 +280,22 @@ FROM
295 280
 
296 281
             ) AS temp_date
297 282
             LEFT JOIN (
298
-                SELECT
299
-                  COUNT(1) as authorization_count,
300
-                tp.create_date AS create_date
301
-                FROM
302
-                  ta_person tp
303
-                where ifnull(tp.person_type, '') != #{personType}
304
-                  and tp.phone is NOT NULL
305
-                GROUP BY tp.create_date
283
+
284
+                    SELECT
285
+                        COUNT(1) as authorization_count,
286
+                        tp.create_date as create_date
287
+                    FROM
288
+                      ta_person tp
289
+                    where ifnull(tp.person_type, '') != #{personType}
290
+                    and tp.phone is NOT NULL
291
+                    <if test="startDate != null or endDate != null">
292
+                        AND tp.create_date BETWEEN #{startDate} and #{endDate}
293
+                    </if>
294
+                    <if test="startDate == null or endDate == null">
295
+                         AND tp.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
296
+                    </if>
297
+                    GROUP BY DATE_FORMAT( tp.create_date , '%Y-%m-%d' )
298
+
306 299
                 ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
307 300
 
308 301
         ) as authorization_count_table
@@ -325,13 +318,21 @@ FROM
325 318
 
326 319
         ) AS temp_date
327 320
         LEFT JOIN (
328
-            SELECT
329
-              COUNT(1) as user_count,
330
-            tp.create_date AS create_date
331
-            FROM
332
-                ta_person tp
333
-            where ifnull(tp.person_type, '') != #{personType}
334
-            GROUP BY tp.create_date
321
+
322
+                SELECT
323
+                    COUNT(1) as user_count,
324
+                    tp.create_date as create_date
325
+                FROM
326
+                 ta_person tp
327
+                where ifnull(tp.person_type, '') != #{personType}
328
+                <if test="startDate != null or endDate != null">
329
+                    AND tp.create_date BETWEEN #{startDate} and #{endDate}
330
+                </if>
331
+                <if test="startDate == null or endDate == null">
332
+                    AND tp.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
333
+                </if>
334
+                GROUP BY DATE_FORMAT( tp.create_date , '%Y-%m-%d' )
335
+
335 336
             ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
336 337
 
337 338
         ) as user_count_table