新增了消息推送策略模式发送
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\Order;
|
||||
use App\Model\User;
|
||||
|
||||
class MessagePushService extends BaseService
|
||||
{
|
||||
private MessagePushServicePackageService|MessagePushInquiryService $strategy;
|
||||
|
||||
/**
|
||||
* @param string $to_user_id 用户id(存在被推送者时存在,否则为空)
|
||||
* @param string $order_no 问诊订单系统订单编号
|
||||
*/
|
||||
public function __construct(string $to_user_id, string $order_no){
|
||||
$params = array();
|
||||
$params['user_id'] = $to_user_id;
|
||||
$user = User::getOne($params);
|
||||
if (empty($user)){
|
||||
throw new BusinessException("用户数据错误");
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_no;
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)){
|
||||
throw new BusinessException("订单数据错误");
|
||||
}
|
||||
|
||||
if ($order['order_type'] == 4 || $order['order_type'] == 5){
|
||||
$this->strategy = new MessagePushServicePackageService();
|
||||
}else{
|
||||
$this->strategy = new MessagePushInquiryService();
|
||||
}
|
||||
|
||||
$this->strategy->order = $order->toArray();
|
||||
$this->strategy->user = $user->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者-通知患者医生已接诊
|
||||
* @return void
|
||||
*/
|
||||
public function patientDoctorAcceptedInquiry(): void
|
||||
{
|
||||
$this->strategy->patientDoctorAcceptedInquiry();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user