新增im消息回调时推送订阅消息
This commit is contained in:
@@ -2416,4 +2416,121 @@ class MessagePush extends BaseService
|
||||
throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者-im消息通知
|
||||
* 订阅
|
||||
* @param string $data 消息内容
|
||||
* @return void
|
||||
*/
|
||||
public function patientImMessageNotice(string $msg): void
|
||||
{
|
||||
try {
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $this->order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance("MessagePush")->error("错误:医生数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// im内容
|
||||
if (strlen($msg) > 15) {
|
||||
$msg = mb_substr($msg, 0, 15);
|
||||
if ($msg) {
|
||||
$msg = $msg . "...";
|
||||
}
|
||||
}
|
||||
|
||||
// 订阅
|
||||
$sub_data = array();
|
||||
$sub_data['push_user_id'] = $this->user['user_id'];
|
||||
$sub_data['wx_template_id'] = "9v6dZhjg09CttLd3W9nEUV_-eshNc4BYYNy59jglvZE";// 问诊提醒
|
||||
$sub_data['params']['page'] = "pages/message/message";
|
||||
$sub_data['params']['data'] = [
|
||||
"thing1" => (string)"医生回复了您的消息,点击查看详情",// 问诊内容
|
||||
"thing2" => (string)$msg,// 提醒内容
|
||||
"name3" => (string)$user_doctor['user_name'],// 问诊医生
|
||||
"thing4" => "如有困扰,前往个人中心的设置中关闭",// 提示说明
|
||||
];
|
||||
|
||||
$data = array();
|
||||
$data['sub_data'] = $sub_data;
|
||||
$data['sms_data'] = array();;
|
||||
|
||||
$message = new SendSubMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePush-patientImMessageNotice")->error(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::getInstance("MessagePush-patientImMessageNotice")->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 医生-im消息通知
|
||||
* 订阅
|
||||
* @param string $im_data
|
||||
* @return void
|
||||
*/
|
||||
public function doctorImMessageNotice(string $msg): 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;
|
||||
}
|
||||
|
||||
// im内容
|
||||
if (strlen($msg) > 15) {
|
||||
$msg = mb_substr($msg, 0, 15);
|
||||
if ($msg) {
|
||||
$msg = $msg . "...";
|
||||
}
|
||||
}
|
||||
|
||||
// 问诊内容-病情主诉
|
||||
$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'] = "Pages/yishi/wenzhen_v2/wenzhen";
|
||||
$sub_data['params']['data'] = [
|
||||
"thing1" => $msg,// 提醒内容
|
||||
"name2" => (string)$this->order_inquiry['patient_name'],// 患者姓名
|
||||
"thing4" => (string)$disease_desc,// 病情描述
|
||||
"thing6" => "患者发来了最新消息,点击查看详情",// 提示说明
|
||||
];
|
||||
|
||||
$data = array();
|
||||
$data['sub_data'] = $sub_data;
|
||||
$data['sms_data'] = array();;
|
||||
|
||||
$message = new SendSubMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePush-patientImMessageNotice")->error(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::getInstance("MessagePush-patientImMessageNotice")->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user