增加消息推送

This commit is contained in:
wucongxing 2023-04-06 09:19:32 +08:00
parent 2f0266398f
commit f082614631
7 changed files with 266 additions and 299 deletions

View File

@ -120,6 +120,10 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
$params = array(); $params = array();
$params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id']; $params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id'];
UserCoupon::edit($params, $save_data); UserCoupon::edit($params, $save_data);
// 发送站内消息-优惠卷退还
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
$MessagePush->patientRefundCoupon();
} }
} }
@ -163,10 +167,13 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
// 发送IM消息-问诊退款 // 发送IM消息-问诊退款
$imService->inquiryRefund($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); $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 = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
$MessagePush->patientNoInquiry(); $MessagePush->patientNoInquiry();
// 发送站内、订阅、短信消息-问诊服务退款成功
$MessagePush->refundInquirySuccess();
Log::getInstance()->info("取消未接诊问诊订单成功,发送消息成功"); Log::getInstance()->info("取消未接诊问诊订单成功,发送消息成功");
} catch (\Exception $e) { } catch (\Exception $e) {
// 验证失败 // 验证失败

View File

@ -226,7 +226,6 @@ class CallBackController extends AbstractController
return $server->serve(); return $server->serve();
} }
// 验证订单退款状态 // 验证订单退款状态
if ($order_inquiry['inquiry_refund_status'] == 3) { if ($order_inquiry['inquiry_refund_status'] == 3) {
// 问诊订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) // 问诊订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)

View File

@ -963,6 +963,10 @@ class InquiryService extends BaseService
$params = array(); $params = array();
$params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id']; $params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id'];
UserCoupon::edit($params, $data); UserCoupon::edit($params, $data);
// 发送站内消息-优惠卷退还
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
$MessagePush->patientRefundCoupon();
} }
} }

View File

