新增功能
This commit is contained in:
@@ -18,6 +18,7 @@ use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\tcm\DiagnosisLists;
|
||||
use app\adminapi\logic\tcm\DiagnosisLogic;
|
||||
use app\adminapi\validate\tcm\DiagnosisValidate;
|
||||
use app\common\model\WechatChatRecord;
|
||||
|
||||
/**
|
||||
* 中医辨房病因诊单控制器
|
||||
@@ -97,6 +98,7 @@ class DiagnosisController extends BaseAdminController
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
|
||||
$params = (new DiagnosisValidate())->goCheck('id');
|
||||
$result = DiagnosisLogic::detail($params);
|
||||
return $this->data($result);
|
||||
@@ -324,6 +326,135 @@ class DiagnosisController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 生成订单小程序码
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function generateOrderQrcode()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['share_user_id'] = $this->adminId;
|
||||
$result = DiagnosisLogic::generateOrderQrcode($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(DiagnosisLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取企业微信聊天记录
|
||||
*/
|
||||
public function getWechatChatRecords()
|
||||
{
|
||||
$diagnosisId = $this->request->get('diagnosis_id', 0);
|
||||
$patientId = $this->request->get('patient_id', 0);
|
||||
$pageNo = $this->request->get('page_no', 1);
|
||||
$pageSize = $this->request->get('page_size', 20);
|
||||
|
||||
if (empty($diagnosisId) && empty($patientId)) {
|
||||
return $this->fail('诊单ID或患者ID不能都为空');
|
||||
}
|
||||
|
||||
$query = WechatChatRecord::order('chat_time', 'desc');
|
||||
if ($diagnosisId) {
|
||||
$query->where('diagnosis_id', $diagnosisId);
|
||||
}
|
||||
if ($patientId) {
|
||||
$query->where('patient_id', $patientId);
|
||||
}
|
||||
|
||||
$count = (clone $query)->count();
|
||||
$lists = $query->page($pageNo, $pageSize)->select()->toArray();
|
||||
|
||||
return $this->data([
|
||||
'lists' => $lists,
|
||||
'count' => $count,
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加企业微信聊天记录(手动录入/同步写入)
|
||||
*/
|
||||
public function addWechatChatRecord()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
|
||||
if (empty($params['diagnosis_id']) && empty($params['patient_id'])) {
|
||||
return $this->fail('诊单ID或患者ID不能都为空');
|
||||
}
|
||||
if (empty($params['content'])) {
|
||||
return $this->fail('内容不能为空');
|
||||
}
|
||||
|
||||
$adminInfo = $this->adminInfo;
|
||||
|
||||
$data = [
|
||||
'diagnosis_id' => $params['diagnosis_id'] ?? 0,
|
||||
'patient_id' => $params['patient_id'] ?? 0,
|
||||
'staff_userid' => $adminInfo['work_wechat_userid'] ?? ($params['staff_userid'] ?? ''),
|
||||
'staff_name' => $params['staff_name'] ?? ($adminInfo['name'] ?? ''),
|
||||
'external_userid' => $params['external_userid'] ?? '',
|
||||
'external_name' => $params['external_name'] ?? '',
|
||||
'msg_type' => $params['msg_type'] ?? 'note',
|
||||
'content' => $params['content'],
|
||||
'media_url' => $params['media_url'] ?? '',
|
||||
'chat_time' => $params['chat_time'] ?? time(),
|
||||
'direction' => $params['direction'] ?? 0,
|
||||
'create_time' => time(),
|
||||
];
|
||||
|
||||
$record = WechatChatRecord::create($data);
|
||||
|
||||
return $this->success('添加成功', ['id' => $record->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除企业微信聊天记录
|
||||
*/
|
||||
public function deleteWechatChatRecord()
|
||||
{
|
||||
$id = $this->request->post('id', 0);
|
||||
if (empty($id)) {
|
||||
return $this->fail('记录ID不能为空');
|
||||
}
|
||||
|
||||
WechatChatRecord::destroy($id);
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 同步企业微信外部联系人信息(查找该患者在企业微信中的跟进人)
|
||||
*/
|
||||
public function getWechatExternalContact()
|
||||
{
|
||||
$patientId = $this->request->get('patient_id', 0);
|
||||
if (empty($patientId)) {
|
||||
return $this->fail('患者ID不能为空');
|
||||
}
|
||||
|
||||
$result = DiagnosisLogic::getWechatExternalContact($patientId);
|
||||
if ($result === false) {
|
||||
return $this->fail(DiagnosisLogic::getError());
|
||||
}
|
||||
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取会话内容存档开启的成员列表
|
||||
*/
|
||||
public function getMsgAuditPermitUsers()
|
||||
{
|
||||
$result = DiagnosisLogic::getMsgAuditPermitUsers();
|
||||
if ($result === false) {
|
||||
return $this->fail(DiagnosisLogic::getError());
|
||||
}
|
||||
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索患者(用于创建订单等场景)
|
||||
* @return \think\response\Json
|
||||
|
||||
Reference in New Issue
Block a user