|
|
@ -43,6 +43,8 @@ public class ClientService implements IClientService { |
|
|
|
@Autowired |
|
|
|
private GameUserJoinDao gameUserJoinDao; |
|
|
|
@Autowired |
|
|
|
private GameUserJoinGroupDao gameUserJoinGroupDao; |
|
|
|
@Autowired |
|
|
|
private GameGroupDao gameGroupDao; |
|
|
|
@Autowired |
|
|
|
private GameUserJoinGroupDao userJoinGroupDao; |
|
|
@ -142,7 +144,7 @@ public class ClientService implements IClientService { |
|
|
|
userJoin.setNickname(""); |
|
|
|
} |
|
|
|
gameUserJoinDao.insertSelective(userJoin); |
|
|
|
//如果是分组游戏,则添加用户与组的关联表并添加redis
|
|
|
|
//如果是分组游戏,则添加用户与组的关联表
|
|
|
|
if (isGroup) { |
|
|
|
if (ObjectUtil.isNull(join.getGroupId())) { |
|
|
|
log.info("分组信息为空"); |
|
|
@ -214,6 +216,11 @@ public class ClientService implements IClientService { |
|
|
|
case GameConstant.GAME_COMPLETED: |
|
|
|
//已结束
|
|
|
|
ClientVo.CompletedData completedData = new ClientVo.CompletedData(); |
|
|
|
//如果是分组游戏,获取本组信息
|
|
|
|
if(isGroup){ |
|
|
|
ClientVo.GroupScore groupScore = getGroupScore(groupId,gameRecord.getId()); |
|
|
|
completedData.setGroupScore(groupScore); |
|
|
|
} |
|
|
|
completedData.setTimes(join.getTimes()); |
|
|
|
completedData.setScore(join.getScore()); |
|
|
|
Integer sort = gameUserJoinDao.getRanking(join.getUserId(), gameRecord.getId()); |
|
|
@ -236,9 +243,59 @@ public class ClientService implements IClientService { |
|
|
|
return joinVo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取本组的信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ClientVo.GroupScore getGroupScore(Long groupId,Long recordId){ |
|
|
|
ClientVo.GroupScore groupScore = new ClientVo.GroupScore(); |
|
|
|
|
|
|
|
int otherGroupScore = 0; |
|
|
|
//查找所有队伍
|
|
|
|
GameGroupExample gameGroupExample = new GameGroupExample(); |
|
|
|
gameGroupExample.createCriteria().andRecordIdEqualTo(recordId); |
|
|
|
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample); |
|
|
|
if (CollectionUtil.isNotEmpty(gameGroupList)) { |
|
|
|
for (GameGroup gameGroup : gameGroupList) { |
|
|
|
if (gameGroup.getId().longValue() == groupId) { |
|
|
|
//查找队伍的总分
|
|
|
|
GameUserJoinGroupExample joinGroupExample = new GameUserJoinGroupExample(); |
|
|
|
joinGroupExample.createCriteria().andGameGroupIdEqualTo(groupId); |
|
|
|
List<GameUserJoinGroup> userJoinGroupList = gameUserJoinGroupDao.selectByExample(joinGroupExample); |
|
|
|
if (CollectionUtil.isNotEmpty(userJoinGroupList)) { |
|
|
|
int totalScore = 0; |
|
|
|
int totalTimes = 0; |
|
|
|
for (GameUserJoinGroup userJoinGroup : userJoinGroupList) { |
|
|
|
GameUserJoin userJoin = gameUserJoinDao.selectByPrimaryKey(userJoinGroup.getUserJoinId()); |
|
|
|
totalScore += userJoin.getScore(); |
|
|
|
totalTimes += userJoin.getTimes(); |
|
|
|
} |
|
|
|
groupScore.setGroupTimes(totalTimes); |
|
|
|
groupScore.setGroupScore(totalScore); |
|
|
|
} |
|
|
|
}else { |
|
|
|
GameUserJoinGroupExample joinGroupExample = new GameUserJoinGroupExample(); |
|
|
|
joinGroupExample.createCriteria().andGameGroupIdEqualTo(groupId); |
|
|
|
List<GameUserJoinGroup> userJoinGroupList = gameUserJoinGroupDao.selectByExample(joinGroupExample); |
|
|
|
if (CollectionUtil.isNotEmpty(userJoinGroupList)) { |
|
|
|
for (GameUserJoinGroup userJoinGroup : userJoinGroupList) { |
|
|
|
GameUserJoin userJoin = gameUserJoinDao.selectByPrimaryKey(userJoinGroup.getUserJoinId()); |
|
|
|
otherGroupScore += userJoin.getScore(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(groupScore.getGroupScore() >= otherGroupScore){ |
|
|
|
groupScore.setGroupSort(1); |
|
|
|
}else { |
|
|
|
groupScore.setGroupSort(2); |
|
|
|
} |
|
|
|
return groupScore; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置状态和总人数 |
|
|
|
* |
|
|
|
* @param gameRecord |
|
|
|
*/ |
|
|
|
private ClientVo.Join initStatusAndCount(GameRecord gameRecord) { |
|
|
|