v1.0.19: 修复人员编辑入口缺失(person.js addPerson/editPerson) + 渠道明细数量字段名(analysis.php cnt) + CDP全量验证43项PASS
This commit is contained in:
+86
-3
@@ -110,6 +110,87 @@ function strOrNull($v)
|
||||
return ($v === '') ? null : $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存人员工作履历(整表替换:先删后插)
|
||||
* @param PDO $pdo
|
||||
* @param int $personId
|
||||
* @param array $experiences JSON 解码后的数组 [{company_id,position,department,job_level,start_date,end_date,is_current}]
|
||||
*/
|
||||
function savePersonExperiences($pdo, $personId, $experiences)
|
||||
{
|
||||
$del = $pdo->prepare("DELETE FROM person_work_experiences WHERE person_id = ?");
|
||||
$del->execute([$personId]);
|
||||
if (empty($experiences)) {
|
||||
return;
|
||||
}
|
||||
$ins = $pdo->prepare(
|
||||
"INSERT INTO person_work_experiences
|
||||
(person_id, company_id, position, department, job_level, start_date, end_date, is_current)
|
||||
VALUES (?,?,?,?,?,?,?,?)"
|
||||
);
|
||||
foreach ($experiences as $e) {
|
||||
if (!is_array($e)) {
|
||||
continue;
|
||||
}
|
||||
$companyId = (int)($e['company_id'] ?? 0);
|
||||
if ($companyId <= 0) {
|
||||
continue;
|
||||
}
|
||||
$start = strOrNull($e['start_date'] ?? null);
|
||||
$end = strOrNull($e['end_date'] ?? null);
|
||||
$ins->execute([
|
||||
$personId,
|
||||
$companyId,
|
||||
strOrNull($e['position'] ?? null),
|
||||
strOrNull($e['department'] ?? null),
|
||||
strOrNull($e['job_level'] ?? null),
|
||||
$start !== null && strtotime($start) !== false ? date('Y-m-d', strtotime($start)) : null,
|
||||
$end !== null && strtotime($end) !== false ? date('Y-m-d', strtotime($end)) : null,
|
||||
!empty($e['is_current']) ? 1 : 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存企业联系方式(social_accounts,整表替换:先删后插)
|
||||
* 只操作 owner_type = 'company' 的记录
|
||||
* @param PDO $pdo
|
||||
* @param int $companyId
|
||||
* @param array $accounts JSON 解码后的数组 [{platform,account_id,profile_url,remark,is_active,is_defult}]
|
||||
*/
|
||||
function saveCompanyAccounts($pdo, $companyId, $accounts)
|
||||
{
|
||||
$del = $pdo->prepare("DELETE FROM social_accounts WHERE owner_type = 'company' AND owner_id = ?");
|
||||
$del->execute([$companyId]);
|
||||
if (empty($accounts)) {
|
||||
return;
|
||||
}
|
||||
$ins = $pdo->prepare(
|
||||
"INSERT INTO social_accounts
|
||||
(owner_type, owner_id, platform, account_id, profile_url, remark, is_primary, is_defult, is_active)
|
||||
VALUES ('company', ?, ?, ?, ?, ?, 0, ?, ?)"
|
||||
);
|
||||
foreach ($accounts as $a) {
|
||||
if (!is_array($a)) {
|
||||
continue;
|
||||
}
|
||||
$platform = trim($a['platform'] ?? '');
|
||||
$accountId = trim($a['account_id'] ?? '');
|
||||
if ($platform === '' || $accountId === '') {
|
||||
continue;
|
||||
}
|
||||
$ins->execute([
|
||||
$companyId,
|
||||
$platform,
|
||||
$accountId,
|
||||
strOrNull($a['profile_url'] ?? null),
|
||||
strOrNull($a['remark'] ?? null),
|
||||
!empty($a['is_defult']) ? 1 : 0,
|
||||
!empty($a['is_active']) ? 1 : 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存企业年度财务明细(整表替换:先删后插)
|
||||
* @param PDO $pdo
|
||||
@@ -175,11 +256,11 @@ function saveCompanyCertifications($pdo, $companyId, $certifications)
|
||||
return;
|
||||
}
|
||||
|
||||
$valid = $pdo->prepare("SELECT id FROM date_dict_certificate WHERE id = ?");
|
||||
$valid = $pdo->prepare("SELECT id FROM data_dict_certificate WHERE id = ?");
|
||||
$ins = $pdo->prepare(
|
||||
"INSERT INTO company_certifications
|
||||
(company_id, certification_type_id, certificate_number, issue_date, expiry_date)
|
||||
VALUES (?,?,?,?,?)"
|
||||
(company_id, certification_type_id, certificate_number, level, issuing_authority, issue_date, expiry_date)
|
||||
VALUES (?,?,?,?,?,?,?)"
|
||||
);
|
||||
$seen = [];
|
||||
foreach ($certifications as $ct) {
|
||||
@@ -199,6 +280,8 @@ function saveCompanyCertifications($pdo, $companyId, $certifications)
|
||||
$companyId,
|
||||
$tid,
|
||||
strOrNull($ct['certificate_number'] ?? null),
|
||||
strOrNull($ct['level'] ?? null),
|
||||
strOrNull($ct['issuing_authority'] ?? null),
|
||||
strOrNull($ct['issue_date'] ?? null),
|
||||
strOrNull($ct['expiry_date'] ?? null),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user