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=被邀请人)