|
|
@ -599,7 +599,8 @@ public class ScreenService implements IScreenService { |
|
|
|
/** |
|
|
|
* 进行中查询每个组的信息 |
|
|
|
*/ |
|
|
|
private List<ScreenVo.GroupVo> getGroupScore2(GameRecord gameRecord) { |
|
|
|
@Override |
|
|
|
public List<ScreenVo.GroupVo> getGroupScore2(GameRecord gameRecord) { |
|
|
|
String groupKey = gameRecord.getId() + "_group"; |
|
|
|
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtil.zsRevGetWithScore(groupKey, 0, -1); |
|
|
|
if(CollectionUtil.isNotEmpty(typedTuples)){ |
|
|
@ -616,7 +617,8 @@ public class ScreenService implements IScreenService { |
|
|
|
o = 0; |
|
|
|
} |
|
|
|
groupVo.setTotalMembers((int)o); |
|
|
|
|
|
|
|
groupVo.setTotalScore(score); |
|
|
|
groupVo.setTotalTimes(score / 100); |
|
|
|
if(gameRecord.getRankRule() == GameConstant.RANK_RULE_AVA){ |
|
|
|
groupVo.setScore((int)o == 0 ? 0 : score / (int)o); |
|
|
|
groupVo.setTimes(groupVo.getScore() /100); |
|
|
@ -637,6 +639,10 @@ public class ScreenService implements IScreenService { |
|
|
|
return vos; |
|
|
|
} |
|
|
|
List<ScreenVo.GroupVo> vos = gameGroupDao.queryGroups(gameRecord.getId()); |
|
|
|
vos.forEach(vo ->{ |
|
|
|
vo.setTotalScore(vo.getScore()); |
|
|
|
vo.setTotalTimes(vo.getScore() == null ? 0 : vo.getScore() / 100); |
|
|
|
}); |
|
|
|
if (CollectionUtil.isEmpty(vos) || gameRecord.getRankRule() == GameConstant.RANK_RULE_TOTAL) { |
|
|
|
return vos; |
|
|
|
} |
|
|
@ -1433,4 +1439,71 @@ public class ScreenService implements IScreenService { |
|
|
|
return wpsPath; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 手机端再玩一次 |
|
|
|
* @param params 游戏类型 |
|
|
|
* @return 返回游戏id |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Long startAgainByPhone(QueryDto<ScreenDto.StartAgainByPhone> params) { |
|
|
|
log.info("手机端再玩一次:{}",params); |
|
|
|
ScreenDto.StartAgainByPhone startAgainByPhone = params.getParam(); |
|
|
|
Long userId = params.getUserId(); |
|
|
|
|
|
|
|
//查找游戏
|
|
|
|
GameTypeExample gameTypeExample = new GameTypeExample(); |
|
|
|
gameTypeExample.createCriteria().andCodeEqualTo(startAgainByPhone.getGameType()); |
|
|
|
List<GameType> gameTypeList = gameTypeDao.selectByExample(gameTypeExample); |
|
|
|
if (CollectionUtil.isEmpty(gameTypeList)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_GAME_TYPE); |
|
|
|
} |
|
|
|
GameType gameType = gameTypeList.get(0); |
|
|
|
log.info("查找游戏类型:{}",gameType); |
|
|
|
//2、查找此用户购买的此游戏的信息,若没有则添加一条记录,默认已付款,结束时间为添加后的一个月,默认次数为10次
|
|
|
|
GameUserPay gameUserPay = getGameUserPay(userId, gameType); |
|
|
|
|
|
|
|
//3、根据用户购买的记录,添加一场新的游戏记录
|
|
|
|
GameRecord gameRecord = new GameRecord(); |
|
|
|
gameRecord.setId(snowflake.nextId()); |
|
|
|
gameRecord.setUserPayId(gameUserPay.getId()); |
|
|
|
gameRecord.setGameGroup((byte) 0); |
|
|
|
//添加路径
|
|
|
|
String gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_SQ; |
|
|
|
switch (gameType.getCode()){ |
|
|
|
case GameConstant.GAME_TYPE_SQ: break; |
|
|
|
case GameConstant.GAME_TYPE_SP: gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_SP; break; |
|
|
|
case GameConstant.GAME_TYPE_BH: gameUrl = PropUtil.notGatewayUrl + WebConstant.TEST_URL_GAME_BH; break; |
|
|
|
default:break; |
|
|
|
} |
|
|
|
gameRecord.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecord.getId()); |
|
|
|
gameRecordDao.insertSelective(gameRecord); |
|
|
|
|
|
|
|
log.info("添加游戏记录:{}",gameRecord); |
|
|
|
//配置表不存在,而且游戏类型默认为分组游戏,默认添加两个分组
|
|
|
|
if (gameType.getIsGroup() == 1) { |
|
|
|
GameGroup gameGroupRed = new GameGroup(); |
|
|
|
gameGroupRed.setId(snowflake.nextId()); |
|
|
|
gameGroupRed.setRecordId(gameRecord.getId()); |
|
|
|
gameGroupRed.setName("红队"); |
|
|
|
gameGroupRed.setCode(GameConstant.FIRST_GROUP); |
|
|
|
gameGroupDao.insertSelective(gameGroupRed); |
|
|
|
GameGroup gameGroupBlue = new GameGroup(); |
|
|
|
gameGroupBlue.setId(snowflake.nextId()); |
|
|
|
gameGroupBlue.setRecordId(gameRecord.getId()); |
|
|
|
gameGroupBlue.setName("蓝队"); |
|
|
|
gameGroupBlue.setCode(GameConstant.SECOND_GROUP); |
|
|
|
gameGroupDao.insertSelective(gameGroupBlue); |
|
|
|
} |
|
|
|
|
|
|
|
//5、查询该游戏的规则
|
|
|
|
List<String> ruleList = getGameActivityRule(gameType.getId()); |
|
|
|
//6、返回
|
|
|
|
ScreenVo.UrlVo urlVo = new ScreenVo.UrlVo(); |
|
|
|
urlVo.setId(gameRecord.getId()); |
|
|
|
urlVo.setUrl(gameRecord.getUrl()); |
|
|
|
urlVo.setRuleList(ruleList); |
|
|
|
|
|
|
|
return gameRecord.getId(); |
|
|
|
} |
|
|
|
} |
|
|
|