v1.0.48: preliminary_data重构按三层原则 - 核心+重要字段正式化(business_role/country/address/work_location/id_number/platform/account_id/profile_url新增列,身份证/社媒/主页从extra_info提为正式列)+删除extra_info(品类/需求类别等非必要不再存放)+表单/转换/列表全部适配(product品类默认未分类)

This commit is contained in:
nanguaboss
2026-08-10 00:53:09 +08:00
parent 6cf2aabc91
commit 319fbbe34c
7 changed files with 150 additions and 118 deletions
+17 -20
View File
@@ -32,17 +32,19 @@ if (in_array($frag['status'], ['已转换', '已废弃'], true)) {
$sourceType = trim($_POST['source_type'] ?? ($frag['source_type'] ?? ''));
$companyName = trim($_POST['company_name'] ?? '');
$industry = trim($_POST['industry'] ?? '');
$registrationNum = trim($_POST['registration_number'] ?? '');
$businessRole = trim($_POST['business_role'] ?? '');
$country = trim($_POST['country'] ?? '');
$address = trim($_POST['address'] ?? '');
$personName = trim($_POST['person_name'] ?? '');
$phone = trim($_POST['contact_phone'] ?? '');
$email = trim($_POST['contact_email'] ?? '');
$workLocation = trim($_POST['work_location'] ?? '');
$idNumber = trim($_POST['id_number'] ?? '');
$platform = trim($_POST['platform'] ?? '');
$accountId = trim($_POST['account_id'] ?? '');
$profileUrl = trim($_POST['profile_url'] ?? '');
$industry = trim($_POST['industry'] ?? ''); // 企业:行业
$registrationNum = trim($_POST['registration_number'] ?? ''); // 企业:注册号
$category = trim($_POST['target_product_category'] ?? ''); // 产品:品类
$needCategory = trim($_POST['need_category'] ?? ''); // 需求:需求类别
if (!in_array($sourceType, ['company', 'person', 'product', 'need', 'mixed'], true)) {
Response::error('碎片类型不合法', 400);
}
@@ -84,32 +86,27 @@ if ($accountId !== '' && $platform !== '') {
}
if (!empty($dups)) Response::duplicates($dups);
// extra_info 合并更新(身份证/平台/账号ID/主页链接/品类/需求类别)
$extra = json_decode($frag['extra_info'] ?? 'null', true);
if (!is_array($extra)) {
$extra = [];
}
if ($idNumber !== '') $extra['id_number'] = $idNumber; else unset($extra['id_number']);
if ($platform !== '') $extra['platform'] = $platform; else unset($extra['platform']);
if ($accountId !== '') $extra['account_id'] = $accountId; else unset($extra['account_id']);
if ($profileUrl !== '') $extra['profile_url'] = $profileUrl; else unset($extra['profile_url']);
if ($category !== '') $extra['category'] = $category; else unset($extra['category']);
if ($needCategory !== '') $extra['need_category'] = $needCategory; else unset($extra['need_category']);
$pdo->prepare(
"UPDATE preliminary_data
SET source_type = ?, company_name = ?, industry = ?, registration_number = ?, person_name = ?,
contact_phone = ?, contact_email = ?, extra_info = ?
SET source_type = ?, company_name = ?, industry = ?, registration_number = ?, business_role = ?, country = ?, address = ?,
person_name = ?, contact_phone = ?, contact_email = ?, work_location = ?, id_number = ?, platform = ?, account_id = ?, profile_url = ?
WHERE id = ?"
)->execute([
$sourceType,
$companyName !== '' ? $companyName : null,
$industry !== '' ? $industry : null,
$registrationNum !== '' ? $registrationNum : null,
$businessRole !== '' ? $businessRole : null,
$country !== '' ? $country : null,
$address !== '' ? $address : null,
$personName !== '' ? $personName : null,
$phone !== '' ? $phone : null,
$email !== '' ? $email : null,
$extra ? json_encode($extra, JSON_UNESCAPED_UNICODE) : null,
$workLocation !== '' ? $workLocation : null,
$idNumber !== '' ? $idNumber : null,
$platform !== '' ? $platform : null,
$accountId !== '' ? $accountId : null,
$profileUrl !== '' ? $profileUrl : null,
$id,
]);
@@ -119,7 +116,7 @@ logCurrent('update', 'fragment', 'preliminary_data', $id, [
'person_name' => $personName,
'phone' => $phone,
'email' => $email,
'extra' => $extra,
'id_number' => $idNumber,
]);
Response::success(null, '已保存,点击「转软碎片」完成转换');