This commit is contained in:
Your Name
2026-03-23 18:02:16 +08:00
parent 18fee2e8f8
commit 250d173c2f
525 changed files with 10659 additions and 793 deletions
@@ -21,6 +21,9 @@ class Prescription extends BaseModel
protected $json = ['herbs', 'case_record'];
protected $jsonAssoc = true;
// 追加字段
protected $append = ['gender_desc'];
public function getGenderDescAttr($value, $data)
{
return ($data['gender'] ?? 0) == 1 ? '男' : '女';
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace app\common\model\tcm;
use app\common\model\BaseModel;
/**
* 处方库模型
*/
class PrescriptionLibrary extends BaseModel
{
protected $name = 'prescription_library';
protected $autoWriteTimestamp = true;
protected $deleteTime = 'delete_time';
/**
* @notes 获取器 - 创建时间
*/
public function getCreateTimeAttr($value)
{
return $value ? date('Y-m-d H:i:s', $value) : '';
}
/**
* @notes 获取器 - 更新时间
*/
public function getUpdateTimeAttr($value)
{
return $value ? date('Y-m-d H:i:s', $value) : '';
}
}
+90 -2
View File
@@ -233,13 +233,101 @@ class TencentImService
}
}
/**
* 拉取单聊(C2C)漫游消息
* @see https://cloud.tencent.com/document/product/269/2739
*
* @param string $operatorAccount 会话一方 UserID(如 doctor_1
* @param string $peerAccount 会话另一方 UserID(如 patient_2
* @return array{success:bool,msgList:array,complete:int,lastMsgKey:?string,lastMsgTime:?int,error:string,rawErrorCode:int}
*/
public function adminGetRoamMsg(
string $operatorAccount,
string $peerAccount,
int $maxCnt = 100,
int $minTime = 0,
int $maxTime = 4294967295,
?string $lastMsgKey = null,
?int $lastMsgTime = null
): array {
$empty = [
'success' => false,
'msgList' => [],
'complete' => 1,
'lastMsgKey' => null,
'lastMsgTime' => null,
'error' => '',
'rawErrorCode' => 0,
];
try {
$adminUserSig = $this->generateUserSig($this->adminIdentifier);
if (!$adminUserSig) {
$empty['error'] = '生成管理员UserSig失败';
return $empty;
}
$random = rand(0, 4294967295);
$url = sprintf(
'https://console.tim.qq.com/v4/openim/admin_getroammsg?sdkappid=%s&identifier=%s&usersig=%s&random=%s&contenttype=json',
$this->sdkAppId,
$this->adminIdentifier,
urlencode($adminUserSig),
$random
);
$data = [
'Operator_Account' => $operatorAccount,
'Peer_Account' => $peerAccount,
'MaxCnt' => $maxCnt,
'MinTime' => $minTime,
'MaxTime' => $maxTime,
];
if ($lastMsgKey !== null && $lastMsgKey !== '') {
$data['LastMsgKey'] = $lastMsgKey;
}
if ($lastMsgTime !== null && $lastMsgTime > 0) {
$data['LastMsgTime'] = $lastMsgTime;
}
$result = $this->httpPost($url, json_encode($data), 30);
if (!$result) {
$empty['error'] = 'IM接口无响应';
return $empty;
}
$response = json_decode($result, true);
if (!$response) {
$empty['error'] = 'IM响应解析失败';
return $empty;
}
$code = (int)($response['ErrorCode'] ?? -1);
$empty['rawErrorCode'] = $code;
if (($response['ActionStatus'] ?? '') !== 'OK') {
$empty['error'] = $response['ErrorInfo'] ?? ('ErrorCode ' . $code);
return $empty;
}
$msgList = $response['MsgList'] ?? [];
if (!is_array($msgList)) {
$msgList = [];
}
return [
'success' => true,
'msgList' => $msgList,
'complete' => (int)($response['Complete'] ?? 1),
'lastMsgKey' => $response['LastMsgKey'] ?? null,
'lastMsgTime' => isset($response['LastMsgTime']) ? (int)$response['LastMsgTime'] : null,
'error' => '',
'rawErrorCode' => $code,
];
} catch (\Exception $e) {
$empty['error'] = $e->getMessage();
return $empty;
}
}
/**
* @notes 发送HTTP POST请求
* @param string $url
* @param string $data
* @return string|false
*/
private function httpPost(string $url, string $data)
private function httpPost(string $url, string $data, int $timeout = 10)
{
$ch = curl_init();
@@ -247,7 +335,7 @@ class TencentImService
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, [