| @@ -72,10 +72,10 @@ public class WxGameController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("添加游戏参与记录") | @ApiOperation("添加游戏参与记录") | ||||
| @GetMapping("checkLimit") | |||||
| @GetMapping("getCount") | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "gameId", value = "游戏ID", dataType = "String", paramType = "query", required = true)}) | @ApiImplicitParam(name = "gameId", value = "游戏ID", dataType = "String", paramType = "query", required = true)}) | ||||
| public ResultData checkLimit(String gameId) { | |||||
| public ResultData getCount(String gameId) { | |||||
| Long gameIdL = null; | Long gameIdL = null; | ||||
| try { | try { | ||||
| gameIdL = Long.valueOf(gameId); | gameIdL = Long.valueOf(gameId); | ||||
| @@ -83,6 +83,6 @@ public class WxGameController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | ||||
| } | } | ||||
| return wxGameService.checkLimit(gameIdL,getUserId()); | |||||
| return wxGameService.getCount(gameIdL,getUserId()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -122,8 +122,7 @@ public enum ErrorCode{ | |||||
| * 游戏 | * 游戏 | ||||
| */ | */ | ||||
| GAME_NOT_FOUND(2070, "游戏未找到"), | GAME_NOT_FOUND(2070, "游戏未找到"), | ||||
| GAME_PLAY_HAS_BEEN_LIMITED(2071, "游戏次数已达到上限"), | |||||
| GAME_AWARD_HAS_BEEN_LIMITED(2072, "游戏获奖已达到上限"), | |||||
| /** | /** | ||||
| * 订单 | * 订单 | ||||
| */ | */ | ||||
| @@ -26,7 +26,7 @@ public interface WxGameService { | |||||
| ResultData addActionLog(Long userId, Long gameId, Long orderId); | ResultData addActionLog(Long userId, Long gameId, Long orderId); | ||||
| ResultData checkLimit(Long gameId, Long userId); | |||||
| ResultData getCount(Long gameId, Long userId); | |||||
| /** | /** | ||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| * | * | ||||
| @@ -114,7 +114,7 @@ public class WxGameServiceImpl implements WxGameService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData checkLimit(Long gameId, Long userId) { | |||||
| public ResultData getCount(Long gameId, Long userId) { | |||||
| WxGame wxGame = wxGameMapper.selectByPrimaryKey(gameId); | WxGame wxGame = wxGameMapper.selectByPrimaryKey(gameId); | ||||
| if (wxGame == null) | if (wxGame == null) | ||||
| @@ -130,14 +130,16 @@ public class WxGameServiceImpl implements WxGameService { | |||||
| int playCount = wxGameActionLogMapper.getPlayCount(wxGameActionLog); | int playCount = wxGameActionLogMapper.getPlayCount(wxGameActionLog); | ||||
| int AwardCount = wxGameActionLogMapper.getAwardCount(wxGameActionLog); | int AwardCount = wxGameActionLogMapper.getAwardCount(wxGameActionLog); | ||||
| if ( playLimit != 0 | |||||
| && playCount >= playLimit) | |||||
| return new ResultData(ErrorCode.GAME_PLAY_HAS_BEEN_LIMITED); | |||||
| boolean playAble = !(( playLimit != 0 && playCount >= playLimit) | |||||
| || (AwardLimit != 0 && AwardCount >= AwardLimit)); | |||||
| if (AwardLimit != 0 | |||||
| && AwardCount >= AwardLimit) | |||||
| return new ResultData(ErrorCode.GAME_AWARD_HAS_BEEN_LIMITED); | |||||
| return new ResultData(playLimit - playCount); | |||||
| Map<String,Object> map = new HashMap(); | |||||
| map.put("playLimit",playLimit); | |||||
| map.put("AwardLimit",AwardLimit); | |||||
| map.put("playCount",playCount); | |||||
| map.put("AwardCount",AwardCount); | |||||
| map.put("playAble",playAble); | |||||
| return new ResultData(map); | |||||
| } | } | ||||