6 years ago
parent
commit
13433cb69c
  1. 28
      game/src/main/java/com/ccsens/game/api/ScreenController.java
  2. 38
      game/src/main/java/com/ccsens/game/bean/po/GameUserJoin.java
  3. 200
      game/src/main/java/com/ccsens/game/bean/po/GameUserJoinExample.java
  4. 38
      game/src/main/java/com/ccsens/game/bean/vo/ScreenVo.java
  5. 8
      game/src/main/java/com/ccsens/game/persist/dao/GameActivityPrizeDao.java
  6. 8
      game/src/main/java/com/ccsens/game/persist/dao/GamePrizeInstructionsDao.java
  7. 8
      game/src/main/java/com/ccsens/game/persist/dao/GameScoreLogDao.java
  8. 6
      game/src/main/java/com/ccsens/game/service/IScreenService.java
  9. 258
      game/src/main/java/com/ccsens/game/service/ScreenService.java
  10. 76
      game/src/main/resources/mapper_raw/GameUserJoinMapper.xml
  11. 14
      game/src/main/resources/mbg.xml
  12. 3
      util/src/main/java/com/ccsens/util/CodeEnum.java

28
game/src/main/java/com/ccsens/game/api/ScreenController.java

@ -1,5 +1,6 @@
package com.ccsens.game.api;
import com.ccsens.cloudutil.annotation.Login;
import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.game.bean.dto.ScreenDto;
import com.ccsens.game.bean.vo.ScreenVo;
@ -27,37 +28,30 @@ public class ScreenController {
@MustLogin
@ApiOperation(value = "获取大屏路径", notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "url", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<ScreenVo.UrlVo> getScreenUrl(HttpServletRequest request,
@ApiParam @Validated @RequestBody QueryDto<ScreenDto.MemberGame> params) throws Exception {
public JsonResponse<ScreenVo.UrlVo> getScreenUrl(@ApiParam @Validated @RequestBody QueryDto<ScreenDto.MemberGame> params) throws Exception {
log.info("获取大屏路径:{}",params);
ScreenVo.UrlVo urlVo = screenService.getScreenUrl(params);
return JsonResponse.newInstance().ok(urlVo);
}
@Login
@ApiOperation(value = "获取游戏基本信息", notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "information", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<ScreenVo.GameInfoVo> getGameInfo(HttpServletRequest request,
@ApiParam @Validated @RequestBody ScreenDto.MemberRecord memberRecord) throws Exception {
log.info("获取游戏基本信息:{}",memberRecord);
ScreenVo.GameInfoVo gameInfoVo = screenService.getGameInformation(memberRecord);
return JsonResponse.newInstance().ok();
public JsonResponse<ScreenVo.GameInfoVo> getGameInfo(@ApiParam @Validated @RequestBody QueryDto<ScreenDto.MemberRecord> params) throws Exception {
log.info("获取游戏基本信息:{}",params);
ScreenVo.GameInfoVo gameInfoVo = screenService.getGameInformation(params);
return JsonResponse.newInstance().ok(gameInfoVo);
}
@ApiOperation(value = "获取游戏的状态", notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "gameStatus", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse getGameStatus(HttpServletRequest request,
@ApiParam @Validated @RequestBody ScreenDto.MemberRecord memberRecord) throws Exception {
log.info("获取游戏的状态:{}",memberRecord);
return JsonResponse.newInstance().ok();
public JsonResponse<ScreenVo.GameStatusVo> getGameStatus(@ApiParam @Validated @RequestBody QueryDto<ScreenDto.MemberRecord> params) throws Exception {
log.info("获取游戏的状态:{}",params);
ScreenVo.GameStatusVo gameStatusVo = screenService.getGameStatusVo(params);
return JsonResponse.newInstance().ok(gameStatusVo);
}
@ApiOperation(value = "开始游戏", notes = "")

38
game/src/main/java/com/ccsens/game/bean/po/GameUserJoin.java

@ -8,11 +8,15 @@ public class GameUserJoin implements Serializable {
private Long userId;
private String nickname;
private String avatarurl;
private Long recordId;
private String times;
private Integer times;
private String score;
private Integer score;
private Integer timeDifference;
@ -44,6 +48,22 @@ public class GameUserJoin implements Serializable {
this.userId = userId;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname == null ? null : nickname.trim();
}
public String getAvatarurl() {
return avatarurl;
}
public void setAvatarurl(String avatarurl) {
this.avatarurl = avatarurl == null ? null : avatarurl.trim();
}
public Long getRecordId() {
return recordId;
}
@ -52,20 +72,20 @@ public class GameUserJoin implements Serializable {
this.recordId = recordId;
}
public String getTimes() {
public Integer getTimes() {
return times;
}
public void setTimes(String times) {
this.times = times == null ? null : times.trim();
public void setTimes(Integer times) {
this.times = times;
}
public String getScore() {
public Integer getScore() {
return score;
}
public void setScore(String score) {
this.score = score == null ? null : score.trim();
public void setScore(Integer score) {
this.score = score;
}
public Integer getTimeDifference() {
@ -124,6 +144,8 @@ public class GameUserJoin implements Serializable {
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", nickname=").append(nickname);
sb.append(", avatarurl=").append(avatarurl);
sb.append(", recordId=").append(recordId);
sb.append(", times=").append(times);
sb.append(", score=").append(score);

200
game/src/main/java/com/ccsens/game/bean/po/GameUserJoinExample.java

@ -225,6 +225,146 @@ public class GameUserJoinExample {
return (Criteria) this;
}
public Criteria andNicknameIsNull() {
addCriterion("nickname is null");
return (Criteria) this;
}
public Criteria andNicknameIsNotNull() {
addCriterion("nickname is not null");
return (Criteria) this;
}
public Criteria andNicknameEqualTo(String value) {
addCriterion("nickname =", value, "nickname");
return (Criteria) this;
}
public Criteria andNicknameNotEqualTo(String value) {
addCriterion("nickname <>", value, "nickname");
return (Criteria) this;
}
public Criteria andNicknameGreaterThan(String value) {
addCriterion("nickname >", value, "nickname");
return (Criteria) this;
}
public Criteria andNicknameGreaterThanOrEqualTo(String value) {
addCriterion("nickname >=", value, "nickname");
return (Criteria) this;
}
public Criteria andNicknameLessThan(String value) {
addCriterion("nickname <", value, "nickname");
return (Criteria) this;
}
public Criteria andNicknameLessThanOrEqualTo(String value) {
addCriterion("nickname <=", value, "nickname");
return (Criteria) this;
}
public Criteria andNicknameLike(String value) {
addCriterion("nickname like", value, "nickname");
return (Criteria) this;
}
public Criteria andNicknameNotLike(String value) {
addCriterion("nickname not like", value, "nickname");
return (Criteria) this;
}
public Criteria andNicknameIn(List<String> values) {
addCriterion("nickname in", values, "nickname");
return (Criteria) this;
}
public Criteria andNicknameNotIn(List<String> values) {
addCriterion("nickname not in", values, "nickname");
return (Criteria) this;
}
public Criteria andNicknameBetween(String value1, String value2) {
addCriterion("nickname between", value1, value2, "nickname");
return (Criteria) this;
}
public Criteria andNicknameNotBetween(String value1, String value2) {
addCriterion("nickname not between", value1, value2, "nickname");
return (Criteria) this;
}
public Criteria andAvatarurlIsNull() {
addCriterion("avatarUrl is null");
return (Criteria) this;
}
public Criteria andAvatarurlIsNotNull() {
addCriterion("avatarUrl is not null");
return (Criteria) this;
}
public Criteria andAvatarurlEqualTo(String value) {
addCriterion("avatarUrl =", value, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlNotEqualTo(String value) {
addCriterion("avatarUrl <>", value, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlGreaterThan(String value) {
addCriterion("avatarUrl >", value, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlGreaterThanOrEqualTo(String value) {
addCriterion("avatarUrl >=", value, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlLessThan(String value) {
addCriterion("avatarUrl <", value, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlLessThanOrEqualTo(String value) {
addCriterion("avatarUrl <=", value, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlLike(String value) {
addCriterion("avatarUrl like", value, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlNotLike(String value) {
addCriterion("avatarUrl not like", value, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlIn(List<String> values) {
addCriterion("avatarUrl in", values, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlNotIn(List<String> values) {
addCriterion("avatarUrl not in", values, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlBetween(String value1, String value2) {
addCriterion("avatarUrl between", value1, value2, "avatarurl");
return (Criteria) this;
}
public Criteria andAvatarurlNotBetween(String value1, String value2) {
addCriterion("avatarUrl not between", value1, value2, "avatarurl");
return (Criteria) this;
}
public Criteria andRecordIdIsNull() {
addCriterion("record_id is null");
return (Criteria) this;
@ -295,62 +435,52 @@ public class GameUserJoinExample {
return (Criteria) this;
}
public Criteria andTimesEqualTo(String value) {
public Criteria andTimesEqualTo(Integer value) {
addCriterion("times =", value, "times");
return (Criteria) this;
}
public Criteria andTimesNotEqualTo(String value) {
public Criteria andTimesNotEqualTo(Integer value) {
addCriterion("times <>", value, "times");
return (Criteria) this;
}
public Criteria andTimesGreaterThan(String value) {
public Criteria andTimesGreaterThan(Integer value) {
addCriterion("times >", value, "times");
return (Criteria) this;
}
public Criteria andTimesGreaterThanOrEqualTo(String value) {
public Criteria andTimesGreaterThanOrEqualTo(Integer value) {
addCriterion("times >=", value, "times");
return (Criteria) this;
}
public Criteria andTimesLessThan(String value) {
public Criteria andTimesLessThan(Integer value) {
addCriterion("times <", value, "times");
return (Criteria) this;
}
public Criteria andTimesLessThanOrEqualTo(String value) {
public Criteria andTimesLessThanOrEqualTo(Integer value) {
addCriterion("times <=", value, "times");
return (Criteria) this;
}
public Criteria andTimesLike(String value) {
addCriterion("times like", value, "times");
return (Criteria) this;
}
public Criteria andTimesNotLike(String value) {
addCriterion("times not like", value, "times");
return (Criteria) this;
}
public Criteria andTimesIn(List<String> values) {
public Criteria andTimesIn(List<Integer> values) {
addCriterion("times in", values, "times");
return (Criteria) this;
}
public Criteria andTimesNotIn(List<String> values) {
public Criteria andTimesNotIn(List<Integer> values) {
addCriterion("times not in", values, "times");
return (Criteria) this;
}
public Criteria andTimesBetween(String value1, String value2) {
public Criteria andTimesBetween(Integer value1, Integer value2) {
addCriterion("times between", value1, value2, "times");
return (Criteria) this;
}
public Criteria andTimesNotBetween(String value1, String value2) {
public Criteria andTimesNotBetween(Integer value1, Integer value2) {
addCriterion("times not between", value1, value2, "times");
return (Criteria) this;
}
@ -365,62 +495,52 @@ public class GameUserJoinExample {
return (Criteria) this;
}
public Criteria andScoreEqualTo(String value) {
public Criteria andScoreEqualTo(Integer value) {
addCriterion("score =", value, "score");
return (Criteria) this;
}
public Criteria andScoreNotEqualTo(String value) {
public Criteria andScoreNotEqualTo(Integer value) {
addCriterion("score <>", value, "score");
return (Criteria) this;
}
public Criteria andScoreGreaterThan(String value) {
public Criteria andScoreGreaterThan(Integer value) {
addCriterion("score >", value, "score");
return (Criteria) this;
}
public Criteria andScoreGreaterThanOrEqualTo(String value) {
public Criteria andScoreGreaterThanOrEqualTo(Integer value) {
addCriterion("score >=", value, "score");
return (Criteria) this;
}
public Criteria andScoreLessThan(String value) {
public Criteria andScoreLessThan(Integer value) {
addCriterion("score <", value, "score");
return (Criteria) this;
}
public Criteria andScoreLessThanOrEqualTo(String value) {
public Criteria andScoreLessThanOrEqualTo(Integer value) {
addCriterion("score <=", value, "score");
return (Criteria) this;
}
public Criteria andScoreLike(String value) {
addCriterion("score like", value, "score");
return (Criteria) this;
}
public Criteria andScoreNotLike(String value) {
addCriterion("score not like", value, "score");
return (Criteria) this;
}
public Criteria andScoreIn(List<String> values) {
public Criteria andScoreIn(List<Integer> values) {
addCriterion("score in", values, "score");
return (Criteria) this;
}
public Criteria andScoreNotIn(List<String> values) {
public Criteria andScoreNotIn(List<Integer> values) {
addCriterion("score not in", values, "score");
return (Criteria) this;
}
public Criteria andScoreBetween(String value1, String value2) {
public Criteria andScoreBetween(Integer value1, Integer value2) {
addCriterion("score between", value1, value2, "score");
return (Criteria) this;
}
public Criteria andScoreNotBetween(String value1, String value2) {
public Criteria andScoreNotBetween(Integer value1, Integer value2) {
addCriterion("score not between", value1, value2, "score");
return (Criteria) this;
}

38
game/src/main/java/com/ccsens/game/bean/vo/ScreenVo.java

@ -1,5 +1,6 @@
package com.ccsens.game.bean.vo;
import com.ccsens.game.bean.po.GameUserJoin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -63,7 +64,8 @@ public class ScreenVo {
@Data
@ApiModel("进行中")
public static class ProcessingData{
@ApiModelProperty("前十名的信息")
private List<GameUserJoin> topUsers;
}
@Data
@ -78,4 +80,38 @@ public class ScreenVo {
@ApiModelProperty("平均次数超过百分之多少人")
private int over;
}
@Data
@ApiModel("进行中")
public static class GameStatusVo{
@ApiModelProperty("游戏状态 0未开始 1准备中 2进行中 3已结束")
private Byte gameStatus;
@ApiModelProperty("总人数")
private int totalMembers ;
@ApiModelProperty("未开始")
private PendingData pendingData;
@ApiModelProperty("准备中")
private PreparingData preparingData;
@ApiModelProperty("进行中")
private ProcessingData processingData;
@ApiModelProperty("已结束")
private CompletedData completedData;
}
@Data
@ApiModel("前十名的信息")
public static class TopUsers{
@ApiModelProperty("用户头像")
private String headImgUrl;
@ApiModelProperty("微信名")
private String nickname;
@ApiModelProperty("排名次序")
private int sort;
@ApiModelProperty("次数")
private int times;
@ApiModelProperty("分数")
private int score;
}
}

8
game/src/main/java/com/ccsens/game/persist/dao/GameActivityPrizeDao.java

@ -0,0 +1,8 @@
package com.ccsens.game.persist.dao;
import com.ccsens.game.persist.mapper.GameActivityPrizeMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface GameActivityPrizeDao extends GameActivityPrizeMapper{
}

8
game/src/main/java/com/ccsens/game/persist/dao/GamePrizeInstructionsDao.java

@ -0,0 +1,8 @@
package com.ccsens.game.persist.dao;
import com.ccsens.game.persist.mapper.GamePrizeInstructionsMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface GamePrizeInstructionsDao extends GamePrizeInstructionsMapper{
}

8
game/src/main/java/com/ccsens/game/persist/dao/GameScoreLogDao.java

@ -0,0 +1,8 @@
package com.ccsens.game.persist.dao;
import com.ccsens.game.persist.mapper.GameScoreLogMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface GameScoreLogDao extends GameScoreLogMapper{
}

6
game/src/main/java/com/ccsens/game/service/IScreenService.java

@ -5,7 +5,9 @@ import com.ccsens.game.bean.vo.ScreenVo;
import com.ccsens.util.bean.dto.QueryDto;
public interface IScreenService {
ScreenVo.UrlVo getScreenUrl(QueryDto<ScreenDto.MemberGame> memberGame);
ScreenVo.UrlVo getScreenUrl(QueryDto<ScreenDto.MemberGame> params);
ScreenVo.GameInfoVo getGameInformation(ScreenDto.MemberRecord memberRecord);
ScreenVo.GameInfoVo getGameInformation(QueryDto<ScreenDto.MemberRecord> params);
ScreenVo.GameStatusVo getGameStatusVo(QueryDto<ScreenDto.MemberRecord> params);
}

258
game/src/main/java/com/ccsens/game/service/ScreenService.java

@ -12,6 +12,7 @@ import com.ccsens.util.CodeEnum;
import com.ccsens.util.WebConstant;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.util.exception.BaseException;
import feign.Param;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -35,7 +36,12 @@ public class ScreenService implements IScreenService{
@Autowired
private GameActivityRuleDao activityRuleDao;
@Autowired
private GameActivityPrizeDao activityPrizeDao;
@Autowired
private GamePrizeInstructionsDao prizeInstructionsDao;
@Autowired
private GameUserJoinDao gameMemberJoinDao;
@Autowired
private Snowflake snowflake;
@ -84,16 +90,7 @@ public class ScreenService implements IScreenService{
gameRecord.setQrCodeUrl(WebConstant.TEST_URL_GAME + gameRecord.getId() + File.separator + gameType.getClientUrl());
gameRecordDao.insertSelective(gameRecord);
//5、查询该游戏的规则
List<String> ruleList = null;
GameActivityRuleExample activityRuleExample = new GameActivityRuleExample();
activityRuleExample.createCriteria().andGameIdEqualTo(gameType.getId());
List<GameActivityRule> gameActivityRuleList = activityRuleDao.selectByExample(activityRuleExample);
if(CollectionUtil.isNotEmpty(gameActivityRuleList)){
ruleList = new ArrayList<>();
for(GameActivityRule activityRule : gameActivityRuleList){
ruleList.add(activityRule.getDescription());
}
}
List<String> ruleList = getGameActivityRule(gameType.getId());
//6、返回
ScreenVo.UrlVo urlVo = new ScreenVo.UrlVo();
urlVo.setUrl(gameRecord.getUrl());
@ -103,44 +100,215 @@ public class ScreenService implements IScreenService{
/**
* 获取游戏基本信息
* @param memberRecord
* @return
*/
@Override
public ScreenVo.GameInfoVo getGameInformation(ScreenDto.MemberRecord memberRecord) {
// GameRecord gameRecord = gameRecordDao.selectByPrimaryKey(memberRecord.getMemberRecord());
// if(ObjectUtil.isNull(gameRecord)){
// throw new BaseException(CodeEnum.NOT_GAME_RECORD);
// }
// GameTypeMember gameTypeMember = typeMemberDao.selectByPrimaryKey(gameRecord.getTypeMemberId());
// ScreenVo.GameInfoVo gameInfoVo = new ScreenVo.GameInfoVo();
// gameInfoVo.setQRCodeUrl(gameRecord.getQrCodeUrl());
// gameInfoVo.setTotalCount(gameTypeMember.getTotalCount());
// gameInfoVo.setUsedCount(gameTypeMember.getUsedCount());
// gameInfoVo.setGameStatus(gameRecord.getGameStatus());
// GameMemberJoinExample gameMemberJoinExample = new GameMemberJoinExample();
// gameMemberJoinExample.createCriteria().andRecordIdEqualTo(memberRecord.getMemberRecord());
// List<GameMemberJoin> memberJoinList = gameMemberJoinDao.selectByExample(gameMemberJoinExample);
// if(CollectionUtil.isNotEmpty(memberJoinList)){
// gameInfoVo.setTotalMembers(memberJoinList.size());
// }else {
// gameInfoVo.setTotalMembers(0);
// }
// switch (gameInfoVo.getGameStatus()){
// case 0:
//
// break;
// case 1:
//
// break;
// case 2:
// break;
// case 3:
// break;
// default:
// break;
// }
public ScreenVo.GameInfoVo getGameInformation(QueryDto<ScreenDto.MemberRecord> params) {
//传入
ScreenDto.MemberRecord memberRecord = params.getParam();
//返回
ScreenVo.GameInfoVo gameInfoVo = new ScreenVo.GameInfoVo();
GameRecord gameRecord = gameRecordDao.selectByPrimaryKey(memberRecord.getMemberRecord());
if(ObjectUtil.isNull(gameRecord)){
throw new BaseException(CodeEnum.NOT_GAME_RECORD);
}
GameUserPay gameUserPay = typeMemberDao.selectByPrimaryKey(gameRecord.getUserPayId());
if(ObjectUtil.isNull(gameUserPay)){
throw new BaseException(CodeEnum.NOT_GAME_TYPE);
}
gameInfoVo.setQRCodeUrl(gameRecord.getQrCodeUrl());
gameInfoVo.setTotalCount(gameUserPay.getTotalCount());
gameInfoVo.setUsedCount(gameUserPay.getUsedCount());
gameInfoVo.setGameStatus(gameRecord.getGameStatus());
//查询参加这个游戏的用户
GameUserJoinExample gameuserJoinExample = new GameUserJoinExample();
gameuserJoinExample.createCriteria().andRecordIdEqualTo(memberRecord.getMemberRecord());
List<GameUserJoin> userJoinList = gameMemberJoinDao.selectByExample(gameuserJoinExample);
if(CollectionUtil.isNotEmpty(userJoinList)){
gameInfoVo.setTotalMembers(userJoinList.size());
}else {
gameInfoVo.setTotalMembers(0);
}
switch (gameInfoVo.getGameStatus()){
case 0:
ScreenVo.PendingData pendingData = new ScreenVo.PendingData();
//查询活动规则
List<String> ruleList = getGameActivityRule(gameUserPay.getGameTypeId());
//查询活动奖品
List<String> prizeList = getGameActivityPrize(gameUserPay.getGameTypeId());
//查询奖券使用说明
List<String> instructionsList = getGamePrizeInstructions(gameUserPay.getGameTypeId());
pendingData.setActivityRule(ruleList);
pendingData.setActivityPrize(prizeList);
pendingData.setInstructions(instructionsList);
gameInfoVo.setPendingData(pendingData);
break;
case 1:
ScreenVo.PreparingData preparingData = new ScreenVo.PreparingData();
if(ObjectUtil.isNull(params.getUserId())){
preparingData.setStartLocalTime(gameRecord.getStartTime() + gameRecord.getTimeDifference());
}else {
if(CollectionUtil.isNotEmpty(userJoinList)){
for(GameUserJoin gameUserJoin : userJoinList){
if(params.getUserId().longValue() == gameUserJoin.getId().longValue()){
preparingData.setStartLocalTime(gameRecord.getStartTime() + gameUserJoin.getTimeDifference());
}
}
if(ObjectUtil.isNull(preparingData.getStartLocalTime())){
throw new BaseException(CodeEnum.NOT_JOIN_GAME);
}
}else {
throw new BaseException(CodeEnum.NOT_JOIN_GAME);
}
}
gameInfoVo.setPreparingData(preparingData);
break;
case 2:
break;
case 3:
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData();
if(CollectionUtil.isNotEmpty(userJoinList)){
completedData = getCompletedData(userJoinList);
}
gameInfoVo.setCompletedData(completedData);
break;
default:
break;
}
return gameInfoVo;
}
/**
* 获取游戏状态
*/
@Override
public ScreenVo.GameStatusVo getGameStatusVo(QueryDto<ScreenDto.MemberRecord> params) {
ScreenDto.MemberRecord memberRecord = params.getParam();
ScreenVo.GameStatusVo gameStatusVo = new ScreenVo.GameStatusVo();
GameRecord gameRecord = gameRecordDao.selectByPrimaryKey(memberRecord.getMemberRecord());
if(ObjectUtil.isNull(gameRecord)){
throw new BaseException(CodeEnum.NOT_GAME_RECORD);
}
GameUserJoinExample gameuserJoinExample = new GameUserJoinExample();
gameuserJoinExample.createCriteria().andRecordIdEqualTo(memberRecord.getMemberRecord());
List<GameUserJoin> userJoinList = gameMemberJoinDao.selectByExample(gameuserJoinExample);
gameStatusVo.setGameStatus(gameRecord.getGameStatus());
switch (gameStatusVo.getGameStatus()){
case 0:
break;
case 1:
ScreenVo.PreparingData preparingData = new ScreenVo.PreparingData();
if(ObjectUtil.isNull(params.getUserId())){
preparingData.setStartLocalTime(gameRecord.getStartTime() + gameRecord.getTimeDifference());
}else {
if(CollectionUtil.isNotEmpty(userJoinList)){
for(GameUserJoin gameUserJoin : userJoinList){
if(gameUserJoin.getId().longValue() == params.getUserId().longValue()){
preparingData.setStartLocalTime(gameRecord.getStartTime() + gameUserJoin.getTimeDifference());
}
}
if(ObjectUtil.isNull(preparingData.getStartLocalTime())){
throw new BaseException(CodeEnum.NOT_JOIN_GAME);
}
}else {
throw new BaseException(CodeEnum.NOT_JOIN_GAME);
}
}
gameStatusVo.setPreparingData(preparingData);
break;
case 2:
// TODO
break;
case 3:
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData();
if(CollectionUtil.isNotEmpty(userJoinList)){
completedData = getCompletedData(userJoinList);
}
gameStatusVo.setCompletedData(completedData);
break;
default:
break;
}
return gameStatusVo;
}
return null;
/**
* 查找活动规则
*/
private 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());
}
}
return ruleList;
}
/**
* 查询活动奖品
*/
private 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());
}
}
return prizeList;
}
/**
* 奖券使用说明表
*/
private 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());
}
}
return instructionsList;
}
/**
* 已结束时的返回值
*/
private ScreenVo.CompletedData getCompletedData(List<GameUserJoin> userJoinList){
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData();
int totalTimes = 0;
int totalScore = 0;
int averageTimes = 0;
int over = 0;
if(CollectionUtil.isNotEmpty(userJoinList)){
for(GameUserJoin userJoin : userJoinList){
totalTimes += userJoin.getTimes();
totalScore += userJoin.getScore();
}
averageTimes = totalTimes / userJoinList.size();
int a = 0;
for(GameUserJoin userJoin : userJoinList){
if(userJoin.getTimes() < averageTimes){
a++;
}
}
over = a / userJoinList.size() * 100;
}
completedData.setTotalTimes(totalTimes);
completedData.setTotalScore(totalScore);
completedData.setAverageTimes(averageTimes);
completedData.setOver(over);
return completedData;
}
}

76
game/src/main/resources/mapper_raw/GameUserJoinMapper.xml

@ -4,9 +4,11 @@
<resultMap id="BaseResultMap" type="com.ccsens.game.bean.po.GameUserJoin">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="avatarUrl" jdbcType="VARCHAR" property="avatarurl" />
<result column="record_id" jdbcType="BIGINT" property="recordId" />
<result column="times" jdbcType="VARCHAR" property="times" />
<result column="score" jdbcType="VARCHAR" property="score" />
<result column="times" jdbcType="INTEGER" property="times" />
<result column="score" jdbcType="INTEGER" property="score" />
<result column="time_difference" jdbcType="INTEGER" property="timeDifference" />
<result column="local_start_time" jdbcType="BIGINT" property="localStartTime" />
<result column="local_end_time" jdbcType="BIGINT" property="localEndTime" />
@ -73,8 +75,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, user_id, record_id, times, score, time_difference, local_start_time, local_end_time,
created_at, updated_at, rec_status
id, user_id, nickname, avatarUrl, record_id, times, score, time_difference, local_start_time,
local_end_time, created_at, updated_at, rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.game.bean.po.GameUserJoinExample" resultMap="BaseResultMap">
select
@ -107,14 +109,16 @@
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.game.bean.po.GameUserJoin">
insert into t_game_user_join (id, user_id, record_id,
times, score, time_difference,
local_start_time, local_end_time, created_at,
updated_at, rec_status)
values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{recordId,jdbcType=BIGINT},
#{times,jdbcType=VARCHAR}, #{score,jdbcType=VARCHAR}, #{timeDifference,jdbcType=INTEGER},
#{localStartTime,jdbcType=BIGINT}, #{localEndTime,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
insert into t_game_user_join (id, user_id, nickname,
avatarUrl, record_id, times,
score, time_difference, local_start_time,
local_end_time, created_at, updated_at,
rec_status)
values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{nickname,jdbcType=VARCHAR},
#{avatarurl,jdbcType=VARCHAR}, #{recordId,jdbcType=BIGINT}, #{times,jdbcType=INTEGER},
#{score,jdbcType=INTEGER}, #{timeDifference,jdbcType=INTEGER}, #{localStartTime,jdbcType=BIGINT},
#{localEndTime,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP},
#{recStatus,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.ccsens.game.bean.po.GameUserJoin">
insert into t_game_user_join
@ -125,6 +129,12 @@
<if test="userId != null">
user_id,
</if>
<if test="nickname != null">
nickname,
</if>
<if test="avatarurl != null">
avatarUrl,
</if>
<if test="recordId != null">
record_id,
</if>
@ -160,14 +170,20 @@
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="nickname != null">
#{nickname,jdbcType=VARCHAR},
</if>
<if test="avatarurl != null">
#{avatarurl,jdbcType=VARCHAR},
</if>
<if test="recordId != null">
#{recordId,jdbcType=BIGINT},
</if>
<if test="times != null">
#{times,jdbcType=VARCHAR},
#{times,jdbcType=INTEGER},
</if>
<if test="score != null">
#{score,jdbcType=VARCHAR},
#{score,jdbcType=INTEGER},
</if>
<if test="timeDifference != null">
#{timeDifference,jdbcType=INTEGER},
@ -204,14 +220,20 @@
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.nickname != null">
nickname = #{record.nickname,jdbcType=VARCHAR},
</if>
<if test="record.avatarurl != null">
avatarUrl = #{record.avatarurl,jdbcType=VARCHAR},
</if>
<if test="record.recordId != null">
record_id = #{record.recordId,jdbcType=BIGINT},
</if>
<if test="record.times != null">
times = #{record.times,jdbcType=VARCHAR},
times = #{record.times,jdbcType=INTEGER},
</if>
<if test="record.score != null">
score = #{record.score,jdbcType=VARCHAR},
score = #{record.score,jdbcType=INTEGER},
</if>
<if test="record.timeDifference != null">
time_difference = #{record.timeDifference,jdbcType=INTEGER},
@ -240,9 +262,11 @@
update t_game_user_join
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
nickname = #{record.nickname,jdbcType=VARCHAR},
avatarUrl = #{record.avatarurl,jdbcType=VARCHAR},
record_id = #{record.recordId,jdbcType=BIGINT},
times = #{record.times,jdbcType=VARCHAR},
score = #{record.score,jdbcType=VARCHAR},
times = #{record.times,jdbcType=INTEGER},
score = #{record.score,jdbcType=INTEGER},
time_difference = #{record.timeDifference,jdbcType=INTEGER},
local_start_time = #{record.localStartTime,jdbcType=BIGINT},
local_end_time = #{record.localEndTime,jdbcType=BIGINT},
@ -259,14 +283,20 @@
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="nickname != null">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="avatarurl != null">
avatarUrl = #{avatarurl,jdbcType=VARCHAR},
</if>
<if test="recordId != null">
record_id = #{recordId,jdbcType=BIGINT},
</if>
<if test="times != null">
times = #{times,jdbcType=VARCHAR},
times = #{times,jdbcType=INTEGER},
</if>
<if test="score != null">
score = #{score,jdbcType=VARCHAR},
score = #{score,jdbcType=INTEGER},
</if>
<if test="timeDifference != null">
time_difference = #{timeDifference,jdbcType=INTEGER},
@ -292,9 +322,11 @@
<update id="updateByPrimaryKey" parameterType="com.ccsens.game.bean.po.GameUserJoin">
update t_game_user_join
set user_id = #{userId,jdbcType=BIGINT},
nickname = #{nickname,jdbcType=VARCHAR},
avatarUrl = #{avatarurl,jdbcType=VARCHAR},
record_id = #{recordId,jdbcType=BIGINT},
times = #{times,jdbcType=VARCHAR},
score = #{score,jdbcType=VARCHAR},
times = #{times,jdbcType=INTEGER},
score = #{score,jdbcType=INTEGER},
time_difference = #{timeDifference,jdbcType=INTEGER},
local_start_time = #{localStartTime,jdbcType=BIGINT},
local_end_time = #{localEndTime,jdbcType=BIGINT},

14
game/src/main/resources/mbg.xml

@ -55,14 +55,14 @@
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="t_game_type" domainObjectName="GameType"></table>
<table tableName="t_game_user_pay" domainObjectName="GameUserPay"></table>
<table tableName="t_game_record" domainObjectName="GameRecord"></table>
<!--<table tableName="t_game_type" domainObjectName="GameType"></table>-->
<!--<table tableName="t_game_user_pay" domainObjectName="GameUserPay"></table>-->
<!--<table tableName="t_game_record" domainObjectName="GameRecord"></table>-->
<table tableName="t_game_user_join" domainObjectName="GameUserJoin"></table>
<table tableName="t_game_score_log" domainObjectName="GameScoreLog"></table>
<table tableName="t_game_activity_rule" domainObjectName="GameActivityRule"></table>
<table tableName="t_game_activity_prize" domainObjectName="GameActivityPrize"></table>
<table tableName="t_game_prize_instructions" domainObjectName="GamePrizeInstructions"></table>
<!--<table tableName="t_game_score_log" domainObjectName="GameScoreLog"></table>-->
<!--<table tableName="t_game_activity_rule" domainObjectName="GameActivityRule"></table>-->
<!--<table tableName="t_game_activity_prize" domainObjectName="GameActivityPrize"></table>-->
<!--<table tableName="t_game_prize_instructions" domainObjectName="GamePrizeInstructions"></table>-->
<!-- 有些表的字段需要指定java类型
<table schema="" tableName="">

3
util/src/main/java/com/ccsens/util/CodeEnum.java

@ -75,7 +75,8 @@ public enum CodeEnum {
SIGNIN_REPEAT(59,"请勿重复签到",true),
SCORE_REPEAT(60,"您已经评分,请勿重复提交",true),
NOT_MEMBER(61,"对不起,找不到对应的成员信息",true),
NOT_GAME_RECORD(62,"对不起,找不到对应的游戏场次",true)
NOT_GAME_RECORD(62,"对不起,找不到对应的游戏场次",true),
NOT_JOIN_GAME(63,"您还未加入游戏,请参加游戏后再试",true)
;
public CodeEnum addMsg(String msg){

Loading…
Cancel
Save