...
|
...
|
@@ -23,9 +23,11 @@ import com.yoho.activity.common.utils.MapUtil; |
|
|
import com.yoho.activity.common.utils.MapUtil.FunctionExPlus;
|
|
|
import com.yoho.activity.common.utils.PropertiesUtil;
|
|
|
import com.yoho.queue.dal.IDrawlineActivityDAO;
|
|
|
import com.yoho.queue.dal.IDrawlinePrizeSettingDAO;
|
|
|
import com.yoho.queue.dal.IDrawlineUserQueueDAO;
|
|
|
import com.yoho.queue.dal.IDrawlineVirtualUserDAO;
|
|
|
import com.yoho.queue.dal.model.DrawlineActivity;
|
|
|
import com.yoho.queue.dal.model.DrawlinePrizeSetting;
|
|
|
import com.yoho.queue.dal.model.DrawlineUserQueue;
|
|
|
import com.yoho.queue.dal.model.DrawlineVirtualUser;
|
|
|
|
...
|
...
|
@@ -49,6 +51,8 @@ public class AddVirtualUserTimer { |
|
|
IDrawlineActivityDAO drawlineActivityDAO;
|
|
|
@Resource
|
|
|
IDrawlineUserQueueDAO drawlineUserQueueDAO;
|
|
|
@Resource
|
|
|
IDrawlinePrizeSettingDAO drawlinePrizeSettingDAO;
|
|
|
|
|
|
//各个活动下,待进入排队的马甲
|
|
|
Map<Integer, List<DrawlineVirtualUser>> waitAddUserMap = new HashMap<Integer, List<DrawlineVirtualUser>>();
|
...
|
...
|
@@ -83,7 +87,7 @@ public class AddVirtualUserTimer { |
|
|
activityIdList.add(activity.getId());
|
|
|
}
|
|
|
//查询这些活动下,已经进入排队的马甲
|
|
|
List<DrawlineUserQueue> queueList = drawlineUserQueueDAO.selectByTypeAndActivityIds(StringUtils.join(activityIdList, ","));
|
|
|
List<DrawlineUserQueue> queueList = drawlineUserQueueDAO.selectByTypeAndActivityIds(StringUtils.join(activityIdList, ","), UserTypeEnum.VIRTUAL_USER.getValue());
|
|
|
|
|
|
//初始化所有的马甲用户
|
|
|
List<DrawlineVirtualUser> userList = drawlineVirtualUserDAO.selectWaitQueueVirtualUser();
|
...
|
...
|
@@ -128,6 +132,10 @@ public class AddVirtualUserTimer { |
|
|
log.info("activityList is empty over");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//添加白名单
|
|
|
addWhiteUser();
|
|
|
|
|
|
//马甲全部排队完了,直接退出
|
|
|
if (!checkVirtual()) {
|
|
|
log.info("wait virtual is empty over");
|
...
|
...
|
@@ -204,6 +212,87 @@ public class AddVirtualUserTimer { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加白名单
|
|
|
*/
|
|
|
private void addWhiteUser() {
|
|
|
// 查询所有的奖品设置
|
|
|
List<DrawlinePrizeSetting> prizeList = drawlinePrizeSettingDAO.selectByActivityIds(StringUtils.join(activityIdList, ","));
|
|
|
if (prizeList == null || prizeList.size() == 0) {
|
|
|
log.info("addWhiteUser prize is empty");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// list 转 map
|
|
|
Map<Integer, String> whileMap = null;
|
|
|
if (prizeList != null) {
|
|
|
whileMap = MapUtil.transformListMap(prizeList, new FunctionExPlus<DrawlinePrizeSetting, Integer, String>() {
|
|
|
|
|
|
@Override
|
|
|
public Integer applyKey(DrawlinePrizeSetting input) {
|
|
|
return input.getActivityId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String applyValue(DrawlinePrizeSetting input) {
|
|
|
return input.getWhiteList();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 查询所有排队的真实用户
|
|
|
List<DrawlineUserQueue> queueList = drawlineUserQueueDAO.selectByTypeAndActivityIds(StringUtils.join(activityIdList, ","), UserTypeEnum.REAL_USER.getValue());
|
|
|
|
|
|
String[] whileArr = null;
|
|
|
String whiteStr = "";
|
|
|
DrawlineUserQueue queueUser = null;
|
|
|
for (DrawlineActivity activity : activityList) {
|
|
|
whiteStr = whileMap.get(activity.getId());
|
|
|
if (StringUtils.isEmpty(whiteStr)) {
|
|
|
continue;
|
|
|
}
|
|
|
whileArr = whiteStr.split(",");
|
|
|
for (String white : whileArr) {
|
|
|
if (whiteIsExists(queueList, activity.getId().intValue(), Integer.parseInt(white))) {
|
|
|
log.debug("white user={} is queue in activityId={} exit", white, activity.getId());
|
|
|
continue;
|
|
|
}
|
|
|
//该白名单没有排队过,则进入排队
|
|
|
queueUser = new DrawlineUserQueue();
|
|
|
queueUser.setActivityId(activity.getId());
|
|
|
queueUser.setUid(Integer.parseInt(white));
|
|
|
queueUser.setUserType((byte) UserTypeEnum.REAL_USER.getValue());
|
|
|
queueUser.setStatus((byte) 1);
|
|
|
//插入排队表
|
|
|
drawlineUserQueueDAO.insertAutoSort(queueUser);
|
|
|
//一次只插入一条白名单
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断该白名单是否已经排队过
|
|
|
* @param queueList
|
|
|
* @param activityId
|
|
|
* @param whiteUid
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean whiteIsExists(List<DrawlineUserQueue> queueList, int activityId, int whiteUid) {
|
|
|
if (queueList == null || queueList.size() == 0) {
|
|
|
return false;
|
|
|
}
|
|
|
for (DrawlineUserQueue queue : queueList) {
|
|
|
if (queue.getActivityId() == null || queue.getUid() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
if (queue.getActivityId().intValue() == activityId && queue.getUid().intValue() == whiteUid) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 检查是否还有剩余的马甲
|
|
|
* @return
|
|
|
*/
|
...
|
...
|
|