|
@@ -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;
|
|
|
//线程锁key
|
|
|
- String lockKey = RedisKeyConstant.GAME_GIFT_PACK_LOCK + userPhone;
|
|
|
- //线程锁 5 分钟, 防止同一用户重复请求
|
|
|
- if (!distributedLockComponent.doLock(lockKey, 0L, 5L, TimeUnit.MINUTES)) {
|
|
|
- throw new BaseException("操作频繁, 请稍后重试");
|
|
|
- }
|
|
|
+ String lockKey = RedisKeyConstant.GAME_GIFT_PACK_LOCK + phoneNum;
|
|
|
+ //线程锁 3 分钟, 防止同一用户重复请求
|
|
|
+ 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;
|