|
|
@@ -2,6 +2,7 @@ package shop.alien.gateway.service;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -70,6 +71,7 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
|
|
|
private String effectiveTime;
|
|
|
|
|
|
private static final DateTimeFormatter LOGOUT_END_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
|
|
+ private static final DateTimeFormatter RE_REGISTER_ALLOW_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
|
|
|
|
|
|
/**
|
|
|
* 申请注销结束时间:logoutTime 起算第 7 天(T+0~T+7),与定时任务冷静期一致。
|
|
|
@@ -92,6 +94,54 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
|
|
|
userVo.setLogoutEndTime(resolveLogoutEndTime(user.getLogoutTime(), user.getLogoutFlag()));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 注销完成日 T(logoutTime)起,至 T+{@link LifeUser#RE_REGISTER_BLOCK_DAYS} 日 00:00 前禁止重新注册/登录。
|
|
|
+ */
|
|
|
+ public static boolean isWithinReRegisterBlockPeriod(Date logoutTime) {
|
|
|
+ if (logoutTime == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ ZoneId zone = ZoneId.systemDefault();
|
|
|
+ LocalDateTime allowFrom = logoutTime.toInstant()
|
|
|
+ .atZone(zone)
|
|
|
+ .toLocalDate()
|
|
|
+ .plusDays(LifeUser.RE_REGISTER_BLOCK_DAYS)
|
|
|
+ .atStartOfDay();
|
|
|
+ return LocalDateTime.now(zone).isBefore(allowFrom);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 可重新注册时间:logoutTime 对应日 T 的 T+14 日 00:00。
|
|
|
+ */
|
|
|
+ public static String resolveReRegisterAllowTime(Date logoutTime) {
|
|
|
+ if (logoutTime == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return logoutTime.toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDate()
|
|
|
+ .plusDays(LifeUser.RE_REGISTER_BLOCK_DAYS)
|
|
|
+ .atStartOfDay()
|
|
|
+ .format(RE_REGISTER_ALLOW_TIME_FORMAT);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 手机号处于注销禁登期时返回完整提示,否则返回 null。
|
|
|
+ */
|
|
|
+ public String getReRegisterBlockedMessage(String phoneNum) {
|
|
|
+ LifeUser user = getUserByPhoneDelete(phoneNum);
|
|
|
+ if (user == null
|
|
|
+ || LifeUser.LOGOUT_FLAG_DONE != user.getLogoutFlag()
|
|
|
+ || !isWithinReRegisterBlockPeriod(user.getLogoutTime())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String allowTime = resolveReRegisterAllowTime(user.getLogoutTime());
|
|
|
+ if (allowTime == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return "原手机号无法注册新账号," + allowTime + "起,原手机号可重新注册";
|
|
|
+ }
|
|
|
+
|
|
|
public LifeUserVo userLogin(String phoneNum, String inviteCode, String macIp) {
|
|
|
LifeUser user = getUserByPhone(phoneNum);
|
|
|
if (user == null) {
|
|
|
@@ -189,6 +239,9 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
|
|
|
return this.getOne(lambdaQueryWrapper);
|
|
|
}
|
|
|
|
|
|
+ public LifeUser getUserByPhoneDelete(String phoneNum) {
|
|
|
+ return lifeUserMapper.selectCancelledDeletedByPhone(phoneNum);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 用户登录log存放(加入mac地址)
|