From 15e6f15a121e06f77239e86470de65fa3fdbee85 Mon Sep 17 00:00:00 2001 From: hupeng Date: Wed, 13 Mar 2019 11:21:24 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=B8=B8=E6=88=8F][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=A2=9E=E5=8A=A0=E5=8F=82=E4=B8=8E=E6=AC=A1?= =?UTF-8?q?=E6=95=B0,=E8=8E=B7=E5=A5=96=E6=AC=A1=E6=95=B0=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/controller/WxGameController.java | 2 +- .../java/com/iformall/common/ErrorCode.java | 5 +- .../java/com/iformall/domain/po/WxGame.java | 65 ++++++++++++++++- .../mapper/WxGameActionLogMapper.java | 4 +- .../service/impl/WxGameServiceImpl.java | 15 +++- .../mapper/WxGameActionLogMapper.xml | 72 ++++++++++++++++--- .../main/resources/mapper/WxGameMapper.xml | 27 +++++-- 7 files changed, 165 insertions(+), 25 deletions(-) diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java index e1119fe71..f7aa591f4 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java @@ -85,7 +85,7 @@ public class WxGameController extends BaseController { } @ApiOperation("添加游戏参与记录") - @PostMapping("checkLimit") + @GetMapping("checkLimit") @ApiImplicitParams({ @ApiImplicitParam(name = "gameId", value = "游戏ID", dataType = "String", paramType = "query", required = true)}) public ResultData checkLimit(String gameId) { diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index 7dfba11ac..58b9e4651 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -90,7 +90,7 @@ public enum ErrorCode{ COUPON_CHANNEL_IS_EXISTED(2027, "此券已投放过"), COUPON_SEND_IS_EXISTED(2028, "此券已经添加到该渠道"), COUPON_SEND_IS_INVALID(2029, "此发券渠道不存在"), - COUPON_SEND_IS_INVALID_TIME(2030, "发放时间不能晚于使用时间"), + COUPON_SEND_IS_INVALID_TIME(2030, "投放的时间超出劵的有效期"), COUPON_CHANNEL_IS_TAKE_OFF(2031, "此券已下架"), COUPON_MERCHANT_NOT_FOUND(2032, "卡券关联商户未发现"), COUPON_CHANNEL_IS_NOT_STARTED(2033, "此券活动未开始"), @@ -122,7 +122,8 @@ public enum ErrorCode{ * 游戏 */ GAME_NOT_FOUND(2070, "游戏未找到"), - GAME_HAS_BEEN_LIMITED(2071, "游戏次数以达到上限"), + GAME_PLAY_HAS_BEEN_LIMITED(2071, "游戏次数已达到上限"), + GAME_AWARD_HAS_BEEN_LIMITED(2072, "游戏获奖已达到上限"), /** * 订单 */ diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxGame.java b/mallinkService/src/main/java/com/iformall/domain/po/WxGame.java index b060301e4..f75860d99 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxGame.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxGame.java @@ -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; + /** + * 获奖次数限制 + */ + @io.swagger.annotations.ApiModelProperty(value = "限奖次数(0:不受限制,n:限奖次数)", name = "awardLimit") + private Integer awardLimit; @Transient @io.swagger.annotations.ApiModelProperty(value = "已投放券信息") @@ -189,6 +194,61 @@ public class WxGame implements Serializable { 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) { if (gameTemplate != null) { @@ -209,7 +269,8 @@ public class WxGame implements Serializable { , ValidStartDate_ASC("`valid_start_date` ASC"), ValidStartDate_DESC("`valid_start_date` DESC") , ValidEndDate_ASC("`valid_end_date` ASC"), ValidEndDate_DESC("`valid_end_date` 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; Field(String value) { diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java index e11f8d43a..c5e778152 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java @@ -8,6 +8,6 @@ import java.util.List; public interface WxGameActionLogMapper extends CommonMapper { List findList(WxGameActionLog wxGameActionLog); - int getCount(WxGameActionLog wxGameActionLog); - + int getPlayCount(WxGameActionLog wxGameActionLog); + int getAwardCount(WxGameActionLog wxGameActionLog); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java index 97f89cd1a..5ba5a7a61 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java @@ -92,13 +92,22 @@ public class WxGameServiceImpl implements WxGameService { @Override 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.setTenantId(wxGame.getTenantId()); wxGameActionLog.setUserId(userId); 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(); } diff --git a/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml index 27086d1f8..20e4082f6 100644 --- a/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml @@ -33,25 +33,28 @@ - and `user_id` = #{userId} + and `user_id` = #{userId} - - and `coupon_order_id` = #{couponOrderId} - + + and `coupon_order_id` = #{couponOrderId} + and `create_time` = #{createTime} + - and `create_time` >= #{startTime} + and `start_time` >= #{startTime} + - and `create_time` <= #{endTime} + and `end_time` <= #{endTime} + @@ -68,9 +71,62 @@ - select COUNT(*) FROM wx_game_action_log a - + + + + diff --git a/mallinkService/src/main/resources/mapper/WxGameMapper.xml b/mallinkService/src/main/resources/mapper/WxGameMapper.xml index cc8f401eb..06be2ead2 100644 --- a/mallinkService/src/main/resources/mapper/WxGameMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxGameMapper.xml @@ -11,38 +11,51 @@ + - `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` where 1 = 1 and `id` = #{id} - + + and `tenant_id` like concat('%', #{tenantId},'%') - + + and `game_id` = #{gameId} - + + and `status` = #{status} - + + and `valid_start_date` = #{validStartDate} - + + and `valid_end_date` = #{validEndDate} - + + and `triggle_action` = #{triggleAction} + and `play_limit` = #{playLimit} + + + and `award_limit` = #{awardLimit} + + and id in