|
|
@ -17,6 +17,7 @@ import com.ccsens.util.CodeEnum; |
|
|
import com.ccsens.util.JsonResponse; |
|
|
import com.ccsens.util.JsonResponse; |
|
|
import com.ccsens.util.RedisUtil; |
|
|
import com.ccsens.util.RedisUtil; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
|
|
//import com.ccsens.util.mq.DelayProducer;
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -50,6 +51,8 @@ public class ClientService implements IClientService { |
|
|
private RedisUtil redisUtil; |
|
|
private RedisUtil redisUtil; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private TallFeignClient tallFeignClient; |
|
|
private TallFeignClient tallFeignClient; |
|
|
|
|
|
// @Autowired
|
|
|
|
|
|
// private DelayProducer delaySender;
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ClientVo.Join join(ClientDto.Join join, Long userId) { |
|
|
public ClientVo.Join join(ClientDto.Join join, Long userId) { |
|
|
@ -86,7 +89,10 @@ public class ClientService implements IClientService { |
|
|
joinVo.setCompletedData(completedData); |
|
|
joinVo.setCompletedData(completedData); |
|
|
return joinVo; |
|
|
return joinVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//准备中
|
|
|
boolean prepare = gameRecord.getGameStatus().byteValue() == GameConstant.GAME_PREPARATION; |
|
|
boolean prepare = gameRecord.getGameStatus().byteValue() == GameConstant.GAME_PREPARATION; |
|
|
|
|
|
//进行中
|
|
|
boolean processing = gameRecord.getGameStatus().byteValue() == GameConstant.GAME_PROCESSING; |
|
|
boolean processing = gameRecord.getGameStatus().byteValue() == GameConstant.GAME_PROCESSING; |
|
|
|
|
|
|
|
|
// 2.保存游戏路径用户表(设置游戏路径ID+用户ID组合为唯一索引 replace)
|
|
|
// 2.保存游戏路径用户表(设置游戏路径ID+用户ID组合为唯一索引 replace)
|
|
|
@ -97,7 +103,7 @@ public class ClientService implements IClientService { |
|
|
userJoin.setTimeDifference(timeMore); |
|
|
userJoin.setTimeDifference(timeMore); |
|
|
|
|
|
|
|
|
userJoin.setLocalStartTime(prepare || processing ? gameRecord.getStartTime() + timeMore : 0); |
|
|
userJoin.setLocalStartTime(prepare || processing ? gameRecord.getStartTime() + timeMore : 0); |
|
|
userJoin.setLocalStartTime(prepare || processing ? gameRecord.getEndTime() + timeMore : 0); |
|
|
userJoin.setLocalEndTime(prepare || processing ? gameRecord.getEndTime() + timeMore : 0); |
|
|
// 获取头像和用户名
|
|
|
// 获取头像和用户名
|
|
|
JsonResponse<MemberVo.MemberInfo> memberInfo = tallFeignClient.getMemberByUserId(userId, join.getProjectId()); |
|
|
JsonResponse<MemberVo.MemberInfo> memberInfo = tallFeignClient.getMemberByUserId(userId, join.getProjectId()); |
|
|
if (memberInfo.getCode().intValue() == CodeEnum.SUCCESS.getCode() && memberInfo.getData() != null) { |
|
|
if (memberInfo.getCode().intValue() == CodeEnum.SUCCESS.getCode() && memberInfo.getData() != null) { |
|
|
@ -112,6 +118,21 @@ public class ClientService implements IClientService { |
|
|
user.setNickname(userJoin.getNickname()); |
|
|
user.setNickname(userJoin.getNickname()); |
|
|
redisUtil.zsSet(GameConstant.generateGameKey(gameRecord.getId()), JSON.toJSONString(user), 0, GameConstant.REDIS_TIME); |
|
|
redisUtil.zsSet(GameConstant.generateGameKey(gameRecord.getId()), JSON.toJSONString(user), 0, GameConstant.REDIS_TIME); |
|
|
//4.根据状态延时发送消息
|
|
|
//4.根据状态延时发送消息
|
|
|
|
|
|
if (prepare) { |
|
|
|
|
|
//延时发送开始
|
|
|
|
|
|
long expiration = gameRecord.getStartTime() - System.currentTimeMillis(); |
|
|
|
|
|
//TODO 发送内容未定
|
|
|
|
|
|
// delaySender.sendDelayMessage("开始啦", expiration);
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (prepare || processing) { |
|
|
|
|
|
//延时发送结束
|
|
|
|
|
|
long expiration = gameRecord.getEndTime() - System.currentTimeMillis(); |
|
|
|
|
|
//TODO 发送内容未定
|
|
|
|
|
|
// delaySender.sendDelayMessage("结束了", expiration);
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//5.返回状态
|
|
|
//5.返回状态
|
|
|
return joinResult(userJoin, gameRecord); |
|
|
return joinResult(userJoin, gameRecord); |
|
|
@ -127,8 +148,8 @@ public class ClientService implements IClientService { |
|
|
case GameConstant.GAME_PREPARATION : |
|
|
case GameConstant.GAME_PREPARATION : |
|
|
// 准备中
|
|
|
// 准备中
|
|
|
ClientVo.PreparingData preparingData = new ClientVo.PreparingData(); |
|
|
ClientVo.PreparingData preparingData = new ClientVo.PreparingData(); |
|
|
preparingData.setStartLocalTime(join.getLocalStartTime()); |
|
|
preparingData.setStartLocalTime(join.getLocalStartTime() + join.getTimeDifference()); |
|
|
preparingData.setEndLocalTime(join.getLocalEndTime()); |
|
|
preparingData.setEndLocalTime(join.getLocalEndTime() + join.getTimeDifference()); |
|
|
joinVo.setPreparingData(preparingData); |
|
|
joinVo.setPreparingData(preparingData); |
|
|
break; |
|
|
break; |
|
|
case GameConstant.GAME_PROCESSING : |
|
|
case GameConstant.GAME_PROCESSING : |
|
|
|