From 836e0c4b9e1d9706c1c9ea55f3d41400015f20d9 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 17 Apr 2023 19:57:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A8=E9=80=81=20?= =?UTF-8?q?=E5=8C=BB=E7=94=9F-=E6=82=A3=E8=80=85=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E9=97=AE=E8=AF=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/MessagePush.php | 88 ++++++++++++++++++++++++++-- app/Services/PatientOrderService.php | 13 ++++ 2 files changed, 96 insertions(+), 5 deletions(-) diff --git a/app/Services/MessagePush.php b/app/Services/MessagePush.php index 5b6b8ec..e017877 100644 --- a/app/Services/MessagePush.php +++ b/app/Services/MessagePush.php @@ -1107,7 +1107,7 @@ class MessagePush extends BaseService } /** - * 问诊结束 + * 医生-问诊结束 * 站内 * 发送给医生 * @return bool @@ -1157,7 +1157,7 @@ class MessagePush extends BaseService } /** - * 医生开具的处方审核通过 + * 医生-开具的处方审核通过 * 站内、订阅失败发送短信 * @return bool * @throws ContainerExceptionInterface @@ -1242,7 +1242,7 @@ class MessagePush extends BaseService } /** - * 医生开具的处方审核未通过 + * 医生-开具的处方审核未通过 * 订阅失败发送短信 * @param string $order_prescription_id * @return bool @@ -1847,7 +1847,7 @@ class MessagePush extends BaseService * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function DoctorSystemUpgrade(string $date,string $function): bool + public function doctorSystemUpgrade(string $date,string $function): bool { try { if ($this->push_type == 1) { @@ -1885,7 +1885,7 @@ class MessagePush extends BaseService * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function DoctorAgreementUpdate(string $title): bool + public function doctorAgreementUpdate(string $title): bool { try { if ($this->push_type == 1) { @@ -1914,4 +1914,82 @@ class MessagePush extends BaseService return true; } + + /** + * 医生-患者取消问诊 + * 站内-订阅 + * @return bool + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function patientCancelInquiryToDoctor(): bool + { + try { + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $this->order_inquiry['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + throw new BusinessException("加入推送队列失败:医生数据为空"); + } + + // 站内 + $data = array(); + $data['user_id'] = $this->user['user_id']; + $data['notice_type'] = 1; + $data['inquiry_type'] = $this->order_inquiry['inquiry_type']; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) + $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_title'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); + $data['notice_title'] = "患者已取消问诊咨询。"; + $data['notice_content'] = "患者已取消问诊咨询,您可选择其他患者的问诊咨询进行接诊。"; + $data['link_type'] = 3; // 问诊消息列表页 + + $link_params = array(); + $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; + $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; + $link_params['doctor_user_id'] = $user_doctor['user_id']; + $link_params['patient_user_id'] = $this->order_inquiry['user_id']; + $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + + $message = new SendStationMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + } + + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc";//咨询提醒 + $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; + $sub_data['params']['data'] = [ + "thing1" => "问诊咨询已取消",// 提醒内容 + + "name2" => $this->order_inquiry['patient_name'],// 患者姓名 + + "thing4" => (string)$user_doctor['user_name'],// 病情描述 + + "thing6" => "您可以选择其他患者的问诊咨询进行接诊。",// 提示说明 + + "thing5" => "",// 咨询内容 + + ]; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = []; + + $message = new SendSubMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + } + } catch (\Exception $e) { + throw new BusinessException("加入推送队列失败" . $e->getMessage()); + } + + return true; + } + } \ No newline at end of file diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index d5cac18..6f13b56 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -318,6 +318,19 @@ class PatientOrderService extends BaseService $inquiryService->inquiryRefund($order_inquiry['order_inquiry_id'], "取消问诊"); } + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $order_inquiry['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR,"取消失败"); + } + + // 推送医生-患者取消问诊 + $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush->patientCancelInquiryToDoctor(); + Db::commit(); } catch (\Exception $e) { Db::rollBack();