特性:优化注册与改名卡逻辑,在触发敏感词或拦截重名时明确提示具体是触发了哪个词汇

This commit is contained in:
2026-04-02 16:38:17 +08:00
parent 63292ab810
commit c4edda8b4e
3 changed files with 45 additions and 26 deletions
+9 -2
View File
@@ -151,8 +151,15 @@ class ShopService
}
// 不能在黑名单保留期内
if (UsernameBlacklist::isReserved($newName)) {
return ['ok' => false, 'message' => '该昵称处于保护期,暂时无法使用。'];
if ($blockingRecord = UsernameBlacklist::getBlockingRecord($newName)) {
$reason = '';
if ($blockingRecord->type === 'permanent') {
$reason = "(包含敏感词:{$blockingRecord->username}";
} else {
$reason = '(处于曾用名保护期)';
}
return ['ok' => false, 'message' => "该昵称已被系统禁止使用{$reason}"];
}
// 查找有效的改名卡记录