This commit is contained in:
Your Name
2026-03-20 18:00:19 +08:00
parent d765517b74
commit 18fee2e8f8
240 changed files with 976 additions and 280 deletions
@@ -0,0 +1,25 @@
<?php
namespace app\adminapi\controller;
use app\api\logic\ChatNotifyLogic;
/**
* 聊天通知接口(管理端-医生)
*/
class ChatController extends BaseAdminController
{
/**
* 获取当前医生的患者打开会话通知
* 轮询接口,获取后即消费
*/
public function notifications()
{
$doctorId = $this->adminId;
if ($doctorId <= 0) {
return $this->success('', []);
}
$list = ChatNotifyLogic::getNotifies($doctorId, true);
return $this->success('', $list);
}
}
@@ -5,6 +5,9 @@ namespace app\adminapi\logic\doctor;
use app\common\logic\BaseLogic;
use app\common\model\doctor\Appointment;
use app\common\model\doctor\Roster;
use app\common\model\tcm\Diagnosis;
use app\common\model\auth\Admin;
use app\api\logic\ChatNotifyLogic;
use think\facade\Db;
/**
@@ -390,6 +393,25 @@ class AppointmentLogic extends BaseLogic
$appointment->update_time = time();
$appointment->save();
// 面诊结束:通知对应医助(从诊单 assistant_id 获取)
try {
$diagnosis = Diagnosis::where('id', $appointment->patient_id)->find();
if ($diagnosis && !empty($diagnosis->assistant_id)) {
$assistantId = (int) $diagnosis->assistant_id;
$patientName = $diagnosis->patient_name ?? '患者';
$doctor = Admin::where('id', $appointment->doctor_id)->find();
$doctorName = $doctor ? $doctor->name : '医生';
ChatNotifyLogic::addConsultationCompleteNotify(
$assistantId,
$patientName,
$doctorName,
(int) $appointment->patient_id
);
}
} catch (\Throwable $e) {
\think\facade\Log::warning('面诊结束通知医助失败: ' . $e->getMessage());
}
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());
@@ -924,16 +924,17 @@ class DiagnosisLogic extends BaseLogic
self::setError('生成签名失败');
return false;
}
//添加患者资料
// 确保患者账号已导入IM
self::ensurePatientImAccount($patientId, $patientUserId);
\think\facade\Log::info('小程序获取患者签名成功 - patient_id: ' . $patientId . ', user_id: ' . $patientUserId);
$data= Diagnosis::where('id', $patientId)->find();
return [
'sdkAppId' => (int)$config['sdkAppId'],
'userId' => $patientUserId,
'userSig' => $userSig,
'data'=>$data,
'expireTime' => 86400
];
} catch (\Exception $e) {