소스 검색

feat(auth): 添加注销后重新注册限制功能

- 在LawyerUser实体中新增RE_REGISTER_BLOCK_DAYS常量定义14天禁止重注册期
- 添加isWithinReRegisterBlockPeriod方法判断是否在禁止重注册期间内
- 更新律师用户登录服务实现,在验证注销状态时检查重注册限制
- 修改网关生活用户服务中的设备ID更新逻辑,统一设置新设备ID而非拼接
fcw 2 일 전
부모
커밋
497ccac073

+ 18 - 0
alien-entity/src/main/java/shop/alien/entity/store/LawyerUser.java

@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.temporal.ChronoUnit;
 import java.util.Date;
@@ -32,6 +33,8 @@ public class LawyerUser extends Model<LawyerUser> {
     public static final int LOGOUT_FLAG_DONE = 1;
     /** logout_flag:注销冷静期 */
     public static final int LOGOUT_FLAG_COOLING = 2;
+    /** 注销完成后禁止重新注册的天数(自 logoutTime 日起,T+14 00:00 起可注册) */
+    public static final int RE_REGISTER_BLOCK_DAYS = 14;
 
     public LawyerUser() {
     }
@@ -396,5 +399,20 @@ public class LawyerUser extends Model<LawyerUser> {
     @TableField("zfb_secondary_merchant_account")
     private String zfbSecondaryMerchantAccount;
 
+    /**
+     * 注销完成日 T(logoutTime)起,至 T+{@link #RE_REGISTER_BLOCK_DAYS} 日 00:00 前禁止重新注册/登录。
+     */
+    public static boolean isWithinReRegisterBlockPeriod(Date logoutTime) {
+        if (logoutTime == null) {
+            return false;
+        }
+        LocalDateTime allowFrom = logoutTime.toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate()
+                .plusDays(RE_REGISTER_BLOCK_DAYS)
+                .atStartOfDay();
+        return LocalDateTime.now().isBefore(allowFrom);
+    }
+
 }
 

+ 2 - 2
alien-gateway/src/main/java/shop/alien/gateway/service/LifeUserService.java

@@ -261,8 +261,8 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
         LifeUser update = new LifeUser();
         update.setId(id);
         //当原来的字段有值,在后面用逗号拼接
-        update.setDeviceId(user.getDeviceId() == null ? normalized : user.getDeviceId() + "," + normalized);
-//        update.setDeviceId(normalized);
+//        update.setDeviceId(user.getDeviceId() == null ? normalized : user.getDeviceId() + "," + normalized);
+        update.setDeviceId(normalized);
         return lifeUserMapper.updateById(update) > 0 ? R.success("保存成功") : R.fail("保存失败");
     }
 

+ 2 - 1
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/LawyerUserLogInServiceImpl.java

@@ -187,7 +187,8 @@ public class LawyerUserLogInServiceImpl extends ServiceImpl<LawyerUserMapper, La
                         return R.fail("账号被禁用");
                     }
                     if (lawyerUser.getLogoutFlag() != null && LawyerUser.LOGOUT_FLAG_DONE == lawyerUser.getLogoutFlag()
-                            && (lawyerUser.getDeleteFlag() == null || lawyerUser.getDeleteFlag() == 0)) {
+                            && (lawyerUser.getDeleteFlag() == null || lawyerUser.getDeleteFlag() == 0)
+                            && LawyerUser.isWithinReRegisterBlockPeriod(lawyerUser.getLogoutTime())) {
                         return R.fail("账号已注销");
                     }
                     BeanUtils.copyProperties(lawyerUser, vo);