|
@@ -21,11 +21,13 @@ 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;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.support.TransactionTemplate;
|
|
|
+import org.springframework.util.Assert;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -41,6 +43,7 @@ import java.util.stream.Collectors;
|
|
|
* @time : 2022-06-22
|
|
|
* @description : 游戏礼包码领取日志
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCodeLogMapper, GameGiftPackCodeLog> implements IGameGiftPackCodeLogService {
|
|
|
|
|
@@ -56,9 +59,6 @@ public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCode
|
|
|
@Autowired
|
|
|
private RedisUtil<String> redisUtil;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IGameServerService gameServerService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IRoleOperateService roleOperateService;
|
|
|
|
|
@@ -116,11 +116,11 @@ public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCode
|
|
|
throw new BaseException("操作频繁, 请稍后重试");
|
|
|
}
|
|
|
GameGiftPackLinkLog gameGiftPackLinkLog = gameGiftPackLinkLogService.getById(linkId);
|
|
|
- assert gameGiftPackLinkLog != null : "参数错误, 链接访问日志信息不存在";
|
|
|
+ Assert.notNull(gameGiftPackLinkLog, "参数错误, 链接访问日志信息不存在");
|
|
|
//判断验证是通过的
|
|
|
Long userId = gameGiftPackLinkLog.getUserId();
|
|
|
- assert StringUtils.isNoneBlank(userId == null ? null : userId.toString(), gameGiftPackLinkLog.getServerId(),
|
|
|
- gameGiftPackLinkLog.getRoleId(), gameGiftPackLinkLog.getRoleName()) : "参数错误, 链接访问记录信息缺失";
|
|
|
+ Assert.state(StringUtils.isNoneBlank(userId == null ? null : userId.toString(), gameGiftPackLinkLog.getServerId(),
|
|
|
+ gameGiftPackLinkLog.getRoleId(), gameGiftPackLinkLog.getRoleName()), "参数错误, 链接访问记录信息缺失");
|
|
|
//获取礼包码, 且执行释放锁动作
|
|
|
try {
|
|
|
return this.getRandomCode(randomCode, userPhone, gameGiftPackLinkLog);
|
|
@@ -138,7 +138,7 @@ public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCode
|
|
|
return Tuple2.with(Boolean.TRUE, repeatCheck.second);
|
|
|
}
|
|
|
//异步更新角色操作表
|
|
|
- roleOperateService.roleOperateUpdate(linkLog);
|
|
|
+ roleOperateService.roleOperateUpdate(userPhone, linkLog);
|
|
|
//构造记录
|
|
|
GameGiftPackCodeLog gameGiftPackCodeLog = this.transform(linkLog, userPhone);
|
|
|
//从缓存中获取一个礼包码id, 如果缓存中不存在则是领完了
|
|
@@ -151,7 +151,7 @@ public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCode
|
|
|
}
|
|
|
//查询礼包码具体信息, 礼包码必须存在, 且未被领取, 否则数据错误
|
|
|
GameGiftPackCode gameGiftPackCode = gameGiftPackCodeService.getById(Long.valueOf(codeId));
|
|
|
- assert gameGiftPackCode != null && !gameGiftPackCode.getIsSend() : "礼包码数据错误, 请联系客服小姐姐处理";
|
|
|
+ Assert.notNull(gameGiftPackCode, "礼包码数据错误, 请联系客服小姐姐处理");
|
|
|
//判断是否满足领取条件
|
|
|
Tuple2<Boolean, String> conditionCheck = this.conditionCheck(linkLog);
|
|
|
//设置判定消息
|
|
@@ -213,7 +213,7 @@ public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCode
|
|
|
|
|
|
private Tuple2<Boolean, String> conditionCheck(GameGiftPackLinkLog gameGiftPackLinkLog) {
|
|
|
GameGiftPackLink giftPackLink = gameGiftPackLinkService.getById(gameGiftPackLinkLog.getLinkId());
|
|
|
- assert giftPackLink != null : "参数错误, 礼包链接信息不存在";
|
|
|
+ Assert.notNull(giftPackLink, "参数错误, 礼包链接信息不存在");
|
|
|
String codeCheck = giftPackLink.getCodeCheck();
|
|
|
if (Strings.isBlank(codeCheck)) {
|
|
|
return Tuple2.with(Boolean.TRUE, "领取成功, 礼包码领取条件 - 不存在");
|