更新
This commit is contained in:
@@ -10,7 +10,7 @@ use think\facade\Db;
|
||||
*/
|
||||
class ChatController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['notifyOpen', 'logAvPermission'];
|
||||
public array $notNeedLogin = ['notifyOpen', 'notifyClose', 'logAvPermission'];
|
||||
|
||||
/**
|
||||
* 上报音视频权限拒绝日志
|
||||
@@ -55,4 +55,21 @@ class ChatController extends BaseApiController
|
||||
ChatNotifyLogic::addNotify($doctorId, $patientId ?: '0', $patientName);
|
||||
return $this->success('已通知');
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者离开会话页时通知医生(管理后台轮询 + 可与 IM 信令配合)
|
||||
*/
|
||||
public function notifyClose()
|
||||
{
|
||||
$doctorId = (int) ($this->request->post('doctor_id') ?: $this->request->post('doctorId'));
|
||||
$patientId = trim((string) ($this->request->post('patient_id') ?: $this->request->post('patientId') ?: ''));
|
||||
$patientName = trim((string) ($this->request->post('patient_name') ?: $this->request->post('patientName') ?: '患者'));
|
||||
|
||||
if ($doctorId <= 0) {
|
||||
return $this->fail('医生ID无效');
|
||||
}
|
||||
|
||||
ChatNotifyLogic::addPatientLeftNotify($doctorId, $patientId ?: '0', $patientName);
|
||||
return $this->success('已通知');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,30 @@ class ChatNotifyLogic extends BaseLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者离开会话页/诊室时通知医生端(管理后台轮询)
|
||||
*/
|
||||
public static function addPatientLeftNotify(int $doctorId, string $patientId, string $patientName): bool
|
||||
{
|
||||
$key = self::CACHE_PREFIX . $doctorId;
|
||||
$item = [
|
||||
'id' => uniqid('', true),
|
||||
'type' => 'patient_left_chat',
|
||||
'doctor_id' => $doctorId,
|
||||
'patient_id' => $patientId,
|
||||
'patient_name' => $patientName,
|
||||
'created_at' => time(),
|
||||
];
|
||||
$list = Cache::get($key) ?: [];
|
||||
if (!is_array($list)) {
|
||||
$list = [];
|
||||
}
|
||||
array_unshift($list, $item);
|
||||
$list = array_slice($list, 0, self::MAX_PER_DOCTOR);
|
||||
Cache::set($key, $list, self::CACHE_TTL);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加面诊结束通知(医生完成接诊后通知对应医助)
|
||||
* @param int $assistantId 医助ID (admin_id)
|
||||
|
||||
Reference in New Issue
Block a user