0806
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
/**
|
||||
* 认证类型字典接口 GET /api/company/cert_types.php
|
||||
* 返回启用中的认证类型(如:瞪羚企业、国家高新技术企业等),供编辑弹窗下拉使用
|
||||
* 数据源:date_dict_certificate(原 certification_types,v1.0.16 改名)
|
||||
*/
|
||||
require_once __DIR__ . '/../common/db.php';
|
||||
require_once __DIR__ . '/../common/response.php';
|
||||
@@ -10,6 +11,6 @@ require_once __DIR__ . '/../common/auth.php';
|
||||
checkPermission('company');
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
$types = $pdo->query("SELECT id, name FROM certification_types WHERE is_active = 1 ORDER BY sort_order, id")->fetchAll();
|
||||
$types = $pdo->query("SELECT id, name FROM date_dict_certificate WHERE is_active = 1 ORDER BY sort_order, id")->fetchAll();
|
||||
|
||||
Response::success(['types' => $types]);
|
||||
|
||||
+13
-7
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* 企业详情接口 GET /api/company/detail.php?id=1
|
||||
* 返回企业主表信息 + 关联数据(产品品类/需求/文档/财务)
|
||||
* 返回企业主表信息 + 关联数据(产品品类/文档/财务/资质/联系方式)
|
||||
*/
|
||||
require_once __DIR__ . '/../common/db.php';
|
||||
require_once __DIR__ . '/../common/response.php';
|
||||
@@ -26,9 +26,6 @@ if (!$company) {
|
||||
$products = $pdo->prepare("SELECT id, category_name, category_description, is_core, is_active FROM company_products WHERE company_id = ? AND is_active = 1");
|
||||
$products->execute([$id]);
|
||||
|
||||
$needs = $pdo->prepare("SELECT id, contact_person, need_category, target_product_category, application_scenario, description, is_valid, created_at FROM company_needs WHERE company_id = ? ORDER BY id DESC");
|
||||
$needs->execute([$id]);
|
||||
|
||||
$docs = $pdo->prepare(
|
||||
"SELECT cd.id, cd.doc_name, cd.storage_path, cd.file_type, cd.publish_date, cd.is_active
|
||||
FROM company_documents cd
|
||||
@@ -53,13 +50,22 @@ $certs = $pdo->prepare(
|
||||
"SELECT cc.certification_type_id, ct.name AS certification_name, cc.certificate_number,
|
||||
cc.issue_date, cc.expiry_date
|
||||
FROM company_certifications cc
|
||||
INNER JOIN certification_types ct ON ct.id = cc.certification_type_id
|
||||
INNER JOIN date_dict_certificate ct ON ct.id = cc.certification_type_id
|
||||
WHERE cc.company_id = ?
|
||||
ORDER BY ct.sort_order, ct.id"
|
||||
);
|
||||
$certs->execute([$id]);
|
||||
|
||||
$certTypes = $pdo->query("SELECT id, name FROM certification_types WHERE is_active = 1 ORDER BY sort_order, id")->fetchAll();
|
||||
$certTypes = $pdo->query("SELECT id, name FROM date_dict_certificate WHERE is_active = 1 ORDER BY sort_order, id")->fetchAll();
|
||||
|
||||
// 联系方式:social_accounts 中属于该公司的记录(仅展示,无修改/删除入口)
|
||||
$accounts = $pdo->prepare(
|
||||
"SELECT id, platform, account_id, profile_url, remark, is_primary, is_defult, is_active, created_at
|
||||
FROM social_accounts
|
||||
WHERE owner_type = 'company' AND owner_id = ?
|
||||
ORDER BY is_defult DESC, is_primary DESC, id DESC"
|
||||
);
|
||||
$accounts->execute([$id]);
|
||||
|
||||
// 关联联系人(工作经历 + 联系方式)
|
||||
$contacts = $pdo->prepare(
|
||||
@@ -79,11 +85,11 @@ $contacts->execute([$id, $id]);
|
||||
Response::success([
|
||||
'company' => $company,
|
||||
'products' => $products->fetchAll(),
|
||||
'needs' => $needs->fetchAll(),
|
||||
'documents' => $docs->fetchAll(),
|
||||
'financials' => $financials->fetchAll(),
|
||||
'relations' => $relations->fetchAll(),
|
||||
'contacts' => $contacts->fetchAll(),
|
||||
'accounts' => $accounts->fetchAll(),
|
||||
'certifications' => $certs->fetchAll(),
|
||||
'certification_types' => $certTypes,
|
||||
]);
|
||||
|
||||
@@ -60,10 +60,10 @@ $stmt = $pdo->prepare(
|
||||
pwe.job_level, pwe.start_date, pwe.end_date, pwe.is_current,
|
||||
(SELECT sa.account_id FROM social_accounts sa
|
||||
WHERE sa.owner_type = 'person' AND sa.owner_id = p.id AND sa.platform = 'phone' AND sa.is_active = 1
|
||||
ORDER BY sa.is_primary DESC LIMIT 1) AS phone,
|
||||
ORDER BY sa.is_defult DESC, sa.is_primary DESC LIMIT 1) AS phone,
|
||||
(SELECT sa.account_id FROM social_accounts sa
|
||||
WHERE sa.owner_type = 'person' AND sa.owner_id = p.id AND sa.platform = 'email' AND sa.is_active = 1
|
||||
ORDER BY sa.is_primary DESC LIMIT 1) AS email
|
||||
ORDER BY sa.is_defult DESC, sa.is_primary DESC LIMIT 1) AS email
|
||||
FROM person_work_experiences pwe
|
||||
INNER JOIN persons p ON p.id = pwe.person_id
|
||||
WHERE $whereSql
|
||||
|
||||
@@ -32,7 +32,7 @@ $stmt = $pdo->prepare(
|
||||
"SELECT id, name_zh, name_en, business_role, country, registration_number,
|
||||
address, legal_representative, industry, industry_subdivision, website,
|
||||
registered_capital, established_date, latest_employee_count, latest_annual_revenue,
|
||||
is_listed, stock_code, created_at
|
||||
is_listed, stock_code, source_channel, source_detail, created_at
|
||||
FROM companies WHERE id IN ($in) AND is_active = 1 ORDER BY id DESC"
|
||||
);
|
||||
$stmt->execute($idList);
|
||||
@@ -44,14 +44,14 @@ header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="companies_' . date('Ymd_His') . '.csv"');
|
||||
echo "\xEF\xBB\xBF"; // UTF-8 BOM,便于 Excel 直接打开
|
||||
$out = fopen('php://output', 'w');
|
||||
fputcsv($out, ['ID', '公司名称', '英文名称', '业务角色', '国家/地区', '注册号', '地址', '法人', '行业', '行业细分', '官网', '注册资本', '成立日期', '员工数', '年营收', '是否上市', '股票代码', '创建时间']);
|
||||
fputcsv($out, ['ID', '公司名称', '英文名称', '业务角色', '国家/地区', '注册号', '地址', '法人', '行业', '行业细分', '官网', '注册资本', '成立日期', '员工数', '年营收', '是否上市', '股票代码', '来源渠道', '来源详情', '创建时间']);
|
||||
foreach ($list as $r) {
|
||||
fputcsv($out, [
|
||||
$r['id'], $r['name_zh'], $r['name_en'], $r['business_role'],
|
||||
$r['country'], $r['registration_number'], $r['address'], $r['legal_representative'],
|
||||
$r['industry'], $r['industry_subdivision'], $r['website'], $r['registered_capital'],
|
||||
$r['established_date'], $r['latest_employee_count'], $r['latest_annual_revenue'],
|
||||
$r['is_listed'], $r['stock_code'], date('Y-m-d', strtotime($r['created_at'])),
|
||||
$r['is_listed'], $r['stock_code'], $r['source_channel'], $r['source_detail'], date('Y-m-d', strtotime($r['created_at'])),
|
||||
]);
|
||||
}
|
||||
fclose($out);
|
||||
|
||||
@@ -36,6 +36,7 @@ $map = [
|
||||
'industry' => 'industry', 'industry_subdivision' => 'industry_subdivision', 'website' => 'website',
|
||||
'registered_capital' => 'registered_capital', 'established_date' => 'established_date',
|
||||
'is_listed' => 'is_listed', 'stock_code' => 'stock_code',
|
||||
'source_channel' => 'source_channel', 'source_detail' => 'source_detail',
|
||||
];
|
||||
|
||||
$pdo = DB::getInstance()->getPdo();
|
||||
@@ -46,8 +47,8 @@ $stmt = $pdo->prepare(
|
||||
"INSERT INTO companies
|
||||
(name_zh, name_en, display_name, business_role, country, registration_number,
|
||||
address, legal_form, legal_representative, industry, industry_subdivision, website,
|
||||
registered_capital, established_date, is_listed, stock_code)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
|
||||
registered_capital, established_date, is_listed, stock_code, source_channel, source_detail)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
|
||||
);
|
||||
|
||||
while (($row = fgetcsv($handle)) !== false) {
|
||||
@@ -72,6 +73,7 @@ while (($row = fgetcsv($handle)) !== false) {
|
||||
$rec['industry'] ?? null, $rec['industry_subdivision'] ?? null, $rec['website'] ?? null,
|
||||
$rec['registered_capital'] ?? null, $rec['established_date'],
|
||||
($rec['is_listed'] ?? 0) ? 1 : 0, $rec['stock_code'] ?? null,
|
||||
$rec['source_channel'] ?? null, $rec['source_detail'] ?? null,
|
||||
]);
|
||||
$inserted++;
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -55,7 +55,7 @@ $stmt = $pdo->prepare(
|
||||
"SELECT id, name_zh, name_en, display_name, business_role, country, registration_number,
|
||||
address, legal_representative, industry, industry_subdivision, website,
|
||||
latest_employee_count, latest_annual_revenue, is_listed, stock_code,
|
||||
is_active, created_at, updated_at
|
||||
source_channel, source_detail, is_active, created_at, updated_at
|
||||
FROM companies
|
||||
WHERE $whereSql
|
||||
ORDER BY id DESC
|
||||
|
||||
Reference in New Issue
Block a user