| @@ -85,7 +85,7 @@ public class WxGameController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("添加游戏参与记录") | @ApiOperation("添加游戏参与记录") | ||||
| @PostMapping("checkLimit") | |||||
| @GetMapping("checkLimit") | |||||
| @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 checkLimit(String gameId) { | ||||
| @@ -90,7 +90,7 @@ public enum ErrorCode{ | |||||
| COUPON_CHANNEL_IS_EXISTED(2027, "此券已投放过"), | COUPON_CHANNEL_IS_EXISTED(2027, "此券已投放过"), | ||||
| COUPON_SEND_IS_EXISTED(2028, "此券已经添加到该渠道"), | COUPON_SEND_IS_EXISTED(2028, "此券已经添加到该渠道"), | ||||
| COUPON_SEND_IS_INVALID(2029, "此发券渠道不存在"), | COUPON_SEND_IS_INVALID(2029, "此发券渠道不存在"), | ||||
| COUPON_SEND_IS_INVALID_TIME(2030, "发放时间不能晚于使用时间"), | |||||
| COUPON_SEND_IS_INVALID_TIME(2030, "投放的时间超出劵的有效期"), | |||||
| COUPON_CHANNEL_IS_TAKE_OFF(2031, "此券已下架"), | COUPON_CHANNEL_IS_TAKE_OFF(2031, "此券已下架"), | ||||
| COUPON_MERCHANT_NOT_FOUND(2032, "卡券关联商户未发现"), | COUPON_MERCHANT_NOT_FOUND(2032, "卡券关联商户未发现"), | ||||
| COUPON_CHANNEL_IS_NOT_STARTED(2033, "此券活动未开始"), | COUPON_CHANNEL_IS_NOT_STARTED(2033, "此券活动未开始"), | ||||
| @@ -122,7 +122,8 @@ public enum ErrorCode{ | |||||
| * 游戏 | * 游戏 | ||||
| */ | */ | ||||
| GAME_NOT_FOUND(2070, "游戏未找到"), | GAME_NOT_FOUND(2070, "游戏未找到"), | ||||
| GAME_HAS_BEEN_LIMITED(2071, "游戏次数以达到上限"), | |||||
| GAME_PLAY_HAS_BEEN_LIMITED(2071, "游戏次数已达到上限"), | |||||
| GAME_AWARD_HAS_BEEN_LIMITED(2072, "游戏获奖已达到上限"), | |||||
| /** | /** | ||||
| * 订单 | * 订单 | ||||
| */ | */ | ||||
| @@ -60,9 +60,14 @@ public class WxGame implements Serializable { | |||||
| /** | /** | ||||
| * 玩次数限制 | * 玩次数限制 | ||||
| */ | */ | ||||
| @io.swagger.annotations.ApiModelProperty(value = "触发条件(0:不受限制,n:限玩次数)", name = "playLimit") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "限玩次数(0:不受限制,n:限玩次数)", name = "playLimit") | |||||
| private Integer playLimit; | private Integer playLimit; | ||||
| /** | |||||
| * 获奖次数限制 | |||||
| */ | |||||
| @io.swagger.annotations.ApiModelProperty(value = "限奖次数(0:不受限制,n:限奖次数)", name = "awardLimit") | |||||
| private Integer awardLimit; | |||||
| @Transient | @Transient | ||||
| @io.swagger.annotations.ApiModelProperty(value = "已投放券信息") | @io.swagger.annotations.ApiModelProperty(value = "已投放券信息") | ||||
| @@ -189,6 +194,61 @@ public class WxGame implements Serializable { | |||||
| this.couponIdsList = couponIdsList; | this.couponIdsList = couponIdsList; | ||||
| } | } | ||||
| public Integer getAwardLimit() { | |||||
| return awardLimit; | |||||
| } | |||||
| public void setAwardLimit(Integer awardLimit) { | |||||
| this.awardLimit = awardLimit; | |||||
| } | |||||
| public String getName() { | |||||
| return name; | |||||
| } | |||||
| public void setName(String name) { | |||||
| this.name = name; | |||||
| } | |||||
| public String getUrl() { | |||||
| return url; | |||||
| } | |||||
| public void setUrl(String url) { | |||||
| this.url = url; | |||||
| } | |||||
| public String getImgUrl() { | |||||
| return imgUrl; | |||||
| } | |||||
| public void setImgUrl(String imgUrl) { | |||||
| this.imgUrl = imgUrl; | |||||
| } | |||||
| public Integer getOptionLimit() { | |||||
| return optionLimit; | |||||
| } | |||||
| public void setOptionLimit(Integer optionLimit) { | |||||
| this.optionLimit = optionLimit; | |||||
| } | |||||
| public String getRules() { | |||||
| return rules; | |||||
| } | |||||
| public void setRules(String rules) { | |||||
| this.rules = rules; | |||||
| } | |||||
| public Integer getType() { | |||||
| return type; | |||||
| } | |||||
| public void setType(Integer type) { | |||||
| this.type = type; | |||||
| } | |||||
| public void setGameTemplate(WxGameTemplate gameTemplate) { | public void setGameTemplate(WxGameTemplate gameTemplate) { | ||||
| if (gameTemplate != null) { | if (gameTemplate != null) { | ||||
| @@ -209,7 +269,8 @@ public class WxGame implements Serializable { | |||||
| , ValidStartDate_ASC("`valid_start_date` ASC"), ValidStartDate_DESC("`valid_start_date` DESC") | , ValidStartDate_ASC("`valid_start_date` ASC"), ValidStartDate_DESC("`valid_start_date` DESC") | ||||
| , ValidEndDate_ASC("`valid_end_date` ASC"), ValidEndDate_DESC("`valid_end_date` DESC") | , ValidEndDate_ASC("`valid_end_date` ASC"), ValidEndDate_DESC("`valid_end_date` DESC") | ||||
| , TriggleAction_ASC("`triggle_action` ASC"), TriggleAction_DESC("`triggle_action` DESC") | , TriggleAction_ASC("`triggle_action` ASC"), TriggleAction_DESC("`triggle_action` DESC") | ||||
| , PlayLimit_ASC("`play_limit` ASC"), PlayLimit_DESC("`play_limit` DESC"); | |||||
| , PlayLimit_ASC("`play_limit` ASC"), PlayLimit_DESC("`play_limit` DESC") | |||||
| , AwardLimit_ASC("`award_limit` ASC"), AwardLimit_DESC("`award_limit` DESC"); | |||||
| private String value; | private String value; | ||||
| Field(String value) { | Field(String value) { | ||||
| @@ -8,6 +8,6 @@ import java.util.List; | |||||
| public interface WxGameActionLogMapper extends CommonMapper<WxGameActionLog, String> { | public interface WxGameActionLogMapper extends CommonMapper<WxGameActionLog, String> { | ||||
| List<WxGameActionLog> findList(WxGameActionLog wxGameActionLog); | List<WxGameActionLog> findList(WxGameActionLog wxGameActionLog); | ||||
| int getCount(WxGameActionLog wxGameActionLog); | |||||
| int getPlayCount(WxGameActionLog wxGameActionLog); | |||||
| int getAwardCount(WxGameActionLog wxGameActionLog); | |||||
| } | } | ||||
| @@ -92,13 +92,22 @@ public class WxGameServiceImpl implements WxGameService { | |||||
| @Override | @Override | ||||
| public ResultData checkLimit(Long gameId, Long userId) { | public ResultData checkLimit(Long gameId, Long userId) { | ||||
| WxGame wxGame = wxGameMapper.selectByPrimaryKey(gameId); | |||||
| if (wxGame == null) | |||||
| return new ResultData(ErrorCode.GAME_NOT_FOUND); | |||||
| WxGameActionLog wxGameActionLog = new WxGameActionLog(); | WxGameActionLog wxGameActionLog = new WxGameActionLog(); | ||||
| wxGameActionLog.setTenantId(wxGame.getTenantId()); | |||||
| wxGameActionLog.setUserId(userId); | wxGameActionLog.setUserId(userId); | ||||
| wxGameActionLog.setGameId(gameId); | wxGameActionLog.setGameId(gameId); | ||||
| int limit = wxGameMapper.selectByPrimaryKey(gameId).getPlayLimit(); | |||||
| if (limit != 0 && wxGameActionLogMapper.getCount(wxGameActionLog) > limit) | |||||
| return new ResultData(ErrorCode.GAME_HAS_BEEN_LIMITED); | |||||
| if (wxGame.getPlayLimit() != 0 | |||||
| && wxGameActionLogMapper.getPlayCount(wxGameActionLog) > wxGame.getPlayLimit()) | |||||
| return new ResultData(ErrorCode.GAME_PLAY_HAS_BEEN_LIMITED); | |||||
| if (wxGame.getAwardLimit() != 0 | |||||
| && wxGameActionLogMapper.getAwardCount(wxGameActionLog) > wxGame.getAwardLimit()) | |||||
| return new ResultData(ErrorCode.GAME_AWARD_HAS_BEEN_LIMITED); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -33,25 +33,28 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != userId "> | <if test=" null != userId "> | ||||
| and `user_id` = #{userId} | |||||
| and `user_id` = #{userId} | |||||
| </if> | </if> | ||||
| <if test=" null != couponOrderId "> | |||||
| and `coupon_order_id` = #{couponOrderId} | |||||
| <if test=" null != couponOrderId "> | |||||
| and `coupon_order_id` = #{couponOrderId} | |||||
| </if> | </if> | ||||
| <if test=" null != createTime "> | <if test=" null != createTime "> | ||||
| and `create_time` = #{createTime} | and `create_time` = #{createTime} | ||||
| </if> | </if> | ||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and `create_time` >= #{startTime} | |||||
| and `start_time` >= #{startTime} | |||||
| </if> | </if> | ||||
| <if test=" null != endTime "> | <if test=" null != endTime "> | ||||
| and `create_time` <= #{endTime} | |||||
| and `end_time` <= #{endTime} | |||||
| </if> | </if> | ||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| @@ -68,9 +71,62 @@ | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="getCount" resultType="java.lang.Integer" parameterType="com.iformall.domain.po.WxGameActionLog"> | |||||
| <sql id="dynamicCountWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != gameId "> | |||||
| and `game_id` = #{gameId} | |||||
| </if> | |||||
| <if test=" null != userId "> | |||||
| and `user_id` = #{userId} | |||||
| </if> | |||||
| <if test=" null != couponOrderId "> | |||||
| and `coupon_order_id` = #{couponOrderId} | |||||
| </if> | |||||
| <if test=" null != createTime "> | |||||
| and `create_time` = #{createTime} | |||||
| </if> | |||||
| <if test=" null != startTime "> | |||||
| and `start_time` >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime "> | |||||
| and `end_time` <= #{endTime} | |||||
| </if> | |||||
| </sql> | |||||
| <select id="getPlayCount" resultType="java.lang.Integer" parameterType="com.iformall.domain.po.WxGameActionLog"> | |||||
| select COUNT(*) FROM wx_game_action_log a | select COUNT(*) FROM wx_game_action_log a | ||||
| <include refid="dynamicWhereConditions" /> | |||||
| <include refid="dynamicCountWhereConditions" /> | |||||
| </select> | |||||
| <select id="getAwardCount" resultType="java.lang.Integer" parameterType="com.iformall.domain.po.WxGameActionLog"> | |||||
| select COUNT(*) FROM wx_game_action_log a | |||||
| <include refid="dynamicCountWhereConditions" /> | |||||
| and coupon_order_id != 0 | |||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||
| @@ -11,38 +11,51 @@ | |||||
| <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate" /> | <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate" /> | ||||
| <result column="triggle_action" jdbcType="INTEGER" property="triggleAction" /> | <result column="triggle_action" jdbcType="INTEGER" property="triggleAction" /> | ||||
| <result column="play_limit" jdbcType="INTEGER" property="playLimit" /> | <result column="play_limit" jdbcType="INTEGER" property="playLimit" /> | ||||
| <result column="award_limit" jdbcType="INTEGER" property="awardLimit" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`game_id`,`status`,`coupon_ids`,`valid_start_date`,`valid_end_date`,`triggle_action`,`play_limit` | |||||
| `id`,`tenant_id`,`game_id`,`status`,`coupon_ids`,`valid_start_date`,`valid_end_date`,`triggle_action`,`play_limit`,`award_limit` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| where 1 = 1 | where 1 = 1 | ||||
| <if test=" null != id "> | <if test=" null != id "> | ||||
| and `id` = #{id} | and `id` = #{id} | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != tenantId "> | <if test=" null != tenantId "> | ||||
| and `tenant_id` like concat('%', #{tenantId},'%') | and `tenant_id` like concat('%', #{tenantId},'%') | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != gameId "> | <if test=" null != gameId "> | ||||
| and `game_id` = #{gameId} | and `game_id` = #{gameId} | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != status "> | <if test=" null != status "> | ||||
| and `status` = #{status} | and `status` = #{status} | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != validStartDate "> | <if test=" null != validStartDate "> | ||||
| and `valid_start_date` = #{validStartDate} | and `valid_start_date` = #{validStartDate} | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != validEndDate "> | <if test=" null != validEndDate "> | ||||
| and `valid_end_date` = #{validEndDate} | and `valid_end_date` = #{validEndDate} | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != triggleAction "> | <if test=" null != triggleAction "> | ||||
| and `triggle_action` = #{triggleAction} | and `triggle_action` = #{triggleAction} | ||||
| </if> | </if> | ||||
| <if test=" null != playLimit "> | <if test=" null != playLimit "> | ||||
| and `play_limit` = #{playLimit} | and `play_limit` = #{playLimit} | ||||
| </if> | </if> | ||||
| <if test=" null != awardLimit "> | |||||
| and `award_limit` = #{awardLimit} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||