Browse Source

定时任务优化

魏超 5 years ago
parent
commit
6a38a95024

+ 4
- 30
src/main/resources/mapper/HelpActivityMapper.xml View File

@@ -38,44 +38,18 @@
38 38
     </select>
39 39
 
40 40
     <update id="updateUnStartHelpActivity">
41
-        update ta_help_activity
41
+        update ta_help_activity t
42 42
         set activity_status = 0
43 43
         where
44
-        help_activity_id in (
45
-            select
46
-            help_activity_id
47
-            from
48
-            (
49
-            select
50
-            t.help_activity_id
51
-            from
52
-            ta_help_activity t
53
-            where
54
-            t.activity_status != '2'
55
-            and NOW() > t.start_date
56
-            and NOW() &lt; t.end_date
57
-            ) s
58
-        )
44
+        t.activity_status != '2' and NOW() BETWEEN t.start_date  and t.end_date
59 45
     </update>
60 46
 
61 47
     <update id="updateProcessingHelpActivity">
62
-        update ta_help_activity
48
+        update ta_help_activity t
63 49
         set activity_status = 2
64 50
         where
65
-            help_activity_id in (
66
-                select
67
-                    help_activity_id
68
-                from
69
-                    (
70
-                        select
71
-                            t.help_activity_id
72
-                        from
73
-                            ta_help_activity t
74
-                        where
75
-                            t.activity_status != '2'
51
+             t.activity_status != '2'
76 52
                         and NOW() > t.end_date
77
-                    ) s
78
-            )
79 53
     </update>
80 54
 
81 55
     <select id="selectWxhelpActivityAndGroup" resultType="com.huiju.estateagents.entity.HelpActivity">

+ 15
- 11
src/main/resources/mapper/HelpInitiateRecordMapper.xml View File

@@ -3,17 +3,21 @@
3 3
 <mapper namespace="com.huiju.estateagents.mapper.HelpInitiateRecordMapper">
4 4
 
5 5
     <update id="updateHelpActivityProcessToEnd">
6
-      update ta_help_initiate_record a
7
-        set a.`status` = '2'
8
-        where
9
-            a.help_activity_id in (
10
-                select
11
-                    t.help_activity_id
12
-                from
13
-                    ta_help_activity t
14
-                where (NOW() > t.end_date or t.activity_status = '2')
15
-            )
16
-        and a.`status` = '1'
6
+--       update ta_help_initiate_record a
7
+--         set a.`status` = '2'
8
+--         where
9
+--             a.help_activity_id in (
10
+--                 select
11
+--                     t.help_activity_id
12
+--                 from
13
+--                     ta_help_activity t
14
+--                 where (NOW() > t.end_date or t.activity_status = '2')
15
+--             )
16
+--         and a.`status` = '1'
17
+        update ta_help_initiate_record a
18
+        left join ta_help_activity b on a.help_activity_id = b.help_activity_id
19
+        set a.status = '2'
20
+        where  (NOW() > b.end_date or b.activity_status = '2') and a.`status` = '1' and a.status != '0'
17 21
     </update>
18 22
 
19 23
     <select id="selectPageList" resultType="com.huiju.estateagents.entity.HelpInitiateRecord">

+ 4
- 31
src/main/resources/mapper/TaBuildingDynamicMapper.xml View File

@@ -96,44 +96,17 @@
96 96
     </update>
97 97
 
98 98
     <update id="updateUnStartActivity">
99
-        update ta_building_dynamic
99
+        update ta_building_dynamic t
100 100
         set activity_status = 0
101 101
         where
102
-        dynamic_id in (
103
-            select
104
-            dynamic_id
105
-            from
106
-            (
107
-            select
108
-            t.dynamic_id
109
-            from
110
-            ta_building_dynamic t
111
-            where
112
-            t.activity_status != '2'
113
-            and NOW() > t.create_date
114
-            and NOW() &lt; t.end_date
115
-            ) s
116
-        )
102
+        t.activity_status = 1 and NOW() between  t.create_date and  t.end_date
117 103
     </update>
118 104
 
119 105
     <update id="updateProcessingActivity">
120
-        update ta_building_dynamic
106
+        update ta_building_dynamic t
121 107
         set activity_status = 2
