|
@@ -20,7 +20,6 @@ import com.zanxiang.game.module.mybatis.mapper.GameGiftPackCodeLogMapper;
|
|
|
import com.zanxiang.module.redis.service.IDistributedLockComponent;
|
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
-import com.zanxiang.module.util.exception.BaseException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
@@ -110,22 +109,23 @@ public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCode
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getGiftPackCode(Long linkLogId, String userPhone, String randomCode) {
|
|
|
+
|
|
|
+ GameGiftPackLinkLog gameGiftPackLinkLog = gameGiftPackLinkLogService.getById(linkLogId);
|
|
|
+ Assert.notNull(gameGiftPackLinkLog, "参数错误, 链接访问日志信息不存在");
|
|
|
+
|
|
|
+ String userId = gameGiftPackLinkLog.getUserId() == null ? null : gameGiftPackLinkLog.getUserId().toString();
|
|
|
+ Assert.state(StringUtils.isNoneBlank(userId, gameGiftPackLinkLog.getServerId(), gameGiftPackLinkLog.getRoleId(),
|
|
|
+ gameGiftPackLinkLog.getRoleName()), "参数错误, 链接访问记录信息缺失");
|
|
|
+
|
|
|
+ String phoneNum = userPhone.contains("****") ? gameGiftPackLinkLog.getUserPhone() : userPhone;
|
|
|
|
|
|
- String lockKey = RedisKeyConstant.GAME_GIFT_PACK_LOCK + userPhone;
|
|
|
-
|
|
|
- if (!distributedLockComponent.doLock(lockKey, 0L, 5L, TimeUnit.MINUTES)) {
|
|
|
- throw new BaseException("操作频繁, 请稍后重试");
|
|
|
- }
|
|
|
+ String lockKey = RedisKeyConstant.GAME_GIFT_PACK_LOCK + phoneNum;
|
|
|
+
|
|
|
+ Assert.state(distributedLockComponent.doLock(lockKey, 0L, 3L, TimeUnit.MINUTES), "操作频繁, 请稍后重试");
|
|
|
+
|
|
|
try {
|
|
|
- GameGiftPackLinkLog gameGiftPackLinkLog = gameGiftPackLinkLogService.getById(linkLogId);
|
|
|
- Assert.notNull(gameGiftPackLinkLog, "参数错误, 链接访问日志信息不存在");
|
|
|
-
|
|
|
- Long userId = gameGiftPackLinkLog.getUserId();
|
|
|
- Assert.state(StringUtils.isNoneBlank(userId == null ? null : userId.toString(), gameGiftPackLinkLog.getServerId(),
|
|
|
- gameGiftPackLinkLog.getRoleId(), gameGiftPackLinkLog.getRoleName()), "参数错误, 链接访问记录信息缺失");
|
|
|
-
|
|
|
Map<String, Object> resuktMap = new HashMap<>(2);
|
|
|
- Tuple2<Boolean, String> tuple2 = this.getRandomCode(randomCode, userPhone, gameGiftPackLinkLog);
|
|
|
+ Tuple2<Boolean, String> tuple2 = this.getRandomCode(randomCode, phoneNum, gameGiftPackLinkLog);
|
|
|
resuktMap.put("result", tuple2.first);
|
|
|
resuktMap.put("msg", tuple2.second);
|
|
|
return resuktMap;
|