From 1dd40c12062bbb004ab309639ee6ec4dea1cabd8 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 22 Oct 2025 15:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=80=E8=AF=B7=E7=A0=81=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=8F=AA=E5=85=81=E8=AE=B83=E5=A4=A9=E5=86=85=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E7=9A=84=E6=96=B0=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/activity/BindInviteCodeExe.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/BindInviteCodeExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/BindInviteCodeExe.java index 1700a6cb..1bea8f3c 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/BindInviteCodeExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/BindInviteCodeExe.java @@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.sql.Timestamp; import java.time.ZonedDateTime; import java.util.List; import java.util.Objects; @@ -64,7 +65,22 @@ public class BindInviteCodeExe { // 3. 校验用户是否存在 UserProfile userProfile = userProfileGateway.getByUserId(userId); if (userProfile == null) { - throw new RuntimeException("The user does not exist."); + throw new RuntimeException("The user does not exist."); + } + + // 校验用户创建时间是否超过3天 + Timestamp createTime = userProfile.getCreateTime(); + if (createTime != null) { + long createTimeMillis = createTime.getTime(); + long currentTime = TimestampUtils.now().getTime(); + long threeDaysInMillis = 3 * 24 * 60 * 60 * 1000L; // 3天的毫秒数 + long timeDiff = currentTime - createTimeMillis; + + if (timeDiff > threeDaysInMillis) { + log.warn("用户创建时间超过3天,不允许绑定邀请码, userId={}, createTime={}, currentTime={}, diffDays={}", + userId, createTimeMillis, currentTime, timeDiff / (24 * 60 * 60 * 1000L)); + throw new RuntimeException("User registration time has exceeded 3 days and cannot bind invitation code"); + } } // 4. 校验是否已绑定过邀请人(userId=邀请人, inviteUserId=被邀请人)