v1.0.19: 修复人员编辑入口缺失(person.js addPerson/editPerson) + 渠道明细数量字段名(analysis.php cnt) + CDP全量验证43项PASS

This commit is contained in:
nanguaboss
2026-08-08 19:29:14 +08:00
parent 2cb688ed46
commit 1c8b374a72
40 changed files with 2313 additions and 658 deletions
+35 -3
View File
@@ -1,6 +1,7 @@
<?php
/**
* 企业产品品类列表接口 GET /api/company/products.php
* 企业产品列表接口 GET /api/company/products.php
* v1.0.18:返回产品基础字段(产品品类/基本定位/包含系列/状态/更新日期)+ EAV 参数值(JSON)
* 入参:company_id(必填)/ page / limit
*/
require_once __DIR__ . '/../common/db.php';
@@ -30,12 +31,43 @@ $total = (int)$stmt->fetchColumn();
$offset = ($page - 1) * $limit;
$stmt = $pdo->prepare(
"SELECT id, category_name, category_description, is_core, is_active
"SELECT id, category_name, category_description, positioning, series, is_core, is_active, created_at, updated_at
FROM company_products
WHERE company_id = ? AND is_active = 1
ORDER BY is_core DESC, id DESC
LIMIT $limit OFFSET $offset"
);
$stmt->execute([$companyId]);
$list = $stmt->fetchAll();
Response::success(['list' => $stmt->fetchAll(), 'total' => $total, 'page' => $page, 'limit' => $limit]);
// 批量取 EAV 参数值(每个产品一个 JSON:attr_id => 值)
if ($list) {
$ids = array_column($list, 'id');
$in = implode(',', array_fill(0, count($ids), '?'));
$valStmt = $pdo->prepare(
"SELECT v.product_id, a.attr_name, a.attr_type, a.unit,
v.value_string, v.value_number, v.value_boolean, v.value_date
FROM company_products_attr_value v
INNER JOIN company_products_attr a ON a.id = v.attr_id
WHERE v.product_id IN ($in)"
);
$valStmt->execute($ids);
$values = [];
foreach ($valStmt as $v) {
$values[$v['product_id']][] = [
'attr_name' => $v['attr_name'],
'attr_type' => $v['attr_type'],
'unit' => $v['unit'],
'value' => $v['value_string'] !== null ? $v['value_string']
: ($v['value_number'] !== null ? rtrim(rtrim(sprintf('%.4f', $v['value_number']), '0'), '.')
: ($v['value_boolean'] !== null ? ($v['value_boolean'] ? '是' : '否')
: ($v['value_date'] ?? ''))),
];
}
foreach ($list as &$row) {
$row['attrs'] = $values[$row['id']] ?? [];
}
unset($row);
}
Response::success(['list' => $list, 'total' => $total, 'page' => $page, 'limit' => $limit]);