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:
+26
-23
@@ -22,17 +22,19 @@ if (!in_array($sourceType, ['company', 'person', 'product', 'need', 'mixed'], tr
|
||||
}
|
||||
|
||||
$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'] ?? '');
|
||||
$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'] ?? ''); // 产品:品类(存 extra)
|
||||
$needCategory = trim($_POST['need_category'] ?? ''); // 需求:需求类别(存 extra)
|
||||
$workLocation = trim($_POST['work_location'] ?? ''); // 重要-人员
|
||||
$idNumber = trim($_POST['id_number'] ?? ''); // 重要-人员
|
||||
$platform = trim($_POST['platform'] ?? ''); // 核心-社媒
|
||||
$accountId = trim($_POST['account_id'] ?? ''); // 核心-社媒
|
||||
$profileUrl = trim($_POST['profile_url'] ?? ''); // 重要-主页
|
||||
$sourceChannel = trim($_POST['source_channel'] ?? '');
|
||||
|
||||
// 硬数据标准校验:
|
||||
@@ -74,36 +76,35 @@ if ($accountId !== '' && $platform !== '') {
|
||||
}
|
||||
if (!empty($dups)) Response::duplicates($dups);
|
||||
|
||||
// 额外信息(身份证/社媒平台/账号ID/主页链接/产品品类/需求类别)存 extra_info
|
||||
$extra = [];
|
||||
if ($idNumber !== '') $extra['id_number'] = $idNumber;
|
||||
if ($platform !== '') $extra['platform'] = $platform;
|
||||
if ($accountId !== '') $extra['account_id'] = $accountId;
|
||||
if ($profileUrl !== '') $extra['profile_url'] = $profileUrl;
|
||||
if ($category !== '') $extra['category'] = $category;
|
||||
if ($needCategory !== '') $extra['need_category'] = $needCategory;
|
||||
|
||||
// 至少有一项内容才能录为碎片
|
||||
if ($companyName === '' && $personName === '' && $phone === '' && $email === '' && !$extra) {
|
||||
if ($companyName === '' && $personName === '' && $phone === '' && $email === '' && $idNumber === '' && $accountId === '') {
|
||||
Response::error('请至少填写一项内容', 400);
|
||||
}
|
||||
|
||||
$pdo->prepare(
|
||||
"INSERT INTO preliminary_data
|
||||
(source_type, company_name, industry, registration_number, person_name, contact_phone, contact_email,
|
||||
source_channel, recorded_by, status, extra_info)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, '待处理', ?)"
|
||||
(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,
|
||||
source_channel, recorded_by, status)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '待处理')"
|
||||
)->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,
|
||||
$workLocation !== '' ? $workLocation : null,
|
||||
$idNumber !== '' ? $idNumber : null,
|
||||
$platform !== '' ? $platform : null,
|
||||
$accountId !== '' ? $accountId : null,
|
||||
$profileUrl !== '' ? $profileUrl : null,
|
||||
$sourceChannel !== '' ? $sourceChannel : null, // 未选择来源保持空白
|
||||
$_SESSION['username'] ?? null,
|
||||
$extra ? json_encode($extra, JSON_UNESCAPED_UNICODE) : null,
|
||||
]);
|
||||
$newId = (int)$pdo->lastInsertId();
|
||||
|
||||
@@ -113,7 +114,9 @@ logCurrent('add', 'fragment', 'preliminary_data', $newId, [
|
||||
'person_name' => $personName,
|
||||
'phone' => $phone,
|
||||
'email' => $email,
|
||||
'extra' => $extra,
|
||||
'id_number' => $idNumber,
|
||||
'platform' => $platform,
|
||||
'account_id' => $accountId,
|
||||
]);
|
||||
|
||||
Response::success(['id' => $newId], '新增成功');
|
||||
|
||||
Reference in New Issue
Block a user