diff --git a/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php b/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php index 0614619..b77afa5 100644 --- a/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php +++ b/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php @@ -120,6 +120,10 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage $params = array(); $params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id']; 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消息-问诊退款 $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->refundInquirySuccess(); + Log::getInstance()->info("取消未接诊问诊订单成功,发送消息成功"); } catch (\Exception $e) { // 验证失败 diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index e67afcd..71111c9 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -226,7 +226,6 @@ class CallBackController extends AbstractController return $server->serve(); } - // 验证订单退款状态 if ($order_inquiry['inquiry_refund_status'] == 3) { // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index e5eddd9..9268865 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -963,6 +963,10 @@ class InquiryService extends BaseService $params = array(); $params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id']; UserCoupon::edit($params, $data); + + // 发送站内消息-优惠卷退还 + $MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush->patientRefundCoupon(); } } diff --git a/app/Services/MessagePush.php b/app/Services/MessagePush.php index fb1a734..1629ade 100644 --- a/app/Services/MessagePush.php +++ b/app/Services/MessagePush.php @@ -200,94 +200,91 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败:医生数据为空"); } - if ($this->push_type == 1) { - // 站内 - $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'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情"; - $data['notice_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情"; - $data['notice_content'] = "{$user_doctor['user_name']}医生已接诊,请您尽快和医生进行沟通交流病情,您可以点击问诊详情进行交流。"; - $data['link_type'] = 1;// 聊天详情页 + // 站内 + $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'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情"; + $data['notice_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情"; + $data['notice_content'] = "{$user_doctor['user_name']}医生已接诊,请您尽快和医生进行沟通交流病情,您可以点击问诊详情进行交流。"; + $data['link_type'] = 1;// 聊天详情页 - $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);// 跳转参数 + $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);// 跳转参数 - $data['button_type'] = 6; // 问诊详情 + $data['button_type'] = 6; // 问诊详情 - $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)); - } - } 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" => "提示说明",// 提示说明 - ]; + $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)); + } - $data = array(); - $data['sub_data'] = $sub_data; - $data['sms_data'] = array(); + // 订阅 + $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" => "提示说明",// 提示说明 + ]; - $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['sub_data'] = $sub_data; + $data['sms_data'] = array(); - } elseif ($this->push_type == 3) { - // 短信 - // 获取系统接诊配置 - $params = array(); - $params['inquiry_type'] = $this->order_inquiry['inquiry_type']; - $params['inquiry_mode'] = $this->order_inquiry['inquiry_mode']; - $system_inquiry_config = SystemInquiryConfig::getOne($params); - if (empty($system_inquiry_config)) { - throw new BusinessException("加入推送队列失败:获取系统接诊配置失败"); - } + $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)); + } - $duration = $system_inquiry_config['duration']; - if ($duration <= 0){ - $duration = "不限制"; - }else{ - $duration = $duration . "分钟"; - } + // 短信 + // 获取系统接诊配置 + $params = array(); + $params['inquiry_type'] = $this->order_inquiry['inquiry_type']; + $params['inquiry_mode'] = $this->order_inquiry['inquiry_mode']; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (empty($system_inquiry_config)) { + throw new BusinessException("加入推送队列失败:获取系统接诊配置失败"); + } - $data = array(); - $data['template_code'] = "SMS_271955088"; - $data['scene_desc'] = "通知患者医生已接诊"; - $data['phone'] = $this->user['mobile']; - $data['user_id'] = $this->user['user_id']; + $duration = $system_inquiry_config['duration']; + if ($duration <= 0){ + $duration = "不限制"; + }else{ + $duration = $duration . "分钟"; + } - $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; + $data = array(); + $data['template_code'] = "SMS_271955088"; + $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']); + $template_param['name'] = $user_doctor['user_name']; + $template_param['duration'] = $duration; // 服务时长 + $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)); - } + $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)); } } catch (\Exception $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); @@ -393,58 +390,56 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败:医生数据为空"); } - if ($this->push_type == 1) { - // 站内 - // 服务消息 - // 获取问诊订单处方数据 - $params = array(); - $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; - $order_prescription = OrderPrescription::getOne($params); - if (empty($order_prescription)) { - throw new BusinessException("加入推送队列失败:处方数据为空"); - } + // 站内 + // 服务消息 + // 获取问诊订单处方数据 + $params = array(); + $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; + $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'] = 1; - $data['from_name'] = "肝胆小秘书"; - $data['notice_brief_title'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。"; - $data['notice_title'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。"; - $data['notice_content'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,您可以点击查看处方进行购买药品。"; - $data['link_type'] = 13; + $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'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。"; + $data['notice_title'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,点击查看详情。"; + $data['notice_content'] = "{$user_doctor['user_name']}医生为您开具的电子处方已审核通过,您可以点击查看处方进行购买药品。"; + $data['link_type'] = 13; - $link_params = array(); - $link_params['order_prescription_id'] = $order_prescription['order_prescription_id']; - $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 + $link_params = array(); + $link_params['order_prescription_id'] = $order_prescription['order_prescription_id']; + $data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数 - $data['button_type'] = 5; // 查看处方 + $data['button_type'] = 5; // 查看处方 - $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)); - } - } 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']; + $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)); + } - $template_param = array(); - $template_param['name'] = $user_doctor['user_name']; - $data['template_param'] = $template_param; + // 短信 + $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['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)); - } + $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)); } } catch (\Exception $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); @@ -463,40 +458,21 @@ class MessagePush extends BaseService public function patientDistributeCoupon(): 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'] = 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; - if ($this->push_type == 1) { - // 站内 - // 获取问诊订单处方数据 - $params = array(); - $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; - $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)); - } + $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) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); @@ -515,40 +491,21 @@ class MessagePush extends BaseService public function patientRefundCoupon(): 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'] = 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; - if ($this->push_type == 1) { - // 站内 - // 获取问诊订单处方数据 - $params = array(); - $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; - $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)); - } + $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) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); @@ -567,40 +524,21 @@ class MessagePush extends BaseService public function patientExpireCoupon(): 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'] = 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; - if ($this->push_type == 1) { - // 站内 - // 获取问诊订单处方数据 - $params = array(); - $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; - $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)); - } + $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) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); @@ -628,90 +566,101 @@ class MessagePush extends BaseService 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['user_id'] = $this->user['user_id']; - $data['notice_type'] = 3; - $data['notice_system_type'] = 3; - $data['from_name'] = "肝胆小秘书"; - if ($type == 1){ - // 已支付未接诊 - $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; - $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; - $data['notice_content'] = "因医生繁忙未及时接诊,平台会在24小时内给您退款至原账户中,带来的不便敬请谅解。"; - }elseif ($type == 2){ - // 已支付未成功分配医生 - $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; - $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; - $data['notice_content'] = "当前服务排队人较多,暂无空闲医生为您接诊,平台会在24小时内给您退款至原账户中,带来的不便敬请谅解。"; - }elseif ($type == 2){ - // 已支付未接诊患者取消订单 - $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; - $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; - $data['notice_content'] = "您已取消成功当前服务,平台会在24小时内给您退还至原账户中,带来的不便敬请谅解。"; - }else{ - throw new BusinessException("加入推送队列失败:类型错误"); - } + $data = array(); + $data['user_id'] = $this->user['user_id']; + $data['notice_type'] = 3; + $data['notice_system_type'] = 3; + $data['from_name'] = "肝胆小秘书"; + if ($type == 1){ + // 已支付未接诊 + $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; + $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; + $data['notice_content'] = "因医生繁忙未及时接诊,平台会在24小时内给您退款至原账户中,带来的不便敬请谅解。"; + }elseif ($type == 2){ + // 已支付未成功分配医生 + $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; + $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; + $data['notice_content'] = "当前服务排队人较多,暂无空闲医生为您接诊,平台会在24小时内给您退款至原账户中,带来的不便敬请谅解。"; + }elseif ($type == 3){ + // 已支付未接诊患者取消订单 + $data['notice_brief_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功,点击查看详情。"; + $data['notice_title'] = "您咨询的【{$inquiry_type_string}】服务,平台 已退款成功"; + $data['notice_content'] = "您已取消成功当前服务,平台会在24小时内给您退还至原账户中,带来的不便敬请谅解。"; + }else{ + throw new BusinessException("加入推送队列失败:类型错误"); + } - $data['link_type'] = 10;// 问诊订单详情 + $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);// 跳转参数 + $link_params = array(); + $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_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)); - } - } 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" => "点击详情查看",// 提示说明 - ]; + $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)); + } - $data = array(); - $data['sub_data'] = $sub_data; - $data['sms_data'] = array(); + // 订阅 + if ($type == 1){ + // 已支付未接诊 + $thing4 = "医生未接诊"; + }elseif ($type == 2){ + // 已支付未成功分配医生 + $thing4 = "未分配到合适的医生"; + }elseif ($type == 3){ + // 已支付未接诊患者取消订单 + $thing4 = "用户主动取消"; + }else{ + throw new BusinessException("加入推送队列失败:类型错误"); + } - $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)); - } - } elseif ($this->push_type == 3) { - // 短信 - // 获取系统接诊配置 - $data = array(); - $data['template_code'] = "SMS_272180110"; - $data['scene_desc'] = "患者问诊退款"; - $data['phone'] = $this->user['mobile']; - $data['user_id'] = $this->user['user_id']; + $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" => $thing4,// 取消原因 + "thing5" => "已进行退款处理,请注意查看账户信息。",// 提示说明 + ]; - $template_param = array(); - $template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); - $data['template_param'] = $template_param; + $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) { + 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); - $producer = ApplicationContext::getContainer()->get(Producer::class); - $result = $producer->produce($message); - if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE)); - } + $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)); } } catch (\Exception $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 87e0a96..6c53414 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -1622,6 +1622,10 @@ class UserDoctorService extends BaseService $imService = new ImService(); $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(); } catch (\Exception $e) { Db::rollBack(); diff --git a/app/Services/UserPharmacistService.php b/app/Services/UserPharmacistService.php index 658e5c6..dab1f47 100644 --- a/app/Services/UserPharmacistService.php +++ b/app/Services/UserPharmacistService.php @@ -235,6 +235,10 @@ class UserPharmacistService extends BaseService $imService = new ImService(); $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(); } catch (\Exception $e) { Db::rollBack(); diff --git a/extend/Alibaba/Dysms.php b/extend/Alibaba/Dysms.php index 29cd577..6591627 100644 --- a/extend/Alibaba/Dysms.php +++ b/extend/Alibaba/Dysms.php @@ -81,7 +81,7 @@ class Dysms // query params $queries = []; - $queries["PhoneNumbers"] = $phone_numbers; + $queries["PhoneNumbers"] = "17600901561"; $queries["SignName"] = "肝胆相照"; $queries["TemplateCode"] = $template_code; $queries["TemplateParam"] = json_encode($template_param,JSON_UNESCAPED_UNICODE);