v1.0.41: 硬数据流程调整 - 区块标题去【】+preliminary_data瘦身(删非必要字段品类/描述,备份表已建)+硬数据标准(人员需手机/邮箱至少一,企业需名称必填,前后端校验)+完整度字段改4项
This commit is contained in:
@@ -29,13 +29,20 @@ $idNumber = trim($_POST['id_number'] ?? '');
|
||||
$platform = trim($_POST['platform'] ?? '');
|
||||
$accountId = trim($_POST['account_id'] ?? '');
|
||||
$profileUrl = trim($_POST['profile_url'] ?? '');
|
||||
$category = trim($_POST['target_product_category'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$sourceChannel = trim($_POST['source_channel'] ?? '');
|
||||
if ($sourceChannel === '') {
|
||||
$sourceChannel = '手动录入';
|
||||
}
|
||||
|
||||
// 硬数据标准校验:
|
||||
// 企业/产品/需求 → 企业名称必填;人员 → 手机、邮箱至少填一个;混合 → 至少有一项内容
|
||||
if (in_array($sourceType, ['company', 'product', 'need'], true) && $companyName === '') {
|
||||
Response::error('企业类型硬数据:企业名称为必填项', 400);
|
||||
}
|
||||
if ($sourceType === 'person' && $phone === '' && $email === '') {
|
||||
Response::error('人员类型硬数据:手机号码、邮箱至少填写一项', 400);
|
||||
}
|
||||
|
||||
// 格式校验:手机 / 邮箱 / 身份证 / 主页链接
|
||||
checkFieldFormat('phone', $phone);
|
||||
checkFieldFormat('email', $email);
|
||||
@@ -74,23 +81,21 @@ if ($accountId !== '') $extra['account_id'] = $accountId;
|
||||
if ($profileUrl !== '') $extra['profile_url'] = $profileUrl;
|
||||
|
||||
// 至少有一项内容才能录为碎片
|
||||
if ($companyName === '' && $personName === '' && $phone === '' && $email === '' && $category === '' && $description === '' && !$extra) {
|
||||
if ($companyName === '' && $personName === '' && $phone === '' && $email === '' && !$extra) {
|
||||
Response::error('请至少填写一项内容', 400);
|
||||
}
|
||||
|
||||
$pdo->prepare(
|
||||
"INSERT INTO preliminary_data
|
||||
(source_type, company_name, person_name, contact_phone, contact_email,
|
||||
target_product_category, description, source_channel, recorded_by, status, extra_info)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, '待处理', ?)"
|
||||
source_channel, recorded_by, status, extra_info)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, '待处理', ?)"
|
||||
)->execute([
|
||||
$sourceType,
|
||||
$companyName !== '' ? $companyName : null,
|
||||
$personName !== '' ? $personName : null,
|
||||
$phone !== '' ? $phone : null,
|
||||
$email !== '' ? $email : null,
|
||||
$category !== '' ? $category : null,
|
||||
$description !== '' ? $description : null,
|
||||
$sourceChannel,
|
||||
$_SESSION['username'] ?? null,
|
||||
$extra ? json_encode($extra, JSON_UNESCAPED_UNICODE) : null,
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
* 被 hard_list.php 与 hard_detail.php 共用
|
||||
*/
|
||||
|
||||
/** 硬碎片可统计字段(公司名/联系人/电话/邮箱/品类/描述) */
|
||||
const HARD_FIELDS = ['company_name', 'person_name', 'contact_phone', 'contact_email', 'target_product_category', 'description'];
|
||||
/** 硬碎片可统计字段(核心+重要:企业名/联系人/手机/邮箱;品类与描述已从表中移除) */
|
||||
const HARD_FIELDS = ['company_name', 'person_name', 'contact_phone', 'contact_email'];
|
||||
const HARD_LABELS = [
|
||||
'company_name' => '公司名称', 'person_name' => '联系人', 'contact_phone' => '电话',
|
||||
'contact_email' => '邮箱', 'target_product_category' => '产品品类', 'description' => '描述',
|
||||
'contact_email' => '邮箱',
|
||||
];
|
||||
|
||||
/** 计算硬碎片完整度:已填字段数 ÷ 总可填字段数 × 100% */
|
||||
@@ -36,7 +36,5 @@ function hardSummary($row)
|
||||
if (!empty($row['person_name'])) $parts[] = '联系人:' . $row['person_name'];
|
||||
if (!empty($row['contact_phone'])) $parts[] = '手机:' . $row['contact_phone'];
|
||||
if (!empty($row['contact_email'])) $parts[] = '邮箱:' . $row['contact_email'];
|
||||
if (!empty($row['target_product_category'])) $parts[] = '品类:' . $row['target_product_category'];
|
||||
if (empty($parts) && !empty($row['description'])) $parts[] = '描述:' . mb_substr($row['description'], 0, 20);
|
||||
return implode(' ', $parts);
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ $companyName = trim($_POST['company_name'] ?? ($frag['company_name'] ?? ''));
|
||||
$personName = trim($_POST['person_name'] ?? ($frag['person_name'] ?? ''));
|
||||
$phone = trim($_POST['contact_phone'] ?? ($frag['contact_phone'] ?? ''));
|
||||
$email = trim($_POST['contact_email'] ?? ($frag['contact_email'] ?? ''));
|
||||
$category = trim($_POST['target_product_category'] ?? ($frag['target_product_category'] ?? ''));
|
||||
$description = trim($_POST['description'] ?? ($frag['description'] ?? ''));
|
||||
$category = trim($_POST['target_product_category'] ?? ''); // 仅补全录入表单提供(表中已无该字段)
|
||||
$description = trim($_POST['description'] ?? ''); // 仅补全录入表单提供
|
||||
$industry = trim($_POST['industry'] ?? '');
|
||||
$sourceChannel = $frag['source_channel'] ?? null;
|
||||
|
||||
@@ -105,7 +105,7 @@ switch ($targetType) {
|
||||
$industry !== '' ? $industry : null,
|
||||
$description !== '' ? $description : null,
|
||||
$sourceChannel,
|
||||
$frag['description'] ?? null,
|
||||
$description !== '' ? $description : null,
|
||||
]);
|
||||
$convertedId = (int)$pdo->lastInsertId();
|
||||
$saveContacts('company', $convertedId);
|
||||
@@ -120,7 +120,7 @@ switch ($targetType) {
|
||||
$unionId = 'P' . date('YmdHis') . substr(uniqid(), -6);
|
||||
$pdo->prepare(
|
||||
"INSERT INTO persons (union_id, full_name, source_channel, source_detail) VALUES (?, ?, ?, ?)"
|
||||
)->execute([$unionId, $personName, $sourceChannel, $frag['description'] ?? null]);
|
||||
)->execute([$unionId, $personName, $sourceChannel, $description !== '' ? $description : null]);
|
||||
$convertedId = (int)$pdo->lastInsertId();
|
||||
$saveContacts('person', $convertedId);
|
||||
updateIncomplete($pdo, 'persons', $convertedId);
|
||||
|
||||
@@ -38,7 +38,7 @@ $total = (int)$stmt->fetchColumn();
|
||||
$offset = ($page - 1) * $limit;
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT id, source_type, company_name, person_name, contact_phone, contact_email,
|
||||
target_product_category, description, status, source_channel, recorded_by,
|
||||
status, source_channel, recorded_by,
|
||||
follow_person, converted_type, converted_id, created_at, updated_at
|
||||
FROM preliminary_data
|
||||
WHERE $whereSql
|
||||
|
||||
Reference in New Issue
Block a user