order_service_package = $order_service_package->toArray(); $params = array(); } /** * 患者-通知患者医生已接诊 * @return void */ public function patientDoctorAcceptedInquiry(): void { try { // 获取问诊订单数据 $params = array(); $params['inquiry_no'] = $this->order['order_no']; $order_inquiry = OrderInquiry::getOne($params); if (empty($order_inquiry)){ Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error("问诊订单数据为空"); return; } // 获取医生数据 $params = array(); $params['doctor_id'] = $this->order['doctor_id']; $user_doctor = UserDoctor::getOne($params); if (empty($user_doctor)) { Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error("医生数据为空"); return; } // 站内 // 获取服务包订单详情 $params = array(); $params['order_service_no'] = $this->order['order_no']; $order_service_package_detail = OrderServicePackageDetail::getOne($params); if (empty($order_service_package_detail)){ Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error("服务包订单数据为空"); return; } // 转换服务包订单类型为汉字 $order_type = orderServiceTypeToString($this->order_service_package['order_service_type']); // 转换每月次数为汉字 $monthly_frequency = monthlyFrequencyToString($order_service_package_detail['monthly_frequency']); $start_time = date('Y年m月d日 H时i分',strtotime($this->order_service_package['start_time'])); $finish_time = date('Y年m月d日 H时i分',strtotime($this->order_service_package['finish_time'])); // 站内 $data = array(); $data['user_id'] = $this->user['user_id']; $data['notice_type'] = 3; $data['notice_system_type'] = 1; $data['from_name'] = "肝胆小秘书"; $data['notice_brief_title'] = "您购买的{$order_type},医生已接诊,点击查看详情。"; $data['notice_title'] = "您购买的{$order_type},{$user_doctor['user_name']}医生已接诊,每次问诊不限制沟通回合数,您可以点击【问诊详情】进行交流。"; $data['notice_content'] = "您购买的{$order_type},{$user_doctor['user_name']}医生已接诊,每次问诊不限制沟通回合数,您可以点击【问诊详情】进行交流。"; $data['link_type'] = 1;// 聊天详情页 $link_params = array(); $link_params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $link_params['inquiry_type'] = $order_inquiry['inquiry_type']; $link_params['doctor_user_id'] = $user_doctor['user_id']; $link_params['patient_user_id'] = $order_inquiry['user_id']; $data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数 $data['button_type'] = 6; // 问诊详情 $message = new SendStationMessageProducer($data); $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error(json_encode($data, JSON_UNESCAPED_UNICODE)); } // 订阅 $sub_data = array(); $sub_data['push_user_id'] = $this->user['user_id']; $sub_data['wx_template_id'] = "9v6dZhjg09CttLd3W9nEUV_-eshNc4BYYNy59jglvZE";// 问诊提醒 $sub_data['params']['page'] = "patient/pages/orderDetail/orderDetail?order_inquiry_id={$order_inquiry['order_inquiry_id']}"; $sub_data['params']['data'] = [ "thing1" => $order_type . "服务", "thing2" => "医生已接诊",// 提醒内容 "name3" => (string)$user_doctor['user_name'],// 问诊医生 "thing4" => "点击查看详情",// 提示说明 ]; $subscription_data = array(); $subscription_data['sub_data'] = $sub_data; $subscription_data['sms_data'] = array(); $message = new SendSubMessageProducer($subscription_data); $producer = ApplicationContext::getContainer()->get(Producer::class); $result = $producer->produce($message); if (!$result) { Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error(json_encode($subscription_data, JSON_UNESCAPED_UNICODE)); } // 短信 }catch (\Throwable $e){ Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error($e->getMessage()); } } // 医生-服务包待接诊 // 仅限于患者购买服务包后,首次发起问诊后使用 public function doctorWaitInquiry() { try { // 获取医生数据 $params = array(); $params['doctor_id'] = $this->order['doctor_id']; $user_doctor = UserDoctor::getOne($params); if (empty($user_doctor)) { Log::getInstance("MessagePushServicePackageService-doctorWaitInquiry")->error("医生数据为空"); return; } // 站内 $data = array(); $data['user_id'] = $this->user['user_id']; $data['notice_type'] = 1; $data['inquiry_type'] = 1; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) $data['from_name'] = "肝胆小秘书"; $data['notice_brief_title'] = "您有新的问诊咨询,请及时处理。"; $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) { Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } }catch (\Throwable $e){ Log::getInstance("MessagePushServicePackageService-doctorWaitInquiry")->error($e->getMessage()); } } }