From c53f26f1392d686757ae1d3a6d31c8adf6bf7aba Mon Sep 17 00:00:00 2001 From: xhxu Date: Wed, 6 Jan 2021 10:55:36 +0800 Subject: [PATCH] youxi --- .../iformall/controller/WxGameController.java | 15 +++---- .../service/impl/WxGameServiceImpl.java | 40 ++++++++++--------- .../java/com/iformall/utils/Constant.java | 9 +++++ 3 files changed, 39 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 df4086083..79cfa6d91 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxGameController.java @@ -6,6 +6,7 @@ import com.iformall.domain.po.*; import com.iformall.enums.EnumGameStatus; import com.iformall.service.WxCouponOrderService; import com.iformall.service.WxGameService; +import com.iformall.utils.Constant; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @@ -105,16 +106,16 @@ public class WxGameController extends BaseController { return new ResultData(ErrorCode.GAME_NOT_FOUND); } int playLimit = (int) data.get("playLimit"); - if(playLimit < 0){ + if(playLimit < Constant.limit){ return new ResultData(ErrorCode.GAME_NOT_COUNT); } int AwardLimit = (int) data.get("AwardLimit"); int AwardCount = (int) data.get("AwardCount"); - if(AwardLimit != 0 && AwardCount >= AwardLimit){ + if(AwardLimit != Constant.limit && AwardCount >= AwardLimit){ return new ResultData(ErrorCode.GAME_NOT_WIN_COUNT); } int playCount = (int) data.get("playCount"); - if((playLimit > 0 && playCount >= playLimit) || playLimit < 0){ + if((playLimit > Constant.limit && playCount >= playLimit) || playLimit == Constant.notLimit){ return new ResultData(ErrorCode.GAME_NOT_HAVE_COUNT); } ResultData resultData = wxGameService.luckDraw(gameIdL, getMemberId(),0); @@ -141,19 +142,19 @@ public class WxGameController extends BaseController { return new ResultData(ErrorCode.GAME_NOT_FOUND); } int playLimit = (int) data.get("playLimit"); - if(playLimit < 0){ + if(playLimit < Constant.limit){ return new ResultData(ErrorCode.GAME_NOT_COUNT); } int AwardLimit = (int) data.get("AwardLimit"); int AwardCount = (int) data.get("AwardCount"); - if(AwardLimit != 0 && AwardCount >= AwardLimit){ + if(AwardLimit != Constant.limit && AwardCount >= AwardLimit){ return new ResultData(ErrorCode.GAME_NOT_WIN_COUNT); } int playCount = (int) data.get("playCount"); - if((playLimit > 0 && playCount >= playLimit) || playLimit < 0){ + if((playLimit > Constant.limit && playCount >= playLimit) || playLimit == Constant.notLimit){ int playCreditLimit = (int) data.get("playCreditLimit"); int playCreditCount = (int) data.get("playCreditCount"); - if((playCreditLimit > 0 && playCreditCount >= playCreditLimit) || playCreditLimit < 0){//积分不能玩了 + if((playCreditLimit > Constant.limit && playCreditCount >= playCreditLimit) || playCreditLimit == Constant.notLimit){//积分不能玩了 return new ResultData(ErrorCode.GAME_NOT_HAVEC_COUNT); } }else{ 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 587ba2933..2840b8ec1 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java @@ -157,7 +157,7 @@ public class WxGameServiceImpl implements WxGameService { WxGameActionLog wxGameActionLog = new WxGameActionLog(); - if(wxGame.getLimitType().equals(1)){//每天 + if(wxGame.getLimitType().equals(Constant.limitType)){//每天 Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.set(Calendar.HOUR_OF_DAY, 0); @@ -197,11 +197,11 @@ public class WxGameServiceImpl implements WxGameService { map.put("AwardCount",AwardCount);//当前中奖次数 boolean playAble = true; - if(AwardLimit != 0 && AwardCount >= AwardLimit){//中奖次数没了,不能完了 + if(AwardLimit != Constant.limit && AwardCount >= AwardLimit){//中奖次数没了,不能完了 playAble = false; } - if((playLimit > 0 && playCount >= playLimit) || playLimit < 0){//免费不能玩了 - if((playCreditLimit > 0 && playCreditCount >= playCreditLimit) || playCreditLimit < 0){//积分不能玩了 + if((playLimit > Constant.limit && playCount >= playLimit) || playLimit == Constant.notLimit){//免费不能玩了 + if((playCreditLimit > Constant.limit && playCreditCount >= playCreditLimit) || playCreditLimit == Constant.notLimit){//积分不能玩了 playAble = false; } } @@ -231,15 +231,16 @@ public class WxGameServiceImpl implements WxGameService { List couponIdsList = new ArrayList(); JSONArray couponChannelIds = JSON.parseArray(record.getCouponIds()); ValueOperations operations = cdRedisTemplate.opsForValue(); - for(int i=0; i map = new HashMap<>(); - map.put("prizeType",0); + map.put("prizeType",Constant.creditPlayType); map.put("gameWeight",couponChanObj.getInteger("weight")); map.put("credit",couponChanObj.getInteger("credit")); - map.put("couponId",couponChanObj.getLong("couponId")); + map.put("id",couponChanObj.getInteger("id")); +// map.put("couponId",couponChanObj.getLong("couponId")); couponIdsList.add(map); }else{ Long couponId = couponChanObj.getLong("couponId"); @@ -327,14 +328,17 @@ public class WxGameServiceImpl implements WxGameService { // 上架 couponChannel 更新 for(int i=0; i 0){ - wxGameActionLog.setType(1); + wxGameActionLog.setType(Constant.creditPlayType); } wxGameActionLog.setCouponOrderId(orderId); wxGameActionLog.setAddCredit(addCredit); diff --git a/mallinkService/src/main/java/com/iformall/utils/Constant.java b/mallinkService/src/main/java/com/iformall/utils/Constant.java index 51d0b893c..0cf5eb9d8 100644 --- a/mallinkService/src/main/java/com/iformall/utils/Constant.java +++ b/mallinkService/src/main/java/com/iformall/utils/Constant.java @@ -10,6 +10,15 @@ public class Constant { public static final int WX_LIMIT_DAYS = 30; // 微信分账限制30天 + //游戏常量 + public static final int limit = 0;//游戏玩法不限次数 + public static final int notLimit = -1;//游戏玩法不限能玩 + + public static final int creditPlayType = 1;//积分玩法类型 + public static final Long creditPlayOrderIdTab = -1L;//积分中奖 orderId标识 + + public static final int limitType = 1;//游戏玩法次数类型 表示每天的次数 + // 前端未初始常量 public static final String UNDEFINED = "undefined";