Showing
5 changed files
with
10 additions
and
6 deletions
@@ -2,6 +2,8 @@ package com.yoho.queue.dal; | @@ -2,6 +2,8 @@ package com.yoho.queue.dal; | ||
2 | 2 | ||
3 | import java.util.List; | 3 | import java.util.List; |
4 | 4 | ||
5 | +import org.apache.ibatis.annotations.Param; | ||
6 | + | ||
5 | import com.yoho.queue.dal.model.DrawlineActivity; | 7 | import com.yoho.queue.dal.model.DrawlineActivity; |
6 | 8 | ||
7 | public interface IDrawlineActivityDAO { | 9 | public interface IDrawlineActivityDAO { |
@@ -20,5 +22,5 @@ public interface IDrawlineActivityDAO { | @@ -20,5 +22,5 @@ public interface IDrawlineActivityDAO { | ||
20 | 22 | ||
21 | List<DrawlineActivity> selectByNotLuckydraw(); | 23 | List<DrawlineActivity> selectByNotLuckydraw(); |
22 | 24 | ||
23 | - List<DrawlineActivity> selectAllActivity(); | 25 | + List<DrawlineActivity> selectAllActivity(@Param("currentTime") int currentTime); |
24 | } | 26 | } |
@@ -38,5 +38,5 @@ public interface IDrawlineUserQueueDAO { | @@ -38,5 +38,5 @@ public interface IDrawlineUserQueueDAO { | ||
38 | 38 | ||
39 | List<DrawlineUserQueue> selectByTypeAndActivityIds(@Param("activityIds") String activityIds, @Param("userType") int userType); | 39 | List<DrawlineUserQueue> selectByTypeAndActivityIds(@Param("activityIds") String activityIds, @Param("userType") int userType); |
40 | 40 | ||
41 | - List<Map<String, Object>> selectRealUserCountByActivityIds(@Param("activityIds") String activityIds); | 41 | + List<Map<String, Object>> selectRealUserCountByActivityIds(@Param("activityIds") String activityIds, @Param("beginTime") int beginTime, @Param("endTime") int endTime); |
42 | } | 42 | } |
@@ -171,6 +171,6 @@ | @@ -171,6 +171,6 @@ | ||
171 | where status = 1 and id not in (select id from drawline_activity_luckydraw where draw_status = 1 and status = 1) | 171 | where status = 1 and id not in (select id from drawline_activity_luckydraw where draw_status = 1 and status = 1) |
172 | </select> | 172 | </select> |
173 | <select id="selectAllActivity" resultMap="BaseResultMap"> | 173 | <select id="selectAllActivity" resultMap="BaseResultMap"> |
174 | - select * from drawline_activity where status=1 and begin_time<=UNIX_TIMESTAMP() and end_time >=UNIX_TIMESTAMP() | 174 | + select * from drawline_activity where status=1 and begin_time<=#{currentTime} and end_time >=#{currentTime} |
175 | </select> | 175 | </select> |
176 | </mapper> | 176 | </mapper> |
@@ -201,7 +201,7 @@ | @@ -201,7 +201,7 @@ | ||
201 | </select> | 201 | </select> |
202 | <select id="selectRealUserCountByActivityIds" resultType="java.util.Map"> | 202 | <select id="selectRealUserCountByActivityIds" resultType="java.util.Map"> |
203 | select activity_id, count(activity_id) nums from drawline_user_queue where status=1 and user_type=1 | 203 | select activity_id, count(activity_id) nums from drawline_user_queue where status=1 and user_type=1 |
204 | - and create_time between UNIX_TIMESTAMP()-60 and UNIX_TIMESTAMP() | 204 | + and create_time between #{beginTime} and #{entTime} |
205 | and activity_id in (${activityIds}) group by activity_id | 205 | and activity_id in (${activityIds}) group by activity_id |
206 | </select> | 206 | </select> |
207 | </mapper> | 207 | </mapper> |
@@ -19,6 +19,7 @@ import org.springframework.scheduling.annotation.Scheduled; | @@ -19,6 +19,7 @@ import org.springframework.scheduling.annotation.Scheduled; | ||
19 | import org.springframework.stereotype.Component; | 19 | import org.springframework.stereotype.Component; |
20 | 20 | ||
21 | import com.yoho.activity.common.enums.UserTypeEnum; | 21 | import com.yoho.activity.common.enums.UserTypeEnum; |
22 | +import com.yoho.activity.common.utils.DateUtils; | ||
22 | import com.yoho.activity.common.utils.MapUtil; | 23 | import com.yoho.activity.common.utils.MapUtil; |
23 | import com.yoho.activity.common.utils.MapUtil.FunctionExPlus; | 24 | import com.yoho.activity.common.utils.MapUtil.FunctionExPlus; |
24 | import com.yoho.activity.common.utils.PropertiesUtil; | 25 | import com.yoho.activity.common.utils.PropertiesUtil; |
@@ -77,7 +78,7 @@ public class AddVirtualUserTimer { | @@ -77,7 +78,7 @@ public class AddVirtualUserTimer { | ||
77 | //first = new HashMap<Integer, Boolean>(); | 78 | //first = new HashMap<Integer, Boolean>(); |
78 | 79 | ||
79 | //初始化所有活动 | 80 | //初始化所有活动 |
80 | - activityList = drawlineActivityDAO.selectAllActivity(); | 81 | + activityList = drawlineActivityDAO.selectAllActivity(DateUtils.getCurrentTimeSecond()); |
81 | 82 | ||
82 | if (activityList == null || activityList.size() == 0) { | 83 | if (activityList == null || activityList.size() == 0) { |
83 | return; | 84 | return; |
@@ -143,7 +144,8 @@ public class AddVirtualUserTimer { | @@ -143,7 +144,8 @@ public class AddVirtualUserTimer { | ||
143 | } | 144 | } |
144 | 145 | ||
145 | //查询所有的活动,前一分钟内实际增加的真实用户数 | 146 | //查询所有的活动,前一分钟内实际增加的真实用户数 |
146 | - List<Map<String, Object>> realUserCountList = drawlineUserQueueDAO.selectRealUserCountByActivityIds(StringUtils.join(activityIdList, ",")); | 147 | + int currTime = DateUtils.getCurrentTimeSecond(); |
148 | + List<Map<String, Object>> realUserCountList = drawlineUserQueueDAO.selectRealUserCountByActivityIds(StringUtils.join(activityIdList, ","), currTime - 60, currTime); | ||
147 | if (realUserCountList == null) { | 149 | if (realUserCountList == null) { |
148 | realUserCountList = new ArrayList<Map<String,Object>>(); | 150 | realUserCountList = new ArrayList<Map<String,Object>>(); |
149 | } | 151 | } |
-
Please register or login to post a comment