@ -200,94 +200,91 @@ class MessagePush extends BaseService
throw new BusinessException("加入推送队列失败:医生数据为空"); throw new BusinessException("加入推送队列失败:医生数据为空");
} }
if ($this->push_type == 1) { // 站内
// 站内 $data = array();
$data = array(); $data['user_id'] = $this->user['user_id'];
$data['user_id'] = $this->user['user_id']; $data['notice_type'] = 3;
$data['notice_type'] = 3; $data['notice_system_type'] = 1;
$data['notice_system_type'] = 1; $data['from_name'] = "肝胆小秘书";
$data['from_name'] = "肝胆小秘书"; $data['notice_brief_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情";
$data['notice_brief_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情"; $data['notice_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情";
$data['notice_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情"; $data['notice_content'] = "{$user_doctor['user_name']}医生已接诊,请您尽快和医生进行沟通交流病情,您可以点击问诊详情进行交流。";
$data['notice_content'] = "{$user_doctor['user_name']}医生已接诊,请您尽快和医生进行沟通交流病情,您可以点击问诊详情进行交流。"; $data['link_type'] = 1;// 聊天详情页
$data['link_type'] = 1;// 聊天详情页
$link_params = array(); $link_params = array();
$link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
$link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type'];
$link_params['doctor_user_id'] = $user_doctor['user_id']; $link_params['doctor_user_id'] = $user_doctor['user_id'];
$link_params['patient_user_id'] = $this->order_inquiry['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; // 问诊详情 $data['button_type'] = 6; // 问诊详情
$message = new SendStationMessageProducer($data); $message = new SendStationMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { 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) {
// 订阅
$sub_data = array();
$sub_data['push_user_id'] = $this->user['user_id'];
$sub_data['wx_template_id'] = "9v6dZhjg09CttLd3W9nEUV_-eshNc4BYYNy59jglvZE";// 问诊提醒
$sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}";
$sub_data['params']['data'] = [
"thing1" => "问诊内容",// 问诊内容
"thing2" => "提醒内容",// 提醒内容
"name3" => (string)$user_doctor['user_name'],// 问诊医生
"thing4" => "提示说明",// 提示说明
];
$data = array(); // 订阅
$data['sub_data'] = $sub_data; $sub_data = array();
$data['sms_data'] = array(); $sub_data['push_user_id'] = $this->user['user_id'];
$sub_data['wx_template_id'] = "9v6dZhjg09CttLd3W9nEUV_-eshNc4BYYNy59jglvZE";// 问诊提醒
$sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}";
$sub_data['params']['data'] = [
"thing1" => "问诊内容",// 问诊内容
"thing2" => "提醒内容",// 提醒内容
"name3" => (string)$user_doctor['user_name'],// 问诊医生
"thing4" => "提示说明",// 提示说明
];
$message = new SendSubMessageProducer($data); $data = array();
$producer = ApplicationContext::getContainer()->get(Producer::class); $data['sub_data'] = $sub_data;
$result = $producer->produce($message); $data['sms_data'] = array();
if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
}
} elseif ($this->push_type == 3) { $message = new SendSubMessageProducer($data);
// 短信 $producer = ApplicationContext::getContainer()->get(Producer::class);
// 获取系统接诊配置 $result = $producer->produce($message);
$params = array(); if (!$result) {
$params['inquiry_type'] = $this->order_inquiry['inquiry_type']; throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
$params['inquiry_mode'] = $this->order_inquiry['inquiry_mode']; }
$system_inquiry_config = SystemInquiryConfig::getOne($params);
if (empty($system_inquiry_config)) {
throw new BusinessException("加入推送队列失败:获取系统接诊配置失败");
}
$duration = $system_inquiry_config['duration']; // 短信
if ($duration <= 0){ // 获取系统接诊配置
$duration = "不限制"; $params = array();
}else{ $params['inquiry_type'] = $this->order_inquiry['inquiry_type'];
$duration = $duration . "分钟"; $params['inquiry_mode'] = $this->order_inquiry['inquiry_mode'];
} $system_inquiry_config = SystemInquiryConfig::getOne($params);
if (empty($system_inquiry_config)) {
throw new BusinessException("加入推送队列失败:获取系统接诊配置失败");
}
$data = array(); $duration = $system_inquiry_config['duration'];
$data['template_code'] = "SMS_271955088"; if ($duration <= 0){
$data['scene_desc'] = "通知患者医生已接诊"; $duration = "不限制";
$data['phone'] = $this->user['mobile']; }else{
$data['user_id'] = $this->user['user_id']; $duration = $duration . "分钟";
}
$template_param = array(); $data = array();
$template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); $data['template_code'] = "SMS_271955088";
$template_param['name'] = $user_doctor['user_name']; $data['scene_desc'] = "通知患者医生已接诊";
$template_param['duration'] = $duration; // 服务时长 $data['phone'] = $this->user['mobile'];
$data['template_param'] = $template_param; $data['user_id'] = $this->user['user_id'];
$template_param = array();
$template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']);
$template_param['name'] = $user_doctor['user_name'];
$template_param['duration'] = $duration; // 服务时长
$data['template_param'] = $template_param;
$message = new SendSmsMessageProducer($data); $message = new SendSmsMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); throw new BusinessException("加入推送队列失败" . $e->getMessage());
@ -393,58 +390,56 @@ class MessagePush extends BaseService
throw new BusinessException("加入推送队列失败:医生数据为空"); throw new BusinessException("加入推送队列失败:医生数据为空");
} }
if ($this->push_type == 1) { // 站内
// 站内 // 服务消息
// 服务消息 // 获取问诊订单处方数据
// 获取问诊订单处方数据 $params = array();
$params = array(); $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
$params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $order_prescription = OrderPrescription::getOne($params);
$order_prescription = OrderPrescription::getOne($params); if (empty($order_prescription)) {
if (empty($order_prescription)) { throw new BusinessException("加入推送队列失败:处方数据为空");
throw new BusinessException("加入推送队列失败:处方数据为空"); }
}
$data = array(); $data = array();
$data['user_id'] = $this->user['user_id']; $data['user_id'] = $this->user['user_id'];
$data['notice_type'] = 3; $data['notice_type'] = 3;
$data['notice_system_type'] = 1; $data['notice_system_type'] = 1;
$data['from_name'] = "肝胆小秘书"; $data['from_name'] = "肝胆小秘书";
$data['notice_brief_title'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。"; $data['notice_brief_title'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。";
$data['notice_title'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。"; $data['notice_title'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。";
$data['notice_content'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,您可以点击查看处方进行购买药品。"; $data['notice_content'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,您可以点击查看处方进行购买药品。";
$data['link_type'] = 13; $data['link_type'] = 13;
$link_params = array(); $link_params = array();
$link_params['order_prescription_id'] = $order_prescription['order_prescription_id']; $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; // 查看处方 $data['button_type'] = 5; // 查看处方
$message = new SendStationMessageProducer($data); $message = new SendStationMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { 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) {
// 短信
$data = array();
$data['template_code'] = "SMS_271540920";
$data['scene_desc'] = "处方审核通过";
$data['phone'] = $this->user['mobile'];
$data['user_id'] = $this->user['user_id'];
$template_param = array(); // 短信
$template_param['name'] = $user_doctor['user_name']; $data = array();
$data['template_param'] = $template_param; $data['template_code'] = "SMS_271540920";
$data['scene_desc'] = "处方审核通过";
$data['phone'] = $this->user['mobile'];
$data['user_id'] = $this->user['user_id'];
$template_param = array();
$template_param['name'] = $user_doctor['user_name'];
$data['template_param'] = $template_param;
$message = new SendSmsMessageProducer($data); $message = new SendSmsMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); throw new BusinessException("加入推送队列失败" . $e->getMessage());
@ -463,40 +458,21 @@ class MessagePush extends BaseService
public function patientDistributeCoupon(): bool public function patientDistributeCoupon(): bool
{ {
try { try {
// 获取医生数据 $data = array();
$params = array(); $data['user_id'] = $this->user['user_id'];
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $data['notice_type'] = 3;
$user_doctor = UserDoctor::getOne($params); $data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息)
if (empty($user_doctor)){ $data['from_name'] = "肝胆小秘书";
throw new BusinessException("加入推送队列失败:医生数据为空"); $data['notice_brief_title'] = "有新的优惠券已下发至您的账户,点击查看详情。";
} $data['notice_title'] = "【优惠劵名称】已到账";
$data['notice_content'] = "有新的优惠劵已下发至您的账户中,点击查看详情!";
$data['link_type'] = 7;
if ($this->push_type == 1) { $message = new SendStationMessageProducer($data);
// 站内 $producer = ApplicationContext::getContainer()->get(Producer::class);
// 获取问诊订单处方数据 $result = $producer->produce($message);
$params = array(); if (!$result) {
$params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
$order_prescription = OrderPrescription::getOne($params);
if (empty($order_prescription)) {
throw new BusinessException("加入推送队列失败:处方数据为空");
}
$data = array();
$data['user_id'] = $this->user['user_id'];
$data['notice_type'] = 3;
$data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息)
$data['from_name'] = "肝胆小秘书";
$data['notice_brief_title'] = "有新的优惠券已下发至您的账户,点击查看详情。";
$data['notice_title'] = "【优惠劵名称】已到账";
$data['notice_content'] = "有新的优惠劵已下发至您的账户中,点击查看详情!";
$data['link_type'] = 7;
$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));
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); throw new BusinessException("加入推送队列失败" . $e->getMessage());
@ -515,40 +491,21 @@ class MessagePush extends BaseService
public function patientRefundCoupon(): bool public function patientRefundCoupon(): bool
{ {
try { try {
// 获取医生数据 $data = array();
$params = array(); $data['user_id'] = $this->user['user_id'];
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $data['notice_type'] = 3;
$user_doctor = UserDoctor::getOne($params); $data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息)
if (empty($user_doctor)){ $data['from_name'] = "肝胆小秘书";
throw new BusinessException("加入推送队列失败:医生数据为空"); $data['notice_brief_title'] = "您有优惠劵已退还至您的账户,点击查看详情。";
} $data['notice_title'] = "【优惠劵名称】已退还";
$data['notice_content'] = "您有优惠劵已退还至您的账户,请点击查看详情!";
$data['link_type'] = 7;
if ($this->push_type == 1) { $message = new SendStationMessageProducer($data);
// 站内 $producer = ApplicationContext::getContainer()->get(Producer::class);
// 获取问诊订单处方数据 $result = $producer->produce($message);
$params = array(); if (!$result) {
$params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
$order_prescription = OrderPrescription::getOne($params);
if (empty($order_prescription)) {
throw new BusinessException("加入推送队列失败:处方数据为空");
}
$data = array();
$data['user_id'] = $this->user['user_id'];
$data['notice_type'] = 3;
$data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息)
$data['from_name'] = "肝胆小秘书";
$data['notice_brief_title'] = "您有优惠劵已退还至您的账户,点击查看详情。";
$data['notice_title'] = "【优惠劵名称】已退还";
$data['notice_content'] = "您有优惠劵已退还至您的账户,请点击查看详情!";
$data['link_type'] = 7;
$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));
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); throw new BusinessException("加入推送队列失败" . $e->getMessage());
@ -567,40 +524,21 @@ class MessagePush extends BaseService
public function patientExpireCoupon(): bool public function patientExpireCoupon(): bool
{ {
try { try {
// 获取医生数据 $data = array();
$params = array(); $data['user_id'] = $this->user['user_id'];
$params['doctor_id'] = $this->order_inquiry['doctor_id']; $data['notice_type'] = 3;
$user_doctor = UserDoctor::getOne($params); $data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息)
if (empty($user_doctor)){ $data['from_name'] = "肝胆小秘书";
throw new BusinessException("加入推送队列失败:医生数据为空"); $data['notice_brief_title'] = "您有一张优惠劵即将过期,点击查看详情。";
} $data['notice_title'] = "【优惠劵名称】即将过期";
$data['notice_content'] = "您有一张优惠劵即将过期,点击查看详情!";
$data['link_type'] = 7;
if ($this->push_type == 1) { $message = new SendStationMessageProducer($data);
// 站内 $producer = ApplicationContext::getContainer()->get(Producer::class);
// 获取问诊订单处方数据 $result = $producer->produce($message);
$params = array(); if (!$result) {
$params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
$order_prescription = OrderPrescription::getOne($params);
if (empty($order_prescription)) {
throw new BusinessException("加入推送队列失败:处方数据为空");
}
$data = array();
$data['user_id'] = $this->user['user_id'];
$data['notice_type'] = 3;
$data['notice_system_type'] = 2; // 系统消息类型(患者端系统消息存在 1:服务消息 2:福利消息 3:退款消息 4:物流消息)
$data['from_name'] = "肝胆小秘书";
$data['notice_brief_title'] = "您有一张优惠劵即将过期,点击查看详情。";
$data['notice_title'] = "【优惠劵名称】即将过期";
$data['notice_content'] = "您有一张优惠劵即将过期,点击查看详情!";
$data['link_type'] = 7;
$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));
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); throw new BusinessException("加入推送队列失败" . $e->getMessage());
@ -628,90 +566,101 @@ class MessagePush extends BaseService
throw new BusinessException("加入推送队列失败:医生数据为空"); throw new BusinessException("加入推送队列失败:医生数据为空");
} }
if ($this->push_type == 1) { // 站内
// 站内 $inquiry_type_string = inquiryTypeToString($this->order_inquiry['inquiry_type']);
$inquiry_type_string = inquiryTypeToString($this->order_inquiry['inquiry_type']);
$data = array(); $data = array();
$data['user_id'] = $this->user['user_id']; $data['user_id'] = $this->user['user_id'];
$data['notice_type'] = 3; $data['notice_type'] = 3;
$data['notice_system_type'] = 3; $data['notice_system_type'] = 3;
$data['from_name'] = "肝胆小秘书"; $data['from_name'] = "肝胆小秘书";
if ($type == 1){ if ($type == 1){
// 已支付未接诊 // 已支付未接诊
$data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。";
$data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功";
$data['notice_content'] = "因医生繁忙未及时接诊平台会在24小时内给您退款至原账户中带来的不便敬请谅解。"; $data['notice_content'] = "因医生繁忙未及时接诊平台会在24小时内给您退款至原账户中带来的不便敬请谅解。";
}elseif ($type == 2){ }elseif ($type == 2){
// 已支付未成功分配医生 // 已支付未成功分配医生
$data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。";
$data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功";
$data['notice_content'] = "当前服务排队人较多暂无空闲医生为您接诊平台会在24小时内给您退款至原账户中带来的不便敬请谅解。"; $data['notice_content'] = "当前服务排队人较多暂无空闲医生为您接诊平台会在24小时内给您退款至原账户中带来的不便敬请谅解。";
}elseif ($type == 2){ }elseif ($type == 3){
// 已支付未接诊患者取消订单 // 已支付未接诊患者取消订单
$data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。";
$data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功";
$data['notice_content'] = "您已取消成功当前服务平台会在24小时内给您退还至原账户中带来的不便敬请谅解。"; $data['notice_content'] = "您已取消成功当前服务平台会在24小时内给您退还至原账户中带来的不便敬请谅解。";
}else{ }else{
throw new BusinessException("加入推送队列失败:类型错误"); throw new BusinessException("加入推送队列失败:类型错误");
} }
$data['link_type'] = 10;// 问诊订单详情 $data['link_type'] = 10;// 问诊订单详情
$link_params = array(); $link_params = array();
$link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; $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); $message = new SendStationMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { 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) {
// 订阅
$sub_data = array();
$sub_data['push_user_id'] = $this->user['user_id'];
$sub_data['wx_template_id'] = "UOMww1S30Oq7rErJrqO8wN6lNEVKRo2fgcXnb0tBwHI"; //问诊异常通知
$sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}";
$sub_data['params']['data'] = [
"character_string1" => $this->order_inquiry['inquiry_no'],// 订单ID
"name2" => (string)$user_doctor['user_name'],// 问诊医生
"date3" => $this->order_inquiry['created_at'],// 问诊时间
"thing4" => "医生未接诊退款",// 取消原因
"thing5" => "点击详情查看",// 提示说明
];
$data = array(); // 订阅
$data['sub_data'] = $sub_data; if ($type == 1){
$data['sms_data'] = array(); // 已支付未接诊
$thing4 = "医生未接诊";
}elseif ($type == 2){
// 已支付未成功分配医生
$thing4 = "未分配到合适的医生";
}elseif ($type == 3){
// 已支付未接诊患者取消订单
$thing4 = "用户主动取消";
}else{
throw new BusinessException("加入推送队列失败:类型错误");
}
$message = new SendSubMessageProducer($data); $sub_data = array();
$producer = ApplicationContext::getContainer()->get(Producer::class); $sub_data['push_user_id'] = $this->user['user_id'];
$result = $producer->produce($message); $sub_data['wx_template_id'] = "UOMww1S30Oq7rErJrqO8wN6lNEVKRo2fgcXnb0tBwHI"; //问诊异常通知
if (!$result) { $sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}";
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); $sub_data['params']['data'] = [
} "character_string1" => $this->order_inquiry['inquiry_no'],// 订单ID
} elseif ($this->push_type == 3) { "name2" => (string)$user_doctor['user_name'],// 问诊医生
// 短信 "date3" => $this->order_inquiry['created_at'],// 问诊时间
// 获取系统接诊配置 "thing4" => $thing4,// 取消原因
$data = array(); "thing5" => "已进行退款处理,请注意查看账户信息。",// 提示说明
$data['template_code'] = "SMS_272180110"; ];
$data['scene_desc'] = "患者问诊退款";
$data['phone'] = $this->user['mobile'];
$data['user_id'] = $this->user['user_id'];
$template_param = array(); $data = array();
$template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); $data['sub_data'] = $sub_data;
$data['template_param'] = $template_param; $data['sms_data'] = array();
$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));
}
// 短信
// 获取系统接诊配置
$data = array();
$data['template_code'] = "SMS_272180110";
$data['scene_desc'] = "患者问诊退款";
$data['phone'] = $this->user['mobile'];
$data['user_id'] = $this->user['user_id'];
$template_param = array();
$template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']);
$data['template_param'] = $template_param;
$message = new SendSmsMessageProducer($data); $message = new SendSmsMessageProducer($data);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message); $result = $producer->produce($message);
if (!$result) { if (!$result) {
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
throw new BusinessException("加入推送队列失败" . $e->getMessage()); throw new BusinessException("加入推送队列失败" . $e->getMessage());

View File

@ -1622,6 +1622,10 @@ class UserDoctorService extends BaseService
$imService = new ImService(); $imService = new ImService();
$imService->doctorInquiry($order_inquiry,$user_info['user_id'],$order_inquiry['user_id']); $imService->doctorInquiry($order_inquiry,$user_info['user_id'],$order_inquiry['user_id']);
// 发送站内、订阅、短信消息-医生已接诊
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
$MessagePush->patientAcceptedInquiry();
Db::commit(); Db::commit();
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollBack(); Db::rollBack();

View File

@ -235,6 +235,10 @@ class UserPharmacistService extends BaseService
$imService = new ImService(); $imService = new ImService();
$imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],"7"); $imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],"7");
// 发送站内、短信消息-患者的处方被药师审核通过
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
$MessagePush->patientPrescriptionVerifyPass();
Db::commit(); Db::commit();
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollBack(); Db::rollBack();

View File

@ -81,7 +81,7 @@ class Dysms
// query params // query params
$queries = []; $queries = [];
$queries["PhoneNumbers"] = $phone_numbers; $queries["PhoneNumbers"] = "17600901561";
$queries["SignName"] = "肝胆相照"; $queries["SignName"] = "肝胆相照";
$queries["TemplateCode"] = $template_code; $queries["TemplateCode"] = $template_code;
$queries["TemplateParam"] = json_encode($template_param,JSON_UNESCAPED_UNICODE); $queries["TemplateParam"] = json_encode($template_param,JSON_UNESCAPED_UNICODE);