Просмотр исходного кода

[游戏][修改]:游戏增加参与次数,获奖次数限制

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
15e6f15a12
7 измененных файлов: 165 добавлений и 25 удалений
  1. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java
  2. +3
    -2
      mallinkService/src/main/java/com/iformall/common/ErrorCode.java
  3. +63
    -2
      mallinkService/src/main/java/com/iformall/domain/po/WxGame.java
  4. +2
    -2
      mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java
  5. +12
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java
  6. +64
    -8
      mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml
  7. +20
    -7
      mallinkService/src/main/resources/mapper/WxGameMapper.xml

+ 1
- 1
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) {


+ 3
- 2
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, "游戏获奖已达到上限"),
/**
* 订单
*/


+ 63
- 2
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) {


+ 2
- 2
mallinkService/src/main/java/com/iformall/mapper/WxGameActionLogMapper.java Просмотреть файл

@@ -8,6 +8,6 @@ import java.util.List;
public interface WxGameActionLogMapper extends CommonMapper<WxGameActionLog, String> {

List<WxGameActionLog> findList(WxGameActionLog wxGameActionLog);
int getCount(WxGameActionLog wxGameActionLog);
int getPlayCount(WxGameActionLog wxGameActionLog);
int getAwardCount(WxGameActionLog wxGameActionLog);
}

+ 12
- 3
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();
}



+ 64
- 8
mallinkService/src/main/resources/mapper/WxGameActionLogMapper.xml Просмотреть файл

@@ -33,25 +33,28 @@
</if>

<if test=" null != userId ">
and `user_id` = #{userId}
and `user_id` = #{userId}

</if>

<if test=" null != couponOrderId ">
and `coupon_order_id` = #{couponOrderId}
<if test=" null != couponOrderId ">
and `coupon_order_id` = #{couponOrderId}
</if>
<if test=" null != createTime ">
and `create_time` = #{createTime}

</if>

<if test=" null != startTime ">
and `create_time` &gt;= #{startTime}
and `start_time` &gt;= #{startTime}

</if>

<if test=" null != endTime ">
and `create_time` &lt;= #{endTime}
and `end_time` &lt;= #{endTime}

</if>

<if test=" null != ids ">
@@ -68,9 +71,62 @@
<include refid="dynamicWhereConditions" />
</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` &gt;= #{startTime}

</if>

<if test=" null != endTime ">
and `end_time` &lt;= #{endTime}

</if>


</sql>

<select id="getPlayCount" resultType="java.lang.Integer" parameterType="com.iformall.domain.po.WxGameActionLog">
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>

</mapper>

+ 20
- 7
mallinkService/src/main/resources/mapper/WxGameMapper.xml Просмотреть файл

@@ -11,38 +11,51 @@
<result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate" />
<result column="triggle_action" jdbcType="INTEGER" property="triggleAction" />
<result column="play_limit" jdbcType="INTEGER" property="playLimit" />
<result column="award_limit" jdbcType="INTEGER" property="awardLimit" />
</resultMap>
<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 id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id ">
and `id` = #{id}
</if>
</if>

<if test=" null != tenantId ">
and `tenant_id` like concat('%', #{tenantId},'%')
</if>
</if>

<if test=" null != gameId ">
and `game_id` = #{gameId}
</if>
</if>

<if test=" null != status ">
and `status` = #{status}
</if>
</if>

<if test=" null != validStartDate ">
and `valid_start_date` = #{validStartDate}
</if>
</if>

<if test=" null != validEndDate ">
and `valid_end_date` = #{validEndDate}
</if>
</if>

<if test=" null != triggleAction ">
and `triggle_action` = #{triggleAction}
</if>

<if test=" null != playLimit ">
and `play_limit` = #{playLimit}
</if>

<if test=" null != awardLimit ">
and `award_limit` = #{awardLimit}
</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


Загрузка…
Отмена
Сохранить