v1.0.33: 全局唯一性校验 - 手机号/邮箱/身份证/企业注册号/社媒账号ID/主页链接/企业名称 新增与修改时校验,重复弹窗提示并跳转定位(后端duplicate_check引擎+code 1001,前端弹窗+person/company/media页?id=跳转)
This commit is contained in:
+20
-5
@@ -9,6 +9,7 @@ require_once __DIR__ . '/../common/auth.php';
|
||||
require_once __DIR__ . '/../common/logger.php';
|
||||
require_once __DIR__ . '/../common/helpers.php';
|
||||
require_once __DIR__ . '/../common/completeness.php';
|
||||
require_once __DIR__ . '/../common/duplicate_check.php';
|
||||
|
||||
checkAjax();
|
||||
checkPermission('company');
|
||||
@@ -40,6 +41,25 @@ if (!$old) {
|
||||
Response::error('企业不存在');
|
||||
}
|
||||
|
||||
// 唯一性校验(排除自身):企业名称 / 注册号 / 联系方式
|
||||
$dup = findDuplicate($pdo, 'company_name', $data['name_zh'] ?? $old['display_name'] ?? '', [$id]);
|
||||
if ($dup) Response::duplicate($dup);
|
||||
if (!empty($data['registration_number'])) {
|
||||
$dup = findDuplicate($pdo, 'registration_number', $data['registration_number'], [$id]);
|
||||
if ($dup) Response::duplicate($dup);
|
||||
}
|
||||
$accounts = null;
|
||||
if ($hasAccounts) {
|
||||
$accounts = json_decode($_POST['accounts'], true);
|
||||
if (!is_array($accounts)) {
|
||||
Response::error('联系方式格式错误', 400);
|
||||
}
|
||||
// 整表替换:排除企业自身既有联系方式ID
|
||||
$ownIds = $pdo->query("SELECT id FROM social_accounts WHERE owner_type = 'company' AND owner_id = $id")->fetchAll(PDO::FETCH_COLUMN);
|
||||
$dup = checkAccountsDuplicates($pdo, $accounts, $ownIds);
|
||||
if ($dup) Response::duplicate($dup);
|
||||
}
|
||||
|
||||
if (!empty($data)) {
|
||||
[$sets, $params] = buildUpdate($data);
|
||||
$params[] = $id;
|
||||
@@ -67,11 +87,6 @@ if ($hasFinancials || $hasCertifications || $hasAccounts) {
|
||||
saveCompanyCertifications($pdo, $id, $certs);
|
||||
}
|
||||
if ($hasAccounts) {
|
||||
$accounts = json_decode($_POST['accounts'], true);
|
||||
if (!is_array($accounts)) {
|
||||
$pdo->rollBack();
|
||||
Response::error('联系方式格式错误', 400);
|
||||
}
|
||||
saveCompanyAccounts($pdo, $id, $accounts);
|
||||
}
|
||||
$pdo->commit();
|
||||
|
||||
Reference in New Issue
Block a user