|
|
@ -30,6 +30,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.websocket.OnClose; |
|
|
|
import java.io.File; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
@ -50,6 +51,8 @@ public class ScreenService implements IScreenService{ |
|
|
|
@Autowired |
|
|
|
private GameGroupDao gameGroupDao; |
|
|
|
@Autowired |
|
|
|
private GameUserJoinGroupDao gameUserJoinGroupDao; |
|
|
|
@Autowired |
|
|
|
private GameActivityRuleDao activityRuleDao; |
|
|
|
@Autowired |
|
|
|
private GameActivityPrizeDao activityPrizeDao; |
|
|
@ -232,7 +235,14 @@ public class ScreenService implements IScreenService{ |
|
|
|
case 2: |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
ScreenVo.CompletedData completedData = getCompletedData(memberRecord.getMemberRecord()); |
|
|
|
//查询游戏是否有分组
|
|
|
|
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId()); |
|
|
|
ScreenVo.CompletedData completedData = null; |
|
|
|
if(gameType.getIsGroup() == 0) { |
|
|
|
completedData = getCompletedData(memberRecord.getMemberRecord()); |
|
|
|
}else { |
|
|
|
completedData = getCompletedDataByWin(memberRecord.getMemberRecord()); |
|
|
|
} |
|
|
|
gameInfoVo.setCompletedData(completedData); |
|
|
|
break; |
|
|
|
default: |
|
|
@ -253,6 +263,9 @@ public class ScreenService implements IScreenService{ |
|
|
|
long gameRecordId = memberRecord.getMemberRecord(); |
|
|
|
|
|
|
|
GameRecord gameRecord = getGameRecord(gameRecordId); |
|
|
|
//获取游戏的购买记录和类型
|
|
|
|
GameUserPay gameUserPay = gameUserPayDao.selectByPrimaryKey(gameRecord.getUserPayId()); |
|
|
|
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId()); |
|
|
|
|
|
|
|
gameStatusVo.setGameStatus(gameRecord.getGameStatus()); |
|
|
|
|
|
|
@ -283,14 +296,27 @@ public class ScreenService implements IScreenService{ |
|
|
|
gameStatusVo.setPreparingData(preparingData); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
ScreenVo.ProcessingData processingData = new ScreenVo.ProcessingData(); |
|
|
|
// 查询前十名(列表顺序即前十名顺序)
|
|
|
|
List<ScreenVo.TopUsers> tops = getTopUsers(gameRecordId); |
|
|
|
processingData.setTopMembers(tops); |
|
|
|
gameStatusVo.setProcessingData(processingData); |
|
|
|
//查询游戏是否有分组
|
|
|
|
if(gameType.getIsGroup() == 0) { |
|
|
|
//普通游戏返回前十名的信息
|
|
|
|
ScreenVo.ProcessingData processingData = new ScreenVo.ProcessingData(); |
|
|
|
// 查询前十名(列表顺序即前十名顺序)
|
|
|
|
List<ScreenVo.TopUsers> tops = getTopUsers(gameRecordId); |
|
|
|
processingData.setTopMembers(tops); |
|
|
|
gameStatusVo.setProcessingData(processingData); |
|
|
|
}else { |
|
|
|
//分组游戏则返回每个分组的信息
|
|
|
|
List<ScreenVo.GroupVo> groupVoList = getGroupScore(gameRecordId); |
|
|
|
gameStatusVo.setProcessingData(groupVoList); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
ScreenVo.CompletedData completedData = getCompletedData(gameRecordId); |
|
|
|
ScreenVo.CompletedData completedData = null; |
|
|
|
if(gameType.getIsGroup() == 0) { |
|
|
|
completedData = getCompletedData(memberRecord.getMemberRecord()); |
|
|
|
}else { |
|
|
|
completedData = getCompletedDataByWin(memberRecord.getMemberRecord()); |
|
|
|
} |
|
|
|
gameStatusVo.setCompletedData(completedData); |
|
|
|
break; |
|
|
|
default: |
|
|
@ -299,11 +325,36 @@ public class ScreenService implements IScreenService{ |
|
|
|
return gameStatusVo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 进行中查询每个组的信息 |
|
|
|
*/ |
|
|
|
private List<ScreenVo.GroupVo> getGroupScore(Long gameRecordId){ |
|
|
|
List<ScreenVo.GroupVo> groupVoList = new ArrayList<>(); |
|
|
|
//查询分组信息
|
|
|
|
GameGroupExample gameGroupExample = new GameGroupExample(); |
|
|
|
gameGroupExample.createCriteria().andRecordIdEqualTo(gameRecordId); |
|
|
|
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample); |
|
|
|
if(CollectionUtil.isNotEmpty(gameGroupList)){ |
|
|
|
for(GameGroup gameGroup : gameGroupList){ |
|
|
|
Map<String,Object> group = getGroupTotalScore(gameGroup.getId()); |
|
|
|
List<GameUserJoin> userJoinList = (List<GameUserJoin>) group.get("userJoinList"); |
|
|
|
ScreenVo.GroupVo groupVo = new ScreenVo.GroupVo(); |
|
|
|
groupVo.setGroupId(gameGroup.getId()); |
|
|
|
groupVo.setGroupName(gameGroup.getName()); |
|
|
|
groupVo.setScore((Integer) group.get("totalScore")); |
|
|
|
groupVo.setTotalMembers(userJoinList.size()); |
|
|
|
groupVoList.add(groupVo); |
|
|
|
} |
|
|
|
} |
|
|
|
return groupVoList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 结束时查询胜利组的信息(总分数,总次数,平均以及前十名) |
|
|
|
*/ |
|
|
|
private ScreenVo.CompletedData getCompletedDataByWin(Long gameRecordId) { |
|
|
|
//1、分别查询redis内每个队伍的总分,
|
|
|
|
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData(); |
|
|
|
//TODO 1、分别查询redis内每个队伍的总分,
|
|
|
|
//2、查询获胜队伍的信息
|
|
|
|
|
|
|
|
//3、redis内没有则查询数据库
|
|
|
@ -312,15 +363,50 @@ public class ScreenService implements IScreenService{ |
|
|
|
gameGroupExample.createCriteria().andRecordIdEqualTo(gameRecordId); |
|
|
|
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample); |
|
|
|
if(CollectionUtil.isNotEmpty(gameGroupList)){ |
|
|
|
List<GameUserJoin> userJoinList = null; |
|
|
|
//分别查找两个队伍的总分
|
|
|
|
|
|
|
|
Map<String,Object> group1 = getGroupTotalScore(gameGroupList.get(0).getId()); |
|
|
|
Map<String,Object> group2 = getGroupTotalScore(gameGroupList.get(1).getId()); |
|
|
|
if(CollectionUtil.isNotEmpty(group1) && CollectionUtil.isNotEmpty(group2)){ |
|
|
|
int score1 = (int) group1.get("totalScore"); |
|
|
|
int score2 = (int) group1.get("totalScore"); |
|
|
|
if(score1 > score2){ |
|
|
|
userJoinList = (List<GameUserJoin>) group1.get("userJoinList"); |
|
|
|
}else { |
|
|
|
userJoinList = (List<GameUserJoin>) group2.get("userJoinList"); |
|
|
|
} |
|
|
|
} |
|
|
|
//5、获取获胜队伍的信息
|
|
|
|
completedData = getCompletedData(userJoinList); |
|
|
|
} |
|
|
|
|
|
|
|
//4、分别查询每个队伍的总分
|
|
|
|
//5、获取获胜队伍的信息
|
|
|
|
return null; |
|
|
|
return completedData; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 获取队伍的总分 |
|
|
|
*/ |
|
|
|
private Map<String,Object> getGroupTotalScore(Long groupId){ |
|
|
|
Map<String,Object> groupMap = null; |
|
|
|
|
|
|
|
//查找队伍的参赛人
|
|
|
|
GameUserJoinGroupExample joinGroupExample = new GameUserJoinGroupExample(); |
|
|
|
joinGroupExample.createCriteria().andGameGroupIdEqualTo(groupId); |
|
|
|
List<GameUserJoinGroup> userJoinGroupList = gameUserJoinGroupDao.selectByExample(joinGroupExample); |
|
|
|
if(CollectionUtil.isNotEmpty(userJoinGroupList)){ |
|
|
|
groupMap = new HashMap<>(); |
|
|
|
int totalScore = 0; |
|
|
|
List<GameUserJoin> userJoinList = new ArrayList<>(); |
|
|
|
for (GameUserJoinGroup userJoinGroup : userJoinGroupList){ |
|
|
|
GameUserJoin userJoin = gameUserJoinDao.selectByPrimaryKey(userJoinGroup.getUserJoinId()); |
|
|
|
totalScore += userJoin.getScore(); |
|
|
|
userJoinList.add(userJoin); |
|
|
|
} |
|
|
|
groupMap.put("totalScore",totalScore); |
|
|
|
groupMap.put("userJoinList",userJoinList); |
|
|
|
} |
|
|
|
return groupMap; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询总分数,总次数,平均以及前十名 |
|
|
|
* @param gameRecordId |
|
|
@ -492,14 +578,18 @@ public class ScreenService implements IScreenService{ |
|
|
|
/** |
|
|
|
* 查找活动规则 |
|
|
|
*/ |
|
|
|
private List<String> getGameActivityRule(Long gameTypeId){ |
|
|
|
@Override |
|
|
|
public List<String> getGameActivityRule(Long gameTypeId){ |
|
|
|
List<String> ruleList = new ArrayList<>(); |
|
|
|
GameActivityRuleExample activityRuleExample = new GameActivityRuleExample(); |
|
|
|
activityRuleExample.createCriteria().andGameIdEqualTo(gameTypeId); |
|
|
|
List<GameActivityRule> gameActivityRuleList = activityRuleDao.selectByExample(activityRuleExample); |
|
|
|
if(CollectionUtil.isNotEmpty(gameActivityRuleList)){ |
|
|
|
for(GameActivityRule rule : gameActivityRuleList){ |
|
|
|
ruleList.add(rule.getDescription()); |
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(gameTypeId)) { |
|
|
|
GameActivityRuleExample activityRuleExample = new GameActivityRuleExample(); |
|
|
|
activityRuleExample.createCriteria().andGameIdEqualTo(gameTypeId); |
|
|
|
List<GameActivityRule> gameActivityRuleList = activityRuleDao.selectByExample(activityRuleExample); |
|
|
|
if (CollectionUtil.isNotEmpty(gameActivityRuleList)) { |
|
|
|
for (GameActivityRule rule : gameActivityRuleList) { |
|
|
|
ruleList.add(rule.getDescription()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return ruleList; |
|
|
@ -507,14 +597,18 @@ public class ScreenService implements IScreenService{ |
|
|
|
/** |
|
|
|
* 查询活动奖品 |
|
|
|
*/ |
|
|
|
private List<String> getGameActivityPrize(Long gameTypeId){ |
|
|
|
@Override |
|
|
|
public List<String> getGameActivityPrize(Long gameTypeId){ |
|
|
|
List<String> prizeList = new ArrayList<>(); |
|
|
|
GameActivityPrizeExample activityPrizeExample = new GameActivityPrizeExample(); |
|
|
|
activityPrizeExample.createCriteria().andGameIdEqualTo(gameTypeId); |
|
|
|
List<GameActivityPrize> gameActivityPrizeList = activityPrizeDao.selectByExample(activityPrizeExample); |
|
|
|
if(CollectionUtil.isNotEmpty(gameActivityPrizeList)){ |
|
|
|
for(GameActivityPrize prize : gameActivityPrizeList){ |
|
|
|
prizeList.add(prize.getDescription()); |
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(gameTypeId)) { |
|
|
|
GameActivityPrizeExample activityPrizeExample = new GameActivityPrizeExample(); |
|
|
|
activityPrizeExample.createCriteria().andGameIdEqualTo(gameTypeId); |
|
|
|
List<GameActivityPrize> gameActivityPrizeList = activityPrizeDao.selectByExample(activityPrizeExample); |
|
|
|
if (CollectionUtil.isNotEmpty(gameActivityPrizeList)) { |
|
|
|
for (GameActivityPrize prize : gameActivityPrizeList) { |
|
|
|
prizeList.add(prize.getDescription()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return prizeList; |
|
|
@ -522,14 +616,18 @@ public class ScreenService implements IScreenService{ |
|
|
|
/** |
|
|
|
* 奖券使用说明表 |
|
|
|
*/ |
|
|
|
private List<String> getGamePrizeInstructions(Long gameTypeId){ |
|
|
|
@Override |
|
|
|
public List<String> getGamePrizeInstructions(Long gameTypeId){ |
|
|
|
List<String> instructionsList = new ArrayList<>(); |
|
|
|
GamePrizeInstructionsExample prizeInstructionsExample = new GamePrizeInstructionsExample(); |
|
|
|
prizeInstructionsExample.createCriteria().andGameIdEqualTo(gameTypeId); |
|
|
|
List<GamePrizeInstructions> gamePrizeInstructionsList = prizeInstructionsDao.selectByExample(prizeInstructionsExample); |
|
|
|
if(CollectionUtil.isNotEmpty(gamePrizeInstructionsList)){ |
|
|
|
for(GamePrizeInstructions prizeInstructions : gamePrizeInstructionsList){ |
|
|
|
instructionsList.add(prizeInstructions.getDescription()); |
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(gameTypeId)) { |
|
|
|
GamePrizeInstructionsExample prizeInstructionsExample = new GamePrizeInstructionsExample(); |
|
|
|
prizeInstructionsExample.createCriteria().andGameIdEqualTo(gameTypeId); |
|
|
|
List<GamePrizeInstructions> gamePrizeInstructionsList = prizeInstructionsDao.selectByExample(prizeInstructionsExample); |
|
|
|
if (CollectionUtil.isNotEmpty(gamePrizeInstructionsList)) { |
|
|
|
for (GamePrizeInstructions prizeInstructions : gamePrizeInstructionsList) { |
|
|
|
instructionsList.add(prizeInstructions.getDescription()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return instructionsList; |
|
|
@ -704,5 +802,23 @@ public class ScreenService implements IScreenService{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询游戏类型id |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Long getGameTypeId(Long recordId){ |
|
|
|
Long gameTypeId = null; |
|
|
|
GameRecord gameRecord = gameRecordDao.selectByPrimaryKey(recordId); |
|
|
|
if(ObjectUtil.isNotNull(gameRecord)){ |
|
|
|
//获取游戏的购买记录和类型
|
|
|
|
GameUserPay gameUserPay = gameUserPayDao.selectByPrimaryKey(gameRecord.getUserPayId()); |
|
|
|
if(ObjectUtil.isNotNull(gameUserPay)) { |
|
|
|
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId()); |
|
|
|
if(ObjectUtil.isNotNull(gameType)){ |
|
|
|
gameTypeId = gameType.getId(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return gameTypeId; |
|
|
|
} |
|
|
|
} |
|
|
|