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,
|
||||
|
||||
Reference in New Issue
Block a user