0806
This commit is contained in:
+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,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user