新增功能

This commit is contained in:
Your Name
2026-03-24 16:32:56 +08:00
parent 250d173c2f
commit 9160c36735
248 changed files with 3063 additions and 250 deletions
@@ -19,6 +19,7 @@ use app\common\model\tcm\Diagnosis;
use app\common\model\DiagnosisViewRecord;
use app\common\model\doctor\Appointment;
use app\common\model\tcm\Prescription;
use app\common\model\tcm\CallRecord;
use app\common\model\auth\Admin;
use app\common\model\auth\AdminRole;
use app\common\lists\ListsSearchInterface;
@@ -171,9 +172,76 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
$item['has_prescription'] = isset($prescriptionMap[$item['id']]) ? 1 : 0;
}
// 最近一条通话记录状态(列表行展示:通话中 / 已结束等)
$latestCallByDiag = [];
if (!empty($diagnosisIds)) {
$agg = CallRecord::whereIn('diagnosis_id', $diagnosisIds)
->field('diagnosis_id, MAX(id) AS max_id')
->group('diagnosis_id')
->select()
->toArray();
$maxIds = array_filter(array_column($agg, 'max_id'));
if (!empty($maxIds)) {
$recList = CallRecord::whereIn('id', $maxIds)->select()->toArray();
foreach ($recList as $r) {
$latestCallByDiag[(int)$r['diagnosis_id']] = $r;
}
}
}
foreach ($lists as &$item) {
$item['video_call_hint'] = $this->buildVideoCallHint($latestCallByDiag[$item['id']] ?? null);
}
return $lists;
}
/**
* @param array<string,mixed>|null $rec tcm_call_record 一行
* @return array{state:string,label:string,end_time?:int,start_time?:int}
*/
private function buildVideoCallHint(?array $rec): array
{
if (!$rec) {
return ['state' => 'none', 'label' => ''];
}
$st = (int)($rec['status'] ?? 0);
$roomOk = trim((string)($rec['room_id'] ?? '')) !== '';
if ($st === 1 && $roomOk) {
$t = (int)($rec['start_time'] ?? 0);
return [
'state' => 'live',
'label' => '视频通话进行中',
'start_time' => $t,
];
}
if ($st === 1 && !$roomOk) {
return [
'state' => 'pending_room',
'label' => '通话发起中,待同步房间',
];
}
if ($st === 2) {
$end = (int)($rec['end_time'] ?? 0);
$timePart = $end > 0 ? date('m-d H:i', $end) : '';
return [
'state' => 'ended',
'label' => $timePart !== '' ? ('视频已结束 · ' . $timePart) : '视频已结束',
'end_time' => $end,
];
}
if ($st === 3) {
return ['state' => 'missed', 'label' => '上次通话未接听'];
}
if ($st === 4) {
return ['state' => 'cancelled', 'label' => '上次通话已取消'];
}
return ['state' => 'none', 'label' => ''];
}
/**
* @notes 获取数量
* @return int