Browse Source

Merge branch 'dev' of http://git.ycjcjy.com/zhiyuxing/estateagents into dev

魏超 5 years ago
parent
commit
0c51cfd673

+ 53
- 28
src/main/resources/mapper/TsActivityDailyMapper.xml View File

@@ -4,42 +4,67 @@
4 4
 
5 5
     <select id="getActivityDetail" resultType="com.huiju.estateagents.entity.TsActivityDaily">
6 6
         SELECT
7
-            t.statis_date,
8
-            SUM(t.share_num) as share_num,
9
-            SUM(t.share_persons) as share_persons,
10
-            SUM(t.visit_num) as visit_num,
11
-            SUM(t.visit_persons) as visit_persons,
12
-            SUM(t.new_persons) as new_persons,
13
-            SUM(t.new_customers) as new_customers
7
+            a.statis_date,
8
+            IFNULL(b.share_num, 0) as share_num,
9
+            IFNULL(b.share_persons, 0) as share_persons,
10
+            IFNULL(b.visit_num, 0) as visit_num,
11
+            IFNULL(b.visit_persons, 0) as visit_persons,
12
+            IFNULL(b.new_persons, 0) as new_persons,
13
+            IFNULL(b.new_customers, 0) as new_customers
14 14
         FROM
15
-            ts_activity_daily t
16
-        WHERE
17
-            t.org_id = #{orgId}
18
-            AND t.statis_date BETWEEN #{startDate} AND #{endDate}
15
+        (
16
+            SELECT
17
+                DATE_FORMAT(
18
+                    DATE_ADD( STR_TO_DATE( '2020-04-18', '%Y-%m-%d' ), INTERVAL rownum DAY ), '%Y-%m-%d' ) AS statis_date
19
+            FROM sequence
20
+            WHERE rownum &lt; DATEDIFF(STR_TO_DATE( #{endDate}, '%Y-%m-%d' ), STR_TO_DATE( #{startDate}, '%Y-%m-%d' ))
21
+        ) a
22
+        LEFT JOIN (
23
+            SELECT
24
+                t.statis_date,
25
+                SUM(t.share_num) as share_num,
26
+                SUM(t.share_persons) as share_persons,
27
+                SUM(t.visit_num) as visit_num,
28
+                SUM(t.visit_persons) as visit_persons,
29
+                SUM(t.new_persons) as new_persons,
30
+                SUM(t.new_customers) as new_customers
31
+            FROM
32
+                ts_activity_daily t
33
+            WHERE
34
+                t.org_id = #{orgId}
35
+                AND t.statis_date BETWEEN #{startDate} AND #{endDate}
19 36
 
20
-        <if test="buildingId != null and buildingId != ''">
21
-            AND t.building_id = #{buildingId}
22
-        </if>
37
+            <if test="buildingId != null and buildingId != ''">
38
+                AND t.building_id = #{buildingId}
39
+            </if>
23 40
 
24
-        <if test="targetType != null and targetType != ''">
25
-            AND t.target_type = #{targetType}
26
-        </if>
41
+            <if test="targetType != null and targetType != ''">
42
+                AND t.target_type = #{targetType}
43
+            </if>
27 44
 
28
-        <if test="targetId != null and targetId != ''">
29
-            AND t.target_id = #{targetId}
30
-        </if>
45
+            <if test="targetId != null and targetId != ''">
46
+                AND t.target_id = #{targetId}
47
+            </if>
31 48
 
32
-        <if test="targetName != null and targetName != ''">
33
-            AND t.target_name like CONCAT('%', #{targetName}, '%')
34
-        </if>
49
+            <if test="targetName != null and targetName != ''">
50
+                AND t.target_name like CONCAT('%', #{targetName}, '%')
51
+            </if>
52
+
53
+            GROUP BY t.statis_date
54
+        ) b ON a.statis_date = b.statis_date
35 55
 
36
-        GROUP BY t.statis_date
56
+        <if test="asc != null and asc == 'statis_date'">
57
+            ORDER BY a.statis_date ASC
58
+        </if>
59
+        <if test="desc != null and desc == 'statis_date'">
60
+            ORDER BY a.statis_date DESC
61
+        </if>
37 62
 
38
-        <if test="asc != null and asc != ''">
39
-            ORDER BY ${asc} ASC
63
+        <if test="asc != null and asc != '' and asc != 'statis_date'">
64
+            ORDER BY b.${asc} ASC
40 65
         </if>
41
-        <if test="desc != null and desc != ''">
42
-            ORDER BY ${desc} DESC
66
+        <if test="desc != null and desc != '' and desc != 'statis_date'">
67
+            ORDER BY b.${desc} DESC
43 68
         </if>
44 69
     </select>
45 70
 

+ 4
- 1
src/main/resources/mapper/TsConsultantKpiMapper.xml View File

@@ -362,6 +362,9 @@
362 362
             AND e.target_type = 'share'
363 363
             AND e.target_id = 'index'
364 364
         </if>
365
+        <if test="targetName != null and targetName !=''">
366
+            AND e.target_name like concat('%', #{targetName} ,'%')
367
+        </if>
365 368
 
366 369
             AND e.create_date BETWEEN #{startDate} and #{endDate}
367 370
             <!-- building_id 字段数据不全
@@ -374,7 +377,7 @@
374 377
             AND t.person_id = #{personId}
375 378
         </if>
376 379
         <if test="userName != null and userName !=''">
377
-            AND t.nickname like concat('%', #{userName} ,'%')
380
+            AND IFNULL(t.name, t.nickname) like concat('%', #{userName} ,'%')
378 381
         </if>
379 382
             <!--            AND t.`status` = 1-->
380 383
         ORDER BY e.create_date DESC