新增消息推送,新增处方平台查询处方状态
This commit is contained in:
@@ -27,9 +27,6 @@ use Psr\Container\NotFoundExceptionInterface;
|
||||
*/
|
||||
class MessagePush extends BaseService
|
||||
{
|
||||
// 推送类型 1:站内 2:订阅 3:短信
|
||||
public int $push_type;
|
||||
|
||||
// 用户数据(存在被推送者时存在,否则为空)
|
||||
public array $user = [];
|
||||
|
||||
@@ -37,17 +34,11 @@ class MessagePush extends BaseService
|
||||
public array $order_inquiry = [];
|
||||
|
||||
/**
|
||||
* @param int $push_type 推送类型 1:站内 2:订阅 3:短信
|
||||
* @param string $to_user_id 用户id(存在被推送者时存在,否则为空)
|
||||
* @param string $order_inquiry_id 问诊订单id
|
||||
*/
|
||||
public function __construct(int $push_type, string $to_user_id = "", string $order_inquiry_id = "")
|
||||
public function __construct(string $to_user_id = "", string $order_inquiry_id = "")
|
||||
{
|
||||
if (!in_array($push_type, [1, 2, 3])) {
|
||||
throw new BusinessException("推送类型错误:" . $push_type);
|
||||
}
|
||||
$this->push_type = $push_type;
|
||||
|
||||
if (!empty($to_user_id)) {
|
||||
$params = array();
|
||||
$params['user_id'] = $to_user_id;
|
||||
@@ -79,74 +70,71 @@ class MessagePush extends BaseService
|
||||
public function patientNoInquiry(): bool
|
||||
{
|
||||
try {
|
||||
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'] = "肝胆小秘书";
|
||||
if ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 3) {
|
||||
// 专家-公益
|
||||
$data['notice_brief_title'] = "您咨询的服务暂无医生接诊,点击查看详情。";
|
||||
$data['notice_title'] = "您咨询的服务暂无医生接诊,点击查看详情。";
|
||||
$data['notice_content'] = "您咨询的服务当前排队人较多,暂无空闲医生接诊。给您带来不便敬请谅解,平台会在24小时内进行退款,您可以点击订单详情查看退款详情。";
|
||||
// 站内
|
||||
// 服务消息
|
||||
$data = array();
|
||||
$data['user_id'] = $this->user['user_id'];
|
||||
$data['notice_type'] = 3;
|
||||
$data['notice_system_type'] = 1;
|
||||
$data['from_name'] = "肝胆小秘书";
|
||||
if ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 3) {
|
||||
// 专家-公益
|
||||
$data['notice_brief_title'] = "您咨询的服务暂无医生接诊,点击查看详情。";
|
||||
$data['notice_title'] = "您咨询的服务暂无医生接诊,点击查看详情。";
|
||||
$data['notice_content'] = "您咨询的服务当前排队人较多,暂无空闲医生接诊。给您带来不便敬请谅解,平台会在24小时内进行退款,您可以点击订单详情查看退款详情。";
|
||||
|
||||
} elseif ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 4) {
|
||||
// 快速-购药
|
||||
$data['notice_brief_title'] = "您咨询的医生因工作繁忙没有时间接诊,点击查看详情。";
|
||||
$data['notice_title'] = "您咨询的医生因工作繁忙没有时间接诊,点击查看详情。";
|
||||
$data['notice_content'] = "您咨询的医生因工作繁忙,暂无空闲时间接诊。给您带来不便敬请谅解,平台会在24小时内进行退款,您可以点击订单详情查看退款详情。";
|
||||
}
|
||||
} elseif ($this->order_inquiry['inquiry_type'] == 1 || $this->order_inquiry['inquiry_type'] == 4) {
|
||||
// 快速-购药
|
||||
$data['notice_brief_title'] = "您咨询的医生因工作繁忙没有时间接诊,点击查看详情。";
|
||||
$data['notice_title'] = "您咨询的医生因工作繁忙没有时间接诊,点击查看详情。";
|
||||
$data['notice_content'] = "您咨询的医生因工作繁忙,暂无空闲时间接诊。给您带来不便敬请谅解,平台会在24小时内进行退款,您可以点击订单详情查看退款详情。";
|
||||
}
|
||||
|
||||
$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);// 跳转参数
|
||||
|
||||
$data['button_type'] = 4; // 订单详情
|
||||
$data['button_type'] = 4; // 订单详情
|
||||
|
||||
$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) {
|
||||
// 订阅
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $this->order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
throw new BusinessException("加入推送队列失败:医生数据为空");
|
||||
}
|
||||
$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));
|
||||
}
|
||||
|
||||
$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" => inquiryCancelReasonToString($this->order_inquiry['cancel_reason']),// 取消原因
|
||||
"thing5" => "点击详情更换医生问诊",// 提示说明
|
||||
];
|
||||
// 订阅
|
||||
// 获取医生数据
|
||||
$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['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'] = "UOMww1S30Oq7rErJrqO8wN6lNEVKRo2fgcXnb0tBwHI";//问诊异常通知
|
||||
$sub_data['params']['page'] = "pages/orderDetail/orderDetail?order_inquiry_id={$this->order_inquiry['order_inquiry_id']}";
|
||||
$sub_data['params']['data'] = [
|
||||
"character_string1" => (string)$this->order_inquiry['inquiry_no'],// 订单ID
|
||||
"name2" => (string)$user_doctor['user_name'],// 问诊医生
|
||||
"date3" => $this->order_inquiry['created_at'],// 问诊时间
|
||||
"thing4" => inquiryCancelReasonToString($this->order_inquiry['cancel_reason']),// 取消原因
|
||||
"thing5" => "点击详情更换医生问诊",// 提示说明
|
||||
];
|
||||
|
||||
$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();
|
||||
|
||||
$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));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new BusinessException("加入推送队列失败" . $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user