122 108
         where
123
-            dynamic_id in (
124
-                select
125
-                    dynamic_id
126
-                from
127
-                    (
128
-                        select
129
-                            t.dynamic_id
130
-                        from
131
-                            ta_building_dynamic t
132
-                        where
133
-                            t.activity_status != '2'
134
-                        and NOW() > t.end_date
135
-                    ) s
136
-            );
109
+        t.activity_status =0 and NOW() > t.end_date
137 110
     </update>
138 111
 
139 112
     <select id="updateTaBuildingDynamic">

+ 3
- 17
src/main/resources/mapper/TaShareActivityMapper.xml View File

@@ -16,24 +16,10 @@
16 16
     </select>
17 17
 
18 18
     <update id="updateUnStartGroupActivity">
19
-        update ta_share_activity
19
+        update ta_share_activity t
20 20
         set activity_status = 0
21
-        where
22
-        group_activity_id in (
23
-            select
24
-            group_activity_id
25
-            from
26
-            (
27
-            select
28
-            t.group_activity_id
29
-            from
30
-            ta_share_activity t
31
-            where
32
-            t.activity_status != '2'
33
-            and NOW() > t.start_time
34
-            and NOW() &lt; t.end_time
35
-            ) s
36
-        )
21
+        where t.activity_status != '2'
22
+            and NOW() BETWEEN t.start_time and t.end_time
37 23
     </update>
38 24
 
39 25
     <update id="updateProcessGroupActivity">

+ 11
- 7
src/main/resources/mapper/TaShareChildRecordMapper.xml View File

@@ -3,15 +3,19 @@
3 3
 <mapper namespace="com.huiju.estateagents.mapper.TaShareChildRecordMapper">
4 4
 
5 5
     <update id="updateEndGroupActivity">
6
+--         update ta_share_child_record a
7
+--         set a.`status` = '2'
8
+--         where a.group_activity_id in (
9
+--             select
10
+--                     t.group_activity_id
11
+--                 from
12
+--                     ta_share_activity t
13
+--                 where (NOW() > t.end_time or t.activity_status = '2')
14
+--         ) and a.`status` = '1';
6 15
         update ta_share_child_record a
16
+        LEFT JOIN ta_share_activity b on a.group_activity_id = b.group_activity_id
7 17
         set a.`status` = '2'
8
-        where a.group_activity_id in (
9
-            select
10
-                    t.group_activity_id
11
-                from
12
-                    ta_share_activity t
13
-                where (NOW() > t.end_time or t.activity_status = '2')
14
-        ) and a.`status` = '1';
18
+        where (NOW() > b.end_time or b.activity_status = '2') and a.`status` = '1' and a.status != '0'
15 19
     </update>
16 20
 
17 21
     <select id="getList" resultType="com.huiju.estateagents.entity.TaShareChildRecord">

+ 13
- 9
src/main/resources/mapper/TaShareRecordMapper.xml View File

@@ -3,17 +3,21 @@
3 3
 <mapper namespace="com.huiju.estateagents.mapper.TaShareRecordMapper">
4 4
 
5 5
     <update id="updateEndGroupActivity">
6
+--         update ta_share_record a
7
+--         set a.`status` = '2'
8
+--         where
9
+--             a.group_activity_id in (
10
+--                 select
11
+--                     t.group_activity_id
12
+--                 from
13
+--                     ta_share_activity t
14
+--                 where (NOW() > t.end_time or t.activity_status = '2')
15
+--             )
16
+--         and a.`status` = '1';
6 17
         update ta_share_record a
18
+        LEFT JOIN ta_share_activity b on a.group_activity_id = b.group_activity_id
7 19
         set a.`status` = '2'
8
-        where
9
-            a.group_activity_id in (
10
-                select
11
-                    t.group_activity_id
12
-                from
13
-                    ta_share_activity t
14
-                where (NOW() > t.end_time or t.activity_status = '2')
15
-            )
16
-        and a.`status` = '1';
20
+        where (NOW() > b.end_time or b.activity_status = '2') and a.`status` = '1' and a.status != '0'
17 21
     </update>
18 22
 
19 23
     <select id="recordSuccessList" resultType="com.huiju.estateagents.entity.TaShareRecord">