no commit message

This commit is contained in:
annnj-company
2026-04-27 10:10:35 +08:00
parent 68a0b1ab22
commit 6fc3e6b64f
19 changed files with 1058 additions and 64 deletions

View File

@@ -561,9 +561,29 @@ class Survey extends Base
if (is_array($list)) {
$refer = array();
foreach ($list as $key => $data) {
// 跳过空数据或非数组数据
if (!is_array($data) || empty($data)) {
continue;
}
// 确保主键字段存在
if (!isset($data[$pk])) {
continue;
}
$refer[$data[$pk]] = &$list[$key];
}
foreach ($list as $key => $data) {
// 跳过空数据或非数组数据
if (!is_array($data) || empty($data)) {
continue;
}
// 确保父ID字段存在
if (!isset($data[$pid])) {
continue;
}
// 确保code字段存在
if (!isset($data['code'])) {
continue;
}
$parentId = $data[$pid];
if ($root == $parentId) {
$tree[$data['code']] = &$list[$key];
@@ -759,4 +779,53 @@ class Survey extends Base
}
}
/**
* 获取查勘跟进中数量(当前登录人)
* @return \think\Response
*/
public function surveyFollowCount()
{
// 检查用户信息
if (empty($this->userInfo)) {
error_log("surveyFollowCount: userInfo is empty");
return $this->buildFailed('用户信息不存在');
}
// 检查用户ID
if (!isset($this->userInfo['user_id'])) {
error_log("surveyFollowCount: user_id is not set");
return $this->buildFailed('用户ID不存在');
}
$Survey = new SurveyModel();
// 如果是管理员admin 或 COM_TOP_ADMIN不限制 user_id
if ($this->isAdmin()) {
$count = $Survey->alias('s')
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
->where('i.status', 4)
->where('s.status', 2)
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
->group('s.id')
->count();
} else {
// 非管理员,只统计当前用户的查勘
$userId = $this->userInfo['user_id'];
$count = $Survey->alias('s')
->join('pg_inquiry i', 's.order_no = i.order_no', 'INNER')
->where('i.status', 4)
->where('s.status', 2)
->where('s.user_id', $userId)
->where('s.assign_time', 'gt', '2025-02-01 00:00:00')
->group('s.id')
->count();
}
error_log("surveyFollowCount: count = $count, userId = " . $this->userInfo['user_id'] . ", isAdmin = " . ($this->isAdmin() ? 'true' : 'false'));
return $this->buildSuccess([
'count' => $count
]);
}
}