|
|
@ -8,14 +8,16 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.ccsens.cloudutil.bean.tall.vo.MemberVo; |
|
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
|
import com.ccsens.game.bean.dto.ClientDto; |
|
|
|
import com.ccsens.game.bean.dto.message.*; |
|
|
|
import com.ccsens.game.bean.dto.message.GameMessageCountOut; |
|
|
|
import com.ccsens.game.bean.po.*; |
|
|
|
import com.ccsens.game.bean.vo.ClientVo; |
|
|
|
import com.ccsens.game.bean.vo.ScreenVo; |
|
|
|
import com.ccsens.game.persist.dao.*; |
|
|
|
import com.ccsens.game.util.GameConstant; |
|
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
import com.ccsens.util.JsonResponse; |
|
|
|
import com.ccsens.util.RedisUtil; |
|
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
@ -24,10 +26,12 @@ import org.springframework.data.redis.core.ZSetOperations; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 游戏客户端接口 |
|
|
@ -139,11 +143,13 @@ public class ClientService implements IClientService { |
|
|
|
userJoin.setLocalStartTime(prepare || processing ? gameRecord.getStartTime() + timeMore : 0); |
|
|
|
userJoin.setLocalEndTime(prepare || processing ? gameRecord.getEndTime() + timeMore : 0); |
|
|
|
// 获取头像和用户名
|
|
|
|
JsonResponse<MemberVo.MemberInfo> memberInfo = tallFeignClient.getMemberInfoByUserIdAndTaskId(userId, gameRecord.getTaskId()); |
|
|
|
if (memberInfo.getData() == null) { |
|
|
|
memberInfo = tallFeignClient.getUserByUserId(userId); |
|
|
|
} |
|
|
|
if (memberInfo.getCode().intValue() == CodeEnum.SUCCESS.getCode().intValue() && memberInfo.getData() != null) { |
|
|
|
// JsonResponse<MemberVo.MemberInfo> memberInfo = tallFeignClient.getMemberInfoByUserIdAndTaskId(userId, gameRecord.getTaskId());
|
|
|
|
// if (memberInfo.getData() == null) {
|
|
|
|
// memberInfo = tallFeignClient.getUserByUserId(userId);
|
|
|
|
// }
|
|
|
|
JsonResponse<MemberVo.MemberInfo> memberInfo = tallFeignClient.getUserByUserId(userId); |
|
|
|
|
|
|
|
if (memberInfo != null && memberInfo.getCode().intValue() == CodeEnum.SUCCESS.getCode().intValue() && memberInfo.getData() != null) { |
|
|
|
userJoin.setAvatarUrl(memberInfo.getData().getAvatarUrl()); |
|
|
|
userJoin.setNickname(memberInfo.getData().getNickname()); |
|
|
|
|
|
|
@ -179,6 +185,7 @@ public class ClientService implements IClientService { |
|
|
|
// 缓存小组人数
|
|
|
|
String key = join.getGroupId() + GameConstant.GAME_GROUP_NUM; |
|
|
|
Object o = redisUtil.get(key); |
|
|
|
|
|
|
|
redisUtil.set(key, o == null ? 1 : (int)o + 1, GameConstant.REDIS_TIME_TWENTY); |
|
|
|
} |
|
|
|
// 3.更新redis(sort set key:分数 value:头像,姓名)
|
|
|
@ -294,6 +301,28 @@ public class ClientService implements IClientService { |
|
|
|
|
|
|
|
int otherGroupScore = 0; |
|
|
|
//查找所有队伍
|
|
|
|
String groupKey = recordId + "_group"; |
|
|
|
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtil.zsRevGetWithScore(groupKey, 0, -1); |
|
|
|
if(CollectionUtil.isNotEmpty(typedTuples)){ |
|
|
|
List<ScreenVo.GroupVo> vos = new ArrayList<>(); |
|
|
|
AtomicInteger index = new AtomicInteger(0); |
|
|
|
typedTuples.forEach(type -> { |
|
|
|
index.set(index.get() + 1); |
|
|
|
GameGroup gameGroup = JSON.parseObject((String) type.getValue(), GameGroup.class); |
|
|
|
if(gameGroup.getId().longValue() == groupId.longValue()){ |
|
|
|
groupScore.setGroupScore(type.getScore().intValue()); |
|
|
|
groupScore.setGroupTimes(type.getScore().intValue() / 100); |
|
|
|
groupScore.setGroupSort(index.get()); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
if(groupScore.getGroupSort() != null) { |
|
|
|
return groupScore; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GameGroupExample gameGroupExample = new GameGroupExample(); |
|
|
|
gameGroupExample.createCriteria().andRecordIdEqualTo(recordId); |
|
|
|
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample); |
|
|
|