魏熙美 5 lat temu
rodzic
commit
af80baa87b

+ 2
- 2
src/main/java/com/huiju/estateagents/mapper/TaPersonMapper.java Wyświetl plik

127
      */
127
      */
128
     @ResultType(Map.class)
128
     @ResultType(Map.class)
129
     @Select("SELECT " +
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
             " FROM" +
132
             " FROM" +
133
             " ta_person a" +
133
             " ta_person a" +
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")
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 Wyświetl plik

146
 
146
 
147
     <select id="selectRecentlyCount" resultType="integer" >
147
     <select id="selectRecentlyCount" resultType="integer" >
148
         SELECT
148
         SELECT
149
-          ifnull(SUM(activity_count), 0) as activity_count
149
+            COUNT(1) as activity_count
150
         FROM
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
     </select>
160
     </select>
176
 
161
 
177
 
162
 
295
 
280
 
296
             ) AS temp_date
281
             ) AS temp_date
297
             LEFT JOIN (
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
                 ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
299
                 ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
307
 
300
 
308
         ) as authorization_count_table
301
         ) as authorization_count_table
325
 
318
 
326
         ) AS temp_date
319
         ) AS temp_date
327
         LEFT JOIN (
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
             ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
336
             ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
336
 
337
 
337
         ) as user_count_table
338
         ) as user_count_table