v1.0.33: 全局唯一性校验 - 手机号/邮箱/身份证/企业注册号/社媒账号ID/主页链接/企业名称 新增与修改时校验,重复弹窗提示并跳转定位(后端duplicate_check引擎+code 1001,前端弹窗+person/company/media页?id=跳转)
This commit is contained in:
+20
-3
@@ -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('person');
|
||||
@@ -29,13 +30,29 @@ if (!$old) {
|
||||
Response::error('人员不存在');
|
||||
}
|
||||
|
||||
$contactsChanged = false;
|
||||
// 唯一性校验(排除自身):身份证号码 / 联系方式
|
||||
if (!empty($data['id_number'])) {
|
||||
$dup = findDuplicate($pdo, 'id_number', $data['id_number'], [$id]);
|
||||
if ($dup) Response::duplicate($dup);
|
||||
}
|
||||
$contacts = null;
|
||||
if (isset($_POST['contacts'])) {
|
||||
$contacts = json_decode($_POST['contacts'], true);
|
||||
if (!is_array($contacts)) {
|
||||
Response::error('联系方式格式错误', 400);
|
||||
}
|
||||
// 整体替换:排除人员自身既有联系方式ID
|
||||
$ownIds = $pdo->query("SELECT id FROM social_accounts WHERE owner_type = 'person' AND owner_id = $id")->fetchAll(PDO::FETCH_COLUMN);
|
||||
$dup = checkAccountsDuplicates($pdo, $contacts, $ownIds);
|
||||
if ($dup) Response::duplicate($dup);
|
||||
}
|
||||
|
||||
$contactsChanged = false;
|
||||
if ($contacts !== null) {
|
||||
$contactsChanged = true;
|
||||
// 整体替换联系方式:先删旧(保留非联系人性质?此处直接删除全部后重建)
|
||||
$pdo->prepare("DELETE FROM social_accounts WHERE owner_type = 'person' AND owner_id = ?")->execute([$id]);
|
||||
$contacts = json_decode($_POST['contacts'], true);
|
||||
if (is_array($contacts)) {
|
||||
if (count($contacts) > 0) {
|
||||
$ins = $pdo->prepare(
|
||||
"INSERT INTO social_accounts (owner_type, owner_id, platform, account_id, profile_url, remark, is_primary, is_defult)
|
||||
VALUES ('person', ?, ?, ?, ?, ?, ?, ?)"
|
||||
|
||||
Reference in New Issue
Block a user