diff --git a/src/main/java/com/ycwl/basic/utils/NotificationAuthUtils.java b/src/main/java/com/ycwl/basic/utils/NotificationAuthUtils.java index ca69db13..873e2ad6 100644 --- a/src/main/java/com/ycwl/basic/utils/NotificationAuthUtils.java +++ b/src/main/java/com/ycwl/basic/utils/NotificationAuthUtils.java @@ -92,23 +92,21 @@ public class NotificationAuthUtils { * @return 是否检查并消费成功 */ public boolean checkAndConsumeAuthorization(Long memberId, String templateId, Long scenicId) { - // 测试 - return true; -// try { -// // 先检查剩余次数 -// Integer remainingCount = userNotificationAuthorizationService.getRemainingCount(memberId, templateId, scenicId); -// if (remainingCount == null || remainingCount <= 0) { -// log.debug("用户剩余授权次数不足: memberId={}, templateId={}, scenicId={}, remainingCount={}", -// memberId, templateId, scenicId, remainingCount); -// return false; -// } -// -// // 尝试消费 -// return consumeAuthorization(memberId, templateId, scenicId); -// } catch (Exception e) { -// log.error("检查并消费授权异常: memberId={}, templateId={}, scenicId={}", memberId, templateId, scenicId, e); -// return false; -// } + try { + // 先检查剩余次数 + Integer remainingCount = userNotificationAuthorizationService.getRemainingCount(memberId, templateId, scenicId); + if (remainingCount == null || remainingCount <= 0) { + log.debug("用户剩余授权次数不足: memberId={}, templateId={}, scenicId={}, remainingCount={}", + memberId, templateId, scenicId, remainingCount); + return false; + } + + // 尝试消费 + return consumeAuthorization(memberId, templateId, scenicId); + } catch (Exception e) { + log.error("检查并消费授权异常: memberId={}, templateId={}, scenicId={}", memberId, templateId, scenicId, e); + return false; + } } /**