Files
hospital-applets-api/app/Services/MessagePushService.php
T

58 lines
1.6 KiB
PHP

<?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($order_no);
}else{
$this->strategy = new MessagePushInquiryService();
}
$this->strategy->order = $order->toArray();
$this->strategy->user = $user->toArray();
}
/**
* 患者-通知患者医生已接诊
* @return void
*/
public function patientDoctorAcceptedInquiry(): void
{
$this->strategy->patientDoctorAcceptedInquiry();
}
// 医生-服务包待接诊
// 仅限于患者购买服务包后,首次发起问诊后使用
public function doctorWaitInquiry(): void
{
$this->strategy->doctorWaitInquiry();
}
}