修复:收口登录提示文案

This commit is contained in:
xiaowang
2026-03-26 16:36:34 +08:00
parent bd349473f0
commit be596f15d1
3 changed files with 87 additions and 11 deletions
@@ -209,8 +209,8 @@ public class UserController {
boolean exists = userDO != null;
String nickname = exists ? userDO.getNickname() : null;
String message = exists
? (nickname != null && !nickname.isEmpty() ? "找到账号,登录后将进入:" + nickname : "账号已注册")
: "该账号未注册";
? (nickname != null && !nickname.isEmpty() ? "该账号已注册,昵称:" + nickname : "该账号已注册,可继续登录")
: "该账号未注册或已删除";
return Result.success(new LoginAccountAvailabilityVO(exists, nickname, message));
}
@@ -572,7 +572,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
.last("limit 1")
);
if (userDO == null) {
return buildLoginShopSelection(List.of(), false, "该账号未注册");
return buildLoginShopSelection(List.of(), false, "该账号未注册或已删除");
}
if (userDO.getStatus() != null && !Integer.valueOf(1).equals(userDO.getStatus())) {
return buildLoginShopSelection(List.of(), false, "该账号已被禁用");
@@ -649,10 +649,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
.last("limit 1")
);
if (userDO == null) {
return buildLoginShopSelection(List.of(), false, "该账号不存在");
return buildLoginShopSelection(List.of(), false, "该账号未注册或已删除");
}
if (userDO.getType() == null || userDO.getType() < 2) {
return buildLoginShopSelection(List.of(), false, "该账号没有后台管理权限");
return buildLoginShopSelection(List.of(), false, "该账号不是后台管理账号");
}
if (userDO.getStatus() != null && !Integer.valueOf(1).equals(userDO.getStatus())) {
return buildLoginShopSelection(List.of(), false, "该账号已被禁用");
@@ -663,7 +663,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
boolean allowShoplessLogin = shops.isEmpty();
String message = allowShoplessLogin
? "当前暂无启用店铺,可直接登录后台创建店铺"
: buildLoginShopMessage(shops);
: buildAdminLoginShopMessage(shops);
return buildLoginShopSelection(shops, allowShoplessLogin, message);
}
@@ -682,7 +682,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
.eq(UserDO::getAccount, normalizedAccount)
);
assertUserAvailable(userDO);
assertLoginAccountAvailable(userDO);
// 检查是否为未设置密码的账号
if (ENCODED_UNSET_PASSWORD.equals(userDO.getPassword())) {
@@ -761,7 +761,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
.eq(UserDO::getAccount, normalizedAccount)
);
assertUserAvailable(userDO);
assertLoginAccountAvailable(userDO);
if (!passwordEncoder.matches(loginRequestDTO.getPassword(), userDO.getPassword())) {
throw new RuntimeException("密码错误");
@@ -769,7 +769,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
Integer userType = userDO.getType();
if (userType == null || userType < 2) {
throw new RuntimeException("您没有后台管理权限");
throw new RuntimeException("该账号不是后台管理账号");
}
syncDefaultPermissions(userDO.getId(), userType);
@@ -1193,6 +1193,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
}
}
private void assertLoginAccountAvailable(UserDO userDO) {
if (userDO == null || Integer.valueOf(1).equals(userDO.getIsDelete())) {
throw new RuntimeException("该账号未注册或已删除");
}
if (userDO.getStatus() != null && !Integer.valueOf(1).equals(userDO.getStatus())) {
throw new RuntimeException("该账号已被禁用");
}
}
private void validateVerificationCode(String phone, String verificationCode) {
if (!StringUtils.hasText(phone) || !StringUtils.hasText(verificationCode)) {
throw new RuntimeException("验证码不能为空");
@@ -1242,14 +1251,24 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
private String buildLoginShopMessage(List<ShopSimpleVO> shops) {
if (shops == null || shops.isEmpty()) {
return "当前暂无可选店铺";
return "当前暂无可登录店铺";
}
if (shops.size() == 1) {
return "已匹配到 1 家可登录店铺";
return "已匹配到 1 家可登录店铺,已为您默认选中";
}
return "该账号已绑定多家店铺,请选择本次登录店铺";
}
private String buildAdminLoginShopMessage(List<ShopSimpleVO> shops) {
if (shops == null || shops.isEmpty()) {
return "当前暂无启用店铺,可直接登录后台创建店铺";
}
if (shops.size() == 1) {
return "当前已有 1 家启用店铺,已为您默认选中";
}
return "当前已有 " + shops.size() + " 家启用店铺,请选择本次登录店铺";
}
private Long resolveUserLoginShopId(UserDO userDO, Long requestedShopId) {
Long normalizedRequestedShopId = validateAndNormalizeShopId(requestedShopId);
List<Long> activeShopIds = userShopBindingSupport.listActiveShopIdsByUserId(userDO.getId());