|
@@ -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 < 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
|
|