v1.0.12: 企业/人员/媒体去删除入口;企业/人员加产品入口;企业详情去产品品类/关联联系人;编辑企业改Tab卡(工商信息/财务信息/资质认证)

This commit is contained in:
nanguaboss
2026-08-03 23:22:33 +08:00
parent 71c6e8d9c1
commit 96cba121a8
14 changed files with 644 additions and 83 deletions
+27
View File
@@ -26,5 +26,32 @@ $pdo = DB::getInstance()->getPdo();
$pdo->prepare("INSERT INTO companies $sql")->execute($params);
$newId = (int)$pdo->lastInsertId();
// 财务信息 / 资质认证(可选,整表替换)
if (array_key_exists('financials', $_POST) || array_key_exists('certifications', $_POST)) {
$pdo->beginTransaction();
try {
if (array_key_exists('financials', $_POST)) {
$financials = json_decode($_POST['financials'], true);
if (!is_array($financials)) {
$pdo->rollBack();
Response::error('财务信息格式错误', 400);
}
saveCompanyFinancials($pdo, $newId, $financials);
}
if (array_key_exists('certifications', $_POST)) {
$certs = json_decode($_POST['certifications'], true);
if (!is_array($certs)) {
$pdo->rollBack();
Response::error('资质认证格式错误', 400);
}
saveCompanyCertifications($pdo, $newId, $certs);
}
$pdo->commit();
} catch (Exception $e) {
$pdo->rollBack();
Response::error('关联信息保存失败:' . $e->getMessage());
}
}
logCurrent('add', 'company', 'companies', $newId, $data);
Response::success(['id' => $newId], '新增成功');
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* 认证类型字典接口 GET /api/company/cert_types.php
* 返回启用中的认证类型(如:瞪羚企业、国家高新技术企业等),供编辑弹窗下拉使用
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
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();
Response::success(['types' => $types]);
+15
View File
@@ -48,6 +48,19 @@ $relations = $pdo->prepare(
);
$relations->execute([$id]);
// 资质认证(瞪羚企业等,JOIN 字典表取名称)
$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
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();
// 关联联系人(工作经历 + 联系方式)
$contacts = $pdo->prepare(
"SELECT p.id, p.full_name,
@@ -71,4 +84,6 @@ Response::success([
'financials' => $financials->fetchAll(),
'relations' => $relations->fetchAll(),
'contacts' => $contacts->fetchAll(),
'certifications' => $certs->fetchAll(),
'certification_types' => $certTypes,
]);
+4
View File
@@ -38,6 +38,10 @@ if ($jobLevel !== '') {
$where[] = 'pwe.job_level = ?';
$params[] = $jobLevel;
}
if (isset($_REQUEST['is_current']) && $_REQUEST['is_current'] !== '') {
$where[] = 'pwe.is_current = ?';
$params[] = (int)$_REQUEST['is_current'] ? 1 : 0;
}
$whereSql = implode(' AND ', $where);
// 总数
+41
View File
@@ -0,0 +1,41 @@
<?php
/**
* 企业产品品类列表接口 GET /api/company/products.php
* 入参:company_id(必填)/ page / limit
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
require_once __DIR__ . '/../common/auth.php';
checkPermission('company');
$companyId = (int)($_REQUEST['company_id'] ?? 0);
if ($companyId <= 0) {
Response::error('参数错误', 400);
}
[$page, $limit] = pageParams(5);
$pdo = DB::getInstance()->getPdo();
$chk = $pdo->prepare("SELECT COUNT(*) FROM companies WHERE id = ?");
$chk->execute([$companyId]);
if ((int)$chk->fetchColumn() === 0) {
Response::error('企业不存在');
}
$stmt = $pdo->prepare("SELECT COUNT(*) FROM company_products WHERE company_id = ? AND is_active = 1");
$stmt->execute([$companyId]);
$total = (int)$stmt->fetchColumn();
$offset = ($page - 1) * $limit;
$stmt = $pdo->prepare(
"SELECT id, category_name, category_description, is_core, is_active
FROM company_products
WHERE company_id = ? AND is_active = 1
ORDER BY is_core DESC, id DESC
LIMIT $limit OFFSET $offset"
);
$stmt->execute([$companyId]);
Response::success(['list' => $stmt->fetchAll(), 'total' => $total, 'page' => $page, 'limit' => $limit]);
+38 -5
View File
@@ -19,7 +19,9 @@ if ($id <= 0) {
$data = extractFields(COMPANY_FIELDS);
unset($data['display_name']); // 显示名称不允许通过编辑接口置空/改名,如需改名请走完整字段
if (empty($data)) {
$hasFinancials = array_key_exists('financials', $_POST);
$hasCertifications = array_key_exists('certifications', $_POST);
if (empty($data) && !$hasFinancials && !$hasCertifications) {
Response::error('没有需要更新的字段', 400);
}
@@ -32,9 +34,40 @@ if (!$old) {
Response::error('企业不存在');
}
[$sets, $params] = buildUpdate($data);
$params[] = $id;
$pdo->prepare("UPDATE companies SET $sets WHERE id = ?")->execute($params);
if (!empty($data)) {
[$sets, $params] = buildUpdate($data);
$params[] = $id;
$pdo->prepare("UPDATE companies SET $sets WHERE id = ?")->execute($params);
}
logCurrent('update', 'company', 'companies', $id, ['before' => $old, 'after' => $data]);
// 财务信息 / 资质认证(可选,整表替换)
if ($hasFinancials || $hasCertifications) {
$pdo->beginTransaction();
try {
if ($hasFinancials) {
$financials = json_decode($_POST['financials'], true);
if (!is_array($financials)) {
$pdo->rollBack();
Response::error('财务信息格式错误', 400);
}
saveCompanyFinancials($pdo, $id, $financials);
}
if ($hasCertifications) {
$certs = json_decode($_POST['certifications'], true);
if (!is_array($certs)) {
$pdo->rollBack();
Response::error('资质认证格式错误', 400);
}
saveCompanyCertifications($pdo, $id, $certs);
}
$pdo->commit();
} catch (Exception $e) {
$pdo->rollBack();
Response::error('关联信息保存失败:' . $e->getMessage());
}
}
if (!empty($data)) {
logCurrent('update', 'company', 'companies', $id, ['before' => $old, 'after' => $data]);
}
Response::success(null, '更新成功');