|
@@ -23,9 +23,11 @@ import com.yoho.activity.common.utils.MapUtil; |
|
@@ -23,9 +23,11 @@ import com.yoho.activity.common.utils.MapUtil; |
23
|
import com.yoho.activity.common.utils.MapUtil.FunctionExPlus;
|
23
|
import com.yoho.activity.common.utils.MapUtil.FunctionExPlus;
|
24
|
import com.yoho.activity.common.utils.PropertiesUtil;
|
24
|
import com.yoho.activity.common.utils.PropertiesUtil;
|
25
|
import com.yoho.queue.dal.IDrawlineActivityDAO;
|
25
|
import com.yoho.queue.dal.IDrawlineActivityDAO;
|
|
|
26
|
+import com.yoho.queue.dal.IDrawlinePrizeSettingDAO;
|
26
|
import com.yoho.queue.dal.IDrawlineUserQueueDAO;
|
27
|
import com.yoho.queue.dal.IDrawlineUserQueueDAO;
|
27
|
import com.yoho.queue.dal.IDrawlineVirtualUserDAO;
|
28
|
import com.yoho.queue.dal.IDrawlineVirtualUserDAO;
|
28
|
import com.yoho.queue.dal.model.DrawlineActivity;
|
29
|
import com.yoho.queue.dal.model.DrawlineActivity;
|
|
|
30
|
+import com.yoho.queue.dal.model.DrawlinePrizeSetting;
|
29
|
import com.yoho.queue.dal.model.DrawlineUserQueue;
|
31
|
import com.yoho.queue.dal.model.DrawlineUserQueue;
|
30
|
import com.yoho.queue.dal.model.DrawlineVirtualUser;
|
32
|
import com.yoho.queue.dal.model.DrawlineVirtualUser;
|
31
|
|
33
|
|
|
@@ -49,6 +51,8 @@ public class AddVirtualUserTimer { |
|
@@ -49,6 +51,8 @@ public class AddVirtualUserTimer { |
49
|
IDrawlineActivityDAO drawlineActivityDAO;
|
51
|
IDrawlineActivityDAO drawlineActivityDAO;
|
50
|
@Resource
|
52
|
@Resource
|
51
|
IDrawlineUserQueueDAO drawlineUserQueueDAO;
|
53
|
IDrawlineUserQueueDAO drawlineUserQueueDAO;
|
|
|
54
|
+ @Resource
|
|
|
55
|
+ IDrawlinePrizeSettingDAO drawlinePrizeSettingDAO;
|
52
|
|
56
|
|
53
|
//各个活动下,待进入排队的马甲
|
57
|
//各个活动下,待进入排队的马甲
|
54
|
Map<Integer, List<DrawlineVirtualUser>> waitAddUserMap = new HashMap<Integer, List<DrawlineVirtualUser>>();
|
58
|
Map<Integer, List<DrawlineVirtualUser>> waitAddUserMap = new HashMap<Integer, List<DrawlineVirtualUser>>();
|
|
@@ -83,7 +87,7 @@ public class AddVirtualUserTimer { |
|
@@ -83,7 +87,7 @@ public class AddVirtualUserTimer { |
83
|
activityIdList.add(activity.getId());
|
87
|
activityIdList.add(activity.getId());
|
84
|
}
|
88
|
}
|
85
|
//查询这些活动下,已经进入排队的马甲
|
89
|
//查询这些活动下,已经进入排队的马甲
|
86
|
- List<DrawlineUserQueue> queueList = drawlineUserQueueDAO.selectByTypeAndActivityIds(StringUtils.join(activityIdList, ","));
|
90
|
+ List<DrawlineUserQueue> queueList = drawlineUserQueueDAO.selectByTypeAndActivityIds(StringUtils.join(activityIdList, ","), UserTypeEnum.VIRTUAL_USER.getValue());
|
87
|
|
91
|
|
88
|
//初始化所有的马甲用户
|
92
|
//初始化所有的马甲用户
|
89
|
List<DrawlineVirtualUser> userList = drawlineVirtualUserDAO.selectWaitQueueVirtualUser();
|
93
|
List<DrawlineVirtualUser> userList = drawlineVirtualUserDAO.selectWaitQueueVirtualUser();
|
|
@@ -128,6 +132,10 @@ public class AddVirtualUserTimer { |
|
@@ -128,6 +132,10 @@ public class AddVirtualUserTimer { |
128
|
log.info("activityList is empty over");
|
132
|
log.info("activityList is empty over");
|
129
|
return;
|
133
|
return;
|
130
|
}
|
134
|
}
|
|
|
135
|
+
|
|
|
136
|
+ //添加白名单
|
|
|
137
|
+ addWhiteUser();
|
|
|
138
|
+
|
131
|
//马甲全部排队完了,直接退出
|
139
|
//马甲全部排队完了,直接退出
|
132
|
if (!checkVirtual()) {
|
140
|
if (!checkVirtual()) {
|
133
|
log.info("wait virtual is empty over");
|
141
|
log.info("wait virtual is empty over");
|
|
@@ -204,6 +212,87 @@ public class AddVirtualUserTimer { |
|
@@ -204,6 +212,87 @@ public class AddVirtualUserTimer { |
204
|
}
|
212
|
}
|
205
|
|
213
|
|
206
|
/**
|
214
|
/**
|
|
|
215
|
+ * 添加白名单
|
|
|
216
|
+ */
|
|
|
217
|
+ private void addWhiteUser() {
|
|
|
218
|
+ // 查询所有的奖品设置
|
|
|
219
|
+ List<DrawlinePrizeSetting> prizeList = drawlinePrizeSettingDAO.selectByActivityIds(StringUtils.join(activityIdList, ","));
|
|
|
220
|
+ if (prizeList == null || prizeList.size() == 0) {
|
|
|
221
|
+ log.info("addWhiteUser prize is empty");
|
|
|
222
|
+ return;
|
|
|
223
|
+ }
|
|
|
224
|
+
|
|
|
225
|
+ // list 转 map
|
|
|
226
|
+ Map<Integer, String> whileMap = null;
|
|
|
227
|
+ if (prizeList != null) {
|
|
|
228
|
+ whileMap = MapUtil.transformListMap(prizeList, new FunctionExPlus<DrawlinePrizeSetting, Integer, String>() {
|
|
|
229
|
+
|
|
|
230
|
+ @Override
|
|
|
231
|
+ public Integer applyKey(DrawlinePrizeSetting input) {
|
|
|
232
|
+ return input.getActivityId();
|
|
|
233
|
+ }
|
|
|
234
|
+
|
|
|
235
|
+ @Override
|
|
|
236
|
+ public String applyValue(DrawlinePrizeSetting input) {
|
|
|
237
|
+ return input.getWhiteList();
|
|
|
238
|
+ }
|
|
|
239
|
+ });
|
|
|
240
|
+ }
|
|
|
241
|
+
|
|
|
242
|
+ // 查询所有排队的真实用户
|
|
|
243
|
+ List<DrawlineUserQueue> queueList = drawlineUserQueueDAO.selectByTypeAndActivityIds(StringUtils.join(activityIdList, ","), UserTypeEnum.REAL_USER.getValue());
|
|
|
244
|
+
|
|
|
245
|
+ String[] whileArr = null;
|
|
|
246
|
+ String whiteStr = "";
|
|
|
247
|
+ DrawlineUserQueue queueUser = null;
|
|
|
248
|
+ for (DrawlineActivity activity : activityList) {
|
|
|
249
|
+ whiteStr = whileMap.get(activity.getId());
|
|
|
250
|
+ if (StringUtils.isEmpty(whiteStr)) {
|
|
|
251
|
+ continue;
|
|
|
252
|
+ }
|
|
|
253
|
+ whileArr = whiteStr.split(",");
|
|
|
254
|
+ for (String white : whileArr) {
|
|
|
255
|
+ if (whiteIsExists(queueList, activity.getId().intValue(), Integer.parseInt(white))) {
|
|
|
256
|
+ log.debug("white user={} is queue in activityId={} exit", white, activity.getId());
|
|
|
257
|
+ continue;
|
|
|
258
|
+ }
|
|
|
259
|
+ //该白名单没有排队过,则进入排队
|
|
|
260
|
+ queueUser = new DrawlineUserQueue();
|
|
|
261
|
+ queueUser.setActivityId(activity.getId());
|
|
|
262
|
+ queueUser.setUid(Integer.parseInt(white));
|
|
|
263
|
+ queueUser.setUserType((byte) UserTypeEnum.REAL_USER.getValue());
|
|
|
264
|
+ queueUser.setStatus((byte) 1);
|
|
|
265
|
+ //插入排队表
|
|
|
266
|
+ drawlineUserQueueDAO.insertAutoSort(queueUser);
|
|
|
267
|
+ //一次只插入一条白名单
|
|
|
268
|
+ break;
|
|
|
269
|
+ }
|
|
|
270
|
+ }
|
|
|
271
|
+ }
|
|
|
272
|
+
|
|
|
273
|
+ /**
|
|
|
274
|
+ * 判断该白名单是否已经排队过
|
|
|
275
|
+ * @param queueList
|
|
|
276
|
+ * @param activityId
|
|
|
277
|
+ * @param whiteUid
|
|
|
278
|
+ * @return
|
|
|
279
|
+ */
|
|
|
280
|
+ private boolean whiteIsExists(List<DrawlineUserQueue> queueList, int activityId, int whiteUid) {
|
|
|
281
|
+ if (queueList == null || queueList.size() == 0) {
|
|
|
282
|
+ return false;
|
|
|
283
|
+ }
|
|
|
284
|
+ for (DrawlineUserQueue queue : queueList) {
|
|
|
285
|
+ if (queue.getActivityId() == null || queue.getUid() == null) {
|
|
|
286
|
+ continue;
|
|
|
287
|
+ }
|
|
|
288
|
+ if (queue.getActivityId().intValue() == activityId && queue.getUid().intValue() == whiteUid) {
|
|
|
289
|
+ return true;
|
|
|
290
|
+ }
|
|
|
291
|
+ }
|
|
|
292
|
+ return false;
|
|
|
293
|
+ }
|
|
|
294
|
+
|
|
|
295
|
+ /**
|
207
|
* 检查是否还有剩余的马甲
|
296
|
* 检查是否还有剩余的马甲
|
208
|
* @return
|
297
|
* @return
|
209
|
*/
|
298
|
*/
|