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
+64
View File
@@ -0,0 +1,64 @@
<?php
/**
* 渠道新增计划列表接口 GET /api/channel/plan_list.php
* v1.0.18 渠道管理 - 渠道新增计划
* 参数:page / limit / channel_type / status / keyword
* 返回:{ list, total, page, limit }(list 含 remaining_days 剩余天数)
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
require_once __DIR__ . '/../common/auth.php';
checkPermission('channel');
[$page, $limit] = pageParams();
$channelType = trim($_REQUEST['channel_type'] ?? '');
$status = trim($_REQUEST['status'] ?? '');
$keyword = trim($_REQUEST['keyword'] ?? '');
$where = ['is_active = 1'];
$params = [];
if ($channelType !== '') {
$where[] = 'channel_type = ?';
$params[] = $channelType;
}
if ($status !== '') {
$where[] = 'status = ?';
$params[] = $status;
}
if ($keyword !== '') {
$where[] = '(source_detail LIKE ? OR industry LIKE ? OR remark LIKE ?)';
$like = "%$keyword%";
array_push($params, $like, $like, $like);
}
$whereSql = implode(' AND ', $where);
$pdo = DB::getInstance()->getPdo();
$stmt = $pdo->prepare("SELECT COUNT(*) FROM channel_plans WHERE $whereSql");
$stmt->execute($params);
$total = (int)$stmt->fetchColumn();
$offset = ($page - 1) * $limit;
$stmt = $pdo->prepare(
"SELECT id, channel_type, source_detail, industry, start_date, end_date, remark, status, created_at, updated_at
FROM channel_plans
WHERE $whereSql
ORDER BY id DESC
LIMIT $limit OFFSET $offset"
);
$stmt->execute($params);
$list = $stmt->fetchAll();
// 剩余天数:距时间窗口结束日(end_date)的天数,已过期为 0
$today = strtotime(date('Y-m-d'));
foreach ($list as &$row) {
$row['remaining_days'] = 0;
if (!empty($row['end_date']) && strtotime($row['end_date']) !== false) {
$diff = (int)ceil((strtotime($row['end_date']) - $today) / 86400);
$row['remaining_days'] = max(0, $diff);
}
}
unset($row);
Response::success(['list' => $list, 'total' => $total, 'page' => $page, 'limit' => $limit]);