v1.0.33: 全局唯一性校验 - 手机号/邮箱/身份证/企业注册号/社媒账号ID/主页链接/企业名称 新增与修改时校验,重复弹窗提示并跳转定位(后端duplicate_check引擎+code 1001,前端弹窗+person/company/media页?id=跳转)
This commit is contained in:
+19
-6
@@ -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');
|
||||
@@ -28,6 +29,23 @@ if ((int)($data['is_listed'] ?? 0) !== 1) {
|
||||
}
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
|
||||
// 唯一性校验:企业名称 / 注册号 / 联系方式(手机/邮箱/社媒账号/主页链接)
|
||||
$dup = findDuplicate($pdo, 'company_name', $data['name_zh'] ?? $data['display_name'] ?? '');
|
||||
if ($dup) Response::duplicate($dup);
|
||||
if (!empty($data['registration_number'])) {
|
||||
$dup = findDuplicate($pdo, 'registration_number', $data['registration_number']);
|
||||
if ($dup) Response::duplicate($dup);
|
||||
}
|
||||
if (isset($_POST['accounts'])) {
|
||||
$accounts = json_decode($_POST['accounts'], true);
|
||||
if (!is_array($accounts)) {
|
||||
Response::error('联系方式格式错误', 400);
|
||||
}
|
||||
$dup = checkAccountsDuplicates($pdo, $accounts);
|
||||
if ($dup) Response::duplicate($dup);
|
||||
}
|
||||
|
||||
[$sql, $params] = buildInsert($data);
|
||||
$pdo->prepare("INSERT INTO companies $sql")->execute($params);
|
||||
$newId = (int)$pdo->lastInsertId();
|
||||
@@ -53,12 +71,7 @@ if (array_key_exists('financials', $_POST) || array_key_exists('certifications',
|
||||
saveCompanyCertifications($pdo, $newId, $certs);
|
||||
}
|
||||
if (array_key_exists('accounts', $_POST)) {
|
||||
$accounts = json_decode($_POST['accounts'], true);
|
||||
if (!is_array($accounts)) {
|
||||
$pdo->rollBack();
|
||||
Response::error('联系方式格式错误', 400);
|
||||
}
|
||||
saveCompanyAccounts($pdo, $newId, $accounts);
|
||||
saveCompanyAccounts($pdo, $newId, $accounts ?? []);
|
||||
}
|
||||
$pdo->commit();
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user