From e00fab60bb8230e39086ad0e039fab9524f73e40 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Tue, 30 May 2023 11:37:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A2=E9=98=85=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A8=E9=80=81-=E5=8C=BB=E7=94=9F-=E5=8C=BB?= =?UTF-8?q?=E7=94=9F=E6=9C=89=E6=96=B0=E9=97=AE=E8=AF=8A=EF=BC=8C=E5=8C=BB?= =?UTF-8?q?=E7=94=9F=E8=B6=85=E6=97=B6=E6=9C=AA=E6=8E=A5=E8=AF=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AssignDoctorDelayDirectConsumer.php | 3 + ...ncelUnInquiryOrdersDelayDirectConsumer.php | 6 +- app/Controller/CallBackController.php | 3 + app/Services/ImService.php | 46 +- app/Services/MessagePush.php | 427 +++++++++++------- app/Services/PatientOrderService.php | 3 + 6 files changed, 312 insertions(+), 176 deletions(-) diff --git a/app/Amqp/Consumer/AssignDoctorDelayDirectConsumer.php b/app/Amqp/Consumer/AssignDoctorDelayDirectConsumer.php index 09a095a..89dbf06 100644 --- a/app/Amqp/Consumer/AssignDoctorDelayDirectConsumer.php +++ b/app/Amqp/Consumer/AssignDoctorDelayDirectConsumer.php @@ -266,6 +266,9 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage $imService = new ImService(); $imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); + // 发送IM消息-横幅通知-医生有新问诊 + $imService->bannerNoticeNewInquiry($order_inquiry,$user_doctor['user_id']); + // 医生-医生有新问诊 站内、订阅失败发送短信 $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); $MessagePush->doctorHaveNewInquiry(); diff --git a/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php b/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php index 5627ec6..028219b 100644 --- a/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php +++ b/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php @@ -160,10 +160,14 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage // 发送IM消息-问诊退款 $imService->inquiryRefund($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); - // 发送站内、订阅消息-医生未接诊 + // 发送站内、订阅消息-患者-医生未接诊 $MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']); $MessagePush->patientNoInquiry(); + // 发送站内、订阅消息-医生-超时未接诊 + $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush->doctorNoInquiry(); + if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) { // 获取用户优惠卷信息 $params = array(); diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index 188ff6b..49ce394 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -170,6 +170,9 @@ class CallBackController extends AbstractController $imService = new ImService(); $imService->waitDoctorInquiry($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id']); + // 发送IM消息-横幅通知-医生有新问诊 + $imService->bannerNoticeNewInquiry($order_inquiry,$user_doctor['user_id']); + // 发送站内、订阅失败发送短信消息-医生有新问诊 $MessagePush = new MessagePush($user_doctor['user_id'], $order_inquiry['order_inquiry_id']); $MessagePush->doctorHaveNewInquiry(); diff --git a/app/Services/ImService.php b/app/Services/ImService.php index bc7a570..5150d94 100644 --- a/app/Services/ImService.php +++ b/app/Services/ImService.php @@ -552,7 +552,7 @@ class ImService extends BaseService * @param string $patient_user_id * @return void */ - public function pharmacistVerify(array|object $order_inquiry, string $order_prescription_id,string $product_name,string $doctor_user_id, string $patient_user_id): void + public function pharmacistVerify(array|object $order_inquiry, string $order_prescription_id, string $product_name, string $doctor_user_id, string $patient_user_id): void { try { // 发送消息 @@ -573,7 +573,7 @@ class ImService extends BaseService $message_content_data['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id']; $message_content_data['data']['order_prescription_id'] = $order_prescription_id; $message_content_data['data']['product_name'] = $product_name ?: "药品"; - $message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());; + $message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s', time());; $message_content = [ 'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE), @@ -619,4 +619,46 @@ class ImService extends BaseService throw new BusinessException($e->getMessage()); } } + + /** + * 横幅通知-医生有新问诊 + * @param array|object $order_inquiry + * @param string $doctor_user_id 用户id + * @return void + */ + public function bannerNoticeNewInquiry(array|object $order_inquiry, string $doctor_user_id): void + { + try { + // 发送消息 + $cloud_custom_data = array(); + $cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $cloud_custom_data['is_system'] = 1; + $cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type']; + $cloud_custom_data['message_rounds'] = 0; + $cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name']; + $cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex']; + $cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age']; + + if ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3) { + // 专家、公益 + $desc = "24小时内未接诊,平台将自动取消问诊"; + }else{ + // 快速、购药 + $desc = "5分钟内未接诊,平台将自动取消问诊"; + } + + // 消息内容 医生-患者 + $message_content_data = array(); + $message_content_data['message_type'] = 1; + $message_content_data['title'] = "您有一个新的问诊服务等待接诊"; + $message_content_data['desc'] = $desc; + $message_content = [ + 'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE), + ]; + + $this->sendMessage("", $doctor_user_id, $message_content, "TIMCustomElem", $cloud_custom_data); + } catch (\Exception $e) { + throw new BusinessException($e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/Services/MessagePush.php b/app/Services/MessagePush.php index b20b48f..f81d172 100644 --- a/app/Services/MessagePush.php +++ b/app/Services/MessagePush.php @@ -96,7 +96,7 @@ class MessagePush extends BaseService $link_params = array(); $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数 $data['button_type'] = 4; // 订单详情 @@ -104,7 +104,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 订阅 @@ -112,7 +112,7 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { Log::getInstance("MessagePush")->error("错误:医生数据为空"); return; } @@ -137,7 +137,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:" . $e->getMessage()); @@ -156,7 +156,7 @@ class MessagePush extends BaseService try { // 订阅 // 获取医生数据 - if (!empty($this->order_inquiry['doctor_id'])){ + if (!empty($this->order_inquiry['doctor_id'])) { $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); @@ -182,7 +182,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:" . $e->getMessage()); @@ -201,7 +201,7 @@ class MessagePush extends BaseService { try { // 只有订阅消息 - if ($this->push_type == 2){ + if ($this->push_type == 2) { $sub_data = array(); $sub_data['push_user_id'] = $this->user['user_id']; $sub_data['wx_template_id'] = "jhYUf91ULCTX_f69hazqAYwImdFf8ELasRAwB6X-MTM"; // 患者回复通知 @@ -218,7 +218,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -242,8 +242,8 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ - Log::getInstance("MessagePush")->error("错误:医生数据为空" ); + if (empty($user_doctor)) { + Log::getInstance("MessagePush")->error("错误:医生数据为空"); return; } @@ -251,8 +251,8 @@ class MessagePush extends BaseService $params = array(); $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $order_inquiry_case = OrderInquiryCase::getOne($params); - if (empty($order_inquiry_case)){ - Log::getInstance("MessagePush")->error("错误:病例数据为空" ); + if (empty($order_inquiry_case)) { + Log::getInstance("MessagePush")->error("错误:病例数据为空"); return; } @@ -282,7 +282,7 @@ class MessagePush extends BaseService $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);// 跳转参数 + $data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数 $data['button_type'] = 6; // 问诊详情 @@ -290,15 +290,15 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 问诊内容-病情主诉 $disease_desc = $order_inquiry_case['disease_desc']; - if (!empty($disease_desc)){ - if (strlen($disease_desc) > 15){ - $disease_desc = mb_substr($disease_desc,0,15); - if ($disease_desc){ + if (!empty($disease_desc)) { + if (strlen($disease_desc) > 15) { + $disease_desc = mb_substr($disease_desc, 0, 15); + if ($disease_desc) { $disease_desc = $disease_desc . "..."; } } @@ -324,14 +324,14 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 短信 $duration = $system_inquiry_config['duration']; - if ($duration <= 0){ + if ($duration <= 0) { $duration = "不限制"; - }else{ + } else { $duration = $duration . "分钟"; } @@ -351,7 +351,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -372,7 +372,7 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { Log::getInstance("MessagePush")->error("错误:医生数据为空"); return; } @@ -381,8 +381,8 @@ class MessagePush extends BaseService $params = array(); $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $order_inquiry_case = OrderInquiryCase::getOne($params); - if (empty($order_inquiry_case)){ - Log::getInstance("MessagePush")->error("错误:病例数据为空" ); + if (empty($order_inquiry_case)) { + Log::getInstance("MessagePush")->error("错误:病例数据为空"); return; } @@ -407,21 +407,21 @@ class MessagePush extends BaseService $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);// 跳转参数 + $data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数 $data['button_type'] = 4; // 订单详情 $message = new SendStationMessageProducer($data); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 问诊内容 $disease_desc = $order_inquiry_case['disease_desc']; - if (!empty($disease_desc)){ - $disease_desc = substr($disease_desc,0,15); - if ($disease_desc){ + if (!empty($disease_desc)) { + $disease_desc = substr($disease_desc, 0, 15); + if ($disease_desc) { $disease_desc = $disease_desc . "..."; } } @@ -445,7 +445,7 @@ class MessagePush extends BaseService $message = new SendSubMessageProducer($data); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -466,9 +466,9 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { Log::getInstance("MessagePush")->error("错误:医生数据为空"); - return ; + return; } // 站内 @@ -481,7 +481,7 @@ class MessagePush extends BaseService $order_prescription = OrderPrescription::getOne($params); if (empty($order_prescription)) { Log::getInstance("MessagePush")->error("错误:处方数据为空"); - return ; + return; } $data = array(); @@ -496,7 +496,7 @@ class MessagePush extends BaseService $link_params = array(); $link_params['order_prescription_id'] = $order_prescription['order_prescription_id']; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数 $data['button_type'] = 5; // 查看处方 @@ -504,7 +504,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 短信 @@ -522,7 +522,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -543,9 +543,9 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { Log::getInstance("MessagePush")->error("错误:医生数据为空"); - return ; + return; } // 站内 @@ -563,7 +563,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -595,7 +595,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -627,7 +627,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -659,7 +659,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -677,14 +677,14 @@ class MessagePush extends BaseService public function refundInquirySuccess(int $cancel_reason): void { try { - if (!empty($this->order_inquiry['doctor_id'])){ + if (!empty($this->order_inquiry['doctor_id'])) { // 获取医生数据 $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { Log::getInstance("MessagePush")->error("错误:医生数据为空"); - return ; + return; } } @@ -697,39 +697,39 @@ class MessagePush extends BaseService $data['notice_system_type'] = 3; $data['from_name'] = "肝胆小秘书"; $data['notice_brief_title'] = "您的【{$inquiry_type_string}】服务,平台已退款成功,点击查看详情"; - if ($cancel_reason == 1){ + if ($cancel_reason == 1) { // 已支付未接诊 - if ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 3){ + if ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 3) { $data['notice_title'] = "您的【{$inquiry_type_string}】服务,平台已退款成功"; $data['notice_content'] = "因医生繁忙未及时接诊,平台会在24小时内退款至原账户,给您带来的不便敬请谅解。"; - }else{ + } else { $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台已退款成功"; $data['notice_content'] = "因当前候诊人较多,您的咨询暂无医生接诊。平台会在24小时内退款至原账户,给您带来的不便敬请谅解。"; } - }elseif ($cancel_reason == 2){ + } elseif ($cancel_reason == 2) { // 已支付未成功分配医生 $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台已退款成功"; $data['notice_content'] = "因当前候诊人较多,您的咨询暂无医生接诊。平台会在24小时内退款至原账户,给您带来的不便敬请谅解。"; - }elseif ($cancel_reason == 3){ + } elseif ($cancel_reason == 3) { // 已支付未接诊患者取消订单 $data['notice_title'] = "您的【{$inquiry_type_string}】服务已取消"; $data['notice_content'] = "您已成功取消当前服务,平台会在24小时内退款至原账户,感谢您的支持。"; - }else{ + } else { Log::getInstance("MessagePush")->error("错误:类型错误"); - return ; + return; } $data['link_type'] = 10;// 问诊订单详情 $link_params = array(); $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 短信 @@ -749,7 +749,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -771,9 +771,9 @@ class MessagePush extends BaseService $params = array(); $params['order_product_id'] = $order_product_id; $order_product = OrderProduct::getOne($params); - if (empty($order_product)){ + if (empty($order_product)) { Log::getInstance("MessagePush")->error("错误:药品订单数据为空"); - return ; + return; } $order_product = $order_product->toArray(); @@ -782,30 +782,30 @@ class MessagePush extends BaseService $params = array(); $params['order_product_id'] = $order_product_id; $order_product_item = OrderProductItem::getList($params); - if (empty($order_product_item)){ + if (empty($order_product_item)) { Log::getInstance("MessagePush")->error("错误:商品订单列表数据为空"); - return ; + return; } // 获取商品数据 $product_name_array = array(); - foreach ($order_product_item as $item){ + foreach ($order_product_item as $item) { $params = array(); $params['product_id'] = $item['product_id']; $product = Product::getOne($params); - if (empty($product)){ + if (empty($product)) { Log::getInstance("MessagePush")->error("错误:商品数据为空"); - return ; + return; } $product_name_array[] = $product['common_name']; } $product_name = ""; - if (!empty($product_name_array)){ - if (count($product_name_array) > 1){ - $product_name = implode('、',$product_name_array); - }else{ + if (!empty($product_name_array)) { + if (count($product_name_array) > 1) { + $product_name = implode('、', $product_name_array); + } else { $product_name = $product_name_array[0]; } } @@ -824,13 +824,13 @@ class MessagePush extends BaseService $link_params = array(); $link_params['order_product_id'] = $order_product_id; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 订阅 @@ -859,7 +859,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 短信 @@ -879,7 +879,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -896,7 +896,7 @@ class MessagePush extends BaseService * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function logistics(string $status,string $order_product_id): void + public function logistics(string $status, string $order_product_id): void { try { // 站内 @@ -914,13 +914,13 @@ class MessagePush extends BaseService $link_params = array(); $link_params['order_product_id'] = $order_product_id; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -942,9 +942,9 @@ class MessagePush extends BaseService $params = array(); $params['order_product_id'] = $order_product_id; $order_product = OrderProduct::getOne($params); - if (empty($order_product)){ + if (empty($order_product)) { Log::getInstance("MessagePush")->error("错误:药品订单数据为空"); - return ; + return; } $order_product = $order_product->toArray(); @@ -953,30 +953,30 @@ class MessagePush extends BaseService $params = array(); $params['order_product_id'] = $order_product_id; $order_product_item = OrderProductItem::getList($params); - if (empty($order_product_item)){ + if (empty($order_product_item)) { Log::getInstance("MessagePush")->error("错误:商品订单列表数据为空"); - return ; + return; } // 获取商品数据 $product_name_array = array(); - foreach ($order_product_item as $item){ + foreach ($order_product_item as $item) { $params = array(); $params['product_id'] = $item['product_id']; $product = Product::getOne($params); - if (empty($product)){ + if (empty($product)) { Log::getInstance("MessagePush")->error("错误:商品数据为空"); - return ; + return; } $product_name_array[] = $product['common_name']; } $product_name = ""; - if (!empty($product_name_array)){ - if (count($product_name_array) > 1){ - $product_name = implode('、',$product_name_array); - }else{ + if (!empty($product_name_array)) { + if (count($product_name_array) > 1) { + $product_name = implode('、', $product_name_array); + } else { $product_name = $product_name_array[0]; } } @@ -1018,7 +1018,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -1058,7 +1058,7 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { Log::getInstance("MessagePush")->error("错误:医生数据为空"); return; } @@ -1067,7 +1067,7 @@ class MessagePush extends BaseService $params = array(); $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $order_inquiry_case = OrderInquiryCase::getOne($params); - if (empty($order_inquiry_case)){ + if (empty($order_inquiry_case)) { Log::getInstance("MessagePush")->error("错误:病例数据为空"); return; } @@ -1088,29 +1088,37 @@ class MessagePush extends BaseService $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);// 跳转参数 + $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) { - Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 订阅 - $inquiry_type = inquiryTypeToString($this->order_inquiry['inquiry_type']); // 问诊内容-病情主诉 $disease_desc = $order_inquiry_case['disease_desc']; - if (!empty($disease_desc)){ - if (strlen($disease_desc) > 15){ - $disease_desc = mb_substr($disease_desc,0,15); - if ($disease_desc){ + if (!empty($disease_desc)) { + if (strlen($disease_desc) > 15) { + $disease_desc = mb_substr($disease_desc, 0, 15); + if ($disease_desc) { $disease_desc = $disease_desc . "..."; } } } + if ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 3) { + // 专家、公益 + $thing6 = "【" . inquiryTypeToString($this->order_inquiry['inquiry_type']) . "】" . ":24小时内未接诊,平台将自动取消问诊"; + } else { + // 快速、购药 + $thing6 = "【" . inquiryTypeToString($this->order_inquiry['inquiry_type']) . "】" . ":5分钟内未接诊,平台将自动取消问诊"; + } + + $sub_data = array(); $sub_data['push_user_id'] = $this->user['user_id']; $sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc";//咨询提醒 @@ -1122,7 +1130,7 @@ class MessagePush extends BaseService "thing4" => (string)$disease_desc,// 病情描述 - "thing6" => "24小时内未接诊,平台将自动取消问诊",// 提示说明 + "thing6" => $thing6,// 提示说明 "thing5" => "",// 咨询内容 @@ -1147,7 +1155,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入订阅推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入订阅推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -1168,7 +1176,7 @@ class MessagePush extends BaseService $params = array(); $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $order_inquiry_case = OrderInquiryCase::getOne($params); - if (empty($order_inquiry_case)){ + if (empty($order_inquiry_case)) { throw new BusinessException("加入推送队列失败:问诊病例为空"); } @@ -1189,13 +1197,13 @@ class MessagePush extends BaseService $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; $link_params['doctor_user_id'] = $this->user['user_id']; $link_params['patient_user_id'] = $this->order_inquiry['user_id']; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } elseif ($this->push_type == 2) { // 订阅 @@ -1210,7 +1218,7 @@ class MessagePush extends BaseService "name2" => $this->order_inquiry['patient_name'],// 患者姓名 - "thing4" => mb_substr($order_inquiry_case['disease_desc'],0,18),// 病情描述 + "thing4" => mb_substr($order_inquiry_case['disease_desc'], 0, 18),// 病情描述 "thing6" => "24小时内未接诊,平台将自动取消问诊。",// 提示说明 @@ -1238,7 +1246,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } @@ -1264,9 +1272,9 @@ class MessagePush extends BaseService $params = array(); $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $order_inquiry_case = OrderInquiryCase::getOne($params); - if (empty($order_inquiry_case)){ - Log::getInstance("MessagePush")->error("错误:问诊病例为空" ); - return ; + if (empty($order_inquiry_case)) { + Log::getInstance("MessagePush")->error("错误:问诊病例为空"); + return; } // 站内 @@ -1285,13 +1293,13 @@ class MessagePush extends BaseService $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; $link_params['patient_user_id'] = $this->order_inquiry['user_id']; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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) { - Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); @@ -1315,8 +1323,8 @@ class MessagePush extends BaseService $params['pharmacist_audit_status'] = 1; $order_prescription = OrderPrescription::getOne($params); if (empty($order_prescription)) { - Log::getInstance("MessagePush")->error("错误:处方数据为空" ); - return ; + Log::getInstance("MessagePush")->error("错误:处方数据为空"); + return; } // 站内 @@ -1335,13 +1343,13 @@ class MessagePush extends BaseService $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; $link_params['doctor_user_id'] = $this->user['user_id']; $link_params['patient_user_id'] = $this->order_inquiry['user_id']; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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) { - Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 订阅 @@ -1375,10 +1383,10 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { - Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } @@ -1398,8 +1406,8 @@ class MessagePush extends BaseService $params['order_prescription_id'] = $order_prescription_id; $order_prescription = OrderPrescription::getOne($params); if (empty($order_prescription)) { - Log::getInstance("MessagePush")->error("错误:处方数据为空" ); - return ; + Log::getInstance("MessagePush")->error("错误:处方数据为空"); + return; } // 订阅 @@ -1410,7 +1418,7 @@ class MessagePush extends BaseService $sub_data['params']['data'] = [ "phrase1" => "审方不通过",// 审核结果 "thing2" => (string)$order_prescription['pharmacist_fail_reason'],// 原因 - "date3" => date('Y-m-d',time()),// 审核时间 + "date3" => date('Y-m-d', time()),// 审核时间 "thing4" => "建议您提醒患者,稍后重新发起问诊申请开方",// 提示说明 ]; @@ -1433,7 +1441,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . $e->getMessage()); @@ -1466,7 +1474,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -1502,7 +1510,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -1536,7 +1544,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } elseif ($this->push_type == 2) { // 订阅 @@ -1544,7 +1552,7 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { throw new BusinessException("加入推送队列失败:医生数据为空"); } @@ -1581,7 +1589,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -1617,7 +1625,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } elseif ($this->push_type == 2) { // 订阅 @@ -1625,7 +1633,7 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { throw new BusinessException("加入推送队列失败:医生数据为空"); } @@ -1657,7 +1665,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -1681,7 +1689,7 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { throw new BusinessException("加入推送队列失败:医生数据为空"); } @@ -1698,7 +1706,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } elseif ($this->push_type == 2) { // 订阅 @@ -1711,7 +1719,7 @@ class MessagePush extends BaseService "thing2" => "医师简介",// 审核内容 - "time3" => date('Y-m-d H:i:s',time()),// 审核时间 + "time3" => date('Y-m-d H:i:s', time()),// 审核时间 "thing4" => "{$user_doctor['user_name']}医生,您修改的简介信息审核通过,快去通知患者吧。",// 备注 @@ -1735,7 +1743,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -1770,7 +1778,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } elseif ($this->push_type == 2) { // 订阅 @@ -1778,7 +1786,7 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { throw new BusinessException("加入推送队列失败:医生数据为空"); } @@ -1789,7 +1797,7 @@ class MessagePush extends BaseService $sub_data['params']['data'] = [ "thing1" => "{$this->user['user_name']}医生您好,简介信息审核没有通过,请重新提交",// 温馨提示 "thing2" => "未知",// 驳回理由 - "time3" => date('Y-m-d H:i:s',time()),// 审核时间 + "time3" => date('Y-m-d H:i:s', time()),// 审核时间 ]; // 短信 @@ -1810,7 +1818,7 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -1835,20 +1843,20 @@ class MessagePush extends BaseService $params = array(); $params['withdrawal_id'] = $withdrawal_id; $doctor_withdrawal = DoctorWithdrawal::getOne($params); - if (empty($doctor_withdrawal)){ - Log::getInstance("MessagePush")->error("错误:提现数据为空" ); - return ; + if (empty($doctor_withdrawal)) { + Log::getInstance("MessagePush")->error("错误:提现数据为空"); + return; } if ($this->push_type == 1) { // 站内 // 计算时间 - $created_at = date('Y',strtotime($doctor_withdrawal['created_at'])); - $now_year = date('Y',time()); - if ($created_at != $now_year){ - $created_at = date('Y',strtotime($doctor_withdrawal['created_at'])) . '年' . date('m',strtotime($doctor_withdrawal['created_at'])) . "月"; - }else{ - $created_at = date('m',strtotime($doctor_withdrawal['created_at'])) . '月' . date('m',strtotime($doctor_withdrawal['created_at'])) . "日"; + $created_at = date('Y', strtotime($doctor_withdrawal['created_at'])); + $now_year = date('Y', time()); + if ($created_at != $now_year) { + $created_at = date('Y', strtotime($doctor_withdrawal['created_at'])) . '年' . date('m', strtotime($doctor_withdrawal['created_at'])) . "月"; + } else { + $created_at = date('m', strtotime($doctor_withdrawal['created_at'])) . '月' . date('m', strtotime($doctor_withdrawal['created_at'])) . "日"; } $data = array(); @@ -1864,13 +1872,13 @@ class MessagePush extends BaseService $data['button_type'] = 1;// 我的账户 $link_params = array(); - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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) { - Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } elseif ($this->push_type == 3) { // 短信 @@ -1883,14 +1891,14 @@ class MessagePush extends BaseService $template_param = array(); $template_param['name'] = $this->user['user_name']; - $template_param['time'] = date('Y-m-d H:i',strtotime($doctor_withdrawal['created_at'])); + $template_param['time'] = date('Y-m-d H:i', strtotime($doctor_withdrawal['created_at'])); $data['template_param'] = $template_param; $message = new SendSmsMessageProducer($data); $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -1915,19 +1923,19 @@ class MessagePush extends BaseService $params = array(); $params['withdrawal_id'] = $withdrawal_id; $doctor_withdrawal = DoctorWithdrawal::getOne($params); - if (empty($doctor_withdrawal)){ + if (empty($doctor_withdrawal)) { throw new BusinessException("加入推送队列失败:提现数据为空"); } if ($this->push_type == 1) { // 站内 // 计算时间 - $created_at = date('Y',strtotime($doctor_withdrawal['created_at'])); - $now_year = date('Y',time()); - if ($created_at != $now_year){ - $created_at = date('Y',strtotime($doctor_withdrawal['created_at'])) . '年' . date('m',strtotime($doctor_withdrawal['created_at'])) . "月"; - }else{ - $created_at = date('m',strtotime($doctor_withdrawal['created_at'])) . '月' . date('m',strtotime($doctor_withdrawal['created_at'])) . "日"; + $created_at = date('Y', strtotime($doctor_withdrawal['created_at'])); + $now_year = date('Y', time()); + if ($created_at != $now_year) { + $created_at = date('Y', strtotime($doctor_withdrawal['created_at'])) . '年' . date('m', strtotime($doctor_withdrawal['created_at'])) . "月"; + } else { + $created_at = date('m', strtotime($doctor_withdrawal['created_at'])) . '月' . date('m', strtotime($doctor_withdrawal['created_at'])) . "日"; } $data = array(); @@ -1943,13 +1951,13 @@ class MessagePush extends BaseService $data['button_type'] = 2;// 联系客服 $link_params = array(); - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } elseif ($this->push_type == 3) { // 短信 @@ -1962,14 +1970,14 @@ class MessagePush extends BaseService $template_param = array(); $template_param['name'] = $this->user['user_name']; - $template_param['time'] = date('Y-m-d H:i',strtotime($doctor_withdrawal['created_at'])); + $template_param['time'] = date('Y-m-d H:i', strtotime($doctor_withdrawal['created_at'])); $data['template_param'] = $template_param; $message = new SendSmsMessageProducer($data); $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -1988,7 +1996,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) { @@ -2002,13 +2010,13 @@ class MessagePush extends BaseService $data['notice_content'] = "{$this->user['user_name']}医生,{$date}会更新{$function}功能,敬请期待;"; $link_params = array(); - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -2040,13 +2048,13 @@ class MessagePush extends BaseService $data['notice_content'] = "{$this->user['user_name']}医生,平台对【{$title}】协议进行了更新,请注意查收"; $link_params = array(); - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $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)); + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } } catch (\Exception $e) { @@ -2070,16 +2078,16 @@ class MessagePush extends BaseService $params = array(); $params['doctor_id'] = $this->order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ - Log::getInstance("MessagePush")->error("错误:医生数据为空" ); + if (empty($user_doctor)) { + Log::getInstance("MessagePush")->error("错误:医生数据为空"); } // 获取问诊订单关联病例 $params = array(); $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $order_inquiry_case = OrderInquiryCase::getOne($params); - if (empty($order_inquiry_case)){ - Log::getInstance("MessagePush")->error("错误:病例数据为空" ); + if (empty($order_inquiry_case)) { + Log::getInstance("MessagePush")->error("错误:病例数据为空"); return; } @@ -2099,21 +2107,21 @@ class MessagePush extends BaseService $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);// 跳转参数 + $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) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } // 问诊内容-病情主诉 $disease_desc = $order_inquiry_case['disease_desc']; - if (!empty($disease_desc)){ - if (strlen($disease_desc) > 15){ - $disease_desc = mb_substr($disease_desc,0,15); - if ($disease_desc){ + if (!empty($disease_desc)) { + if (strlen($disease_desc) > 15) { + $disease_desc = mb_substr($disease_desc, 0, 15); + if ($disease_desc) { $disease_desc = $disease_desc . "..."; } } @@ -2144,11 +2152,84 @@ class MessagePush extends BaseService $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { - Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } catch (\Exception $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } + /** + * 医生-超时未接诊 + * 站内、订阅 + * @return void + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function doctorNoInquiry(): void + { + try { + // 获取问诊订单关联病例 + $params = array(); + $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)) { + Log::getInstance("MessagePush")->error("错误:病例数据为空"); + return; + } + + // 站内 + $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'] = "因您超时未接诊,因您超时未接诊订单已失效,已退款给患者。"; + $data['notice_title'] = "因您超时未接诊,因您超时未接诊订单已失效,已退款给患者。"; + $data['notice_content'] = "因您超时未接诊,因您超时未接诊订单已失效,已退款给患者。"; + + $message = new SendStationMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); + } + + // 问诊内容-病情主诉 + $disease_desc = $order_inquiry_case['disease_desc']; + if (!empty($disease_desc)) { + if (strlen($disease_desc) > 15) { + $disease_desc = mb_substr($disease_desc, 0, 15); + if ($disease_desc) { + $disease_desc = $disease_desc . "..."; + } + } + } + + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc";//咨询提醒 + $sub_data['params']['page'] = ""; + $sub_data['params']['data'] = [ + "thing1" => "超时未接诊",// 提醒内容 + "name2" => (string)$this->order_inquiry['patient_name'],// 患者姓名 + "thing4" => (string)$disease_desc,// 病情描述 + "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) { + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); + } + } catch (\Exception $e) { + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index b89c71a..94c46be 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -906,6 +906,9 @@ class PatientOrderService extends BaseService $imService = new ImService(); $imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); + // 发送IM消息-横幅通知-医生有新问诊 + $imService->bannerNoticeNewInquiry($order_inquiry,$user_doctor['user_id']); + // 发送站内、订阅失败发送短信消息-医生有新问诊 $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); $MessagePush->doctorHaveNewInquiry();