hospital-applets-api/app/Services/SendSmsService.php

72 lines
2.3 KiB
PHP

<?php
namespace App\Services;
// 短信发送
use App\Amqp\Producer\SendSmsMessageProducer;
use App\Constants\HttpEnumCode;
use App\Exception\BusinessException;
use App\Utils\Log;
use Extend\Alibaba\Dysms;
use Hyperf\Amqp\Producer;
use Hyperf\Context\ApplicationContext;
class SendSmsService extends BaseService
{
public string $mobile;
public function __construct(string|int $mobile)
{
if (!empty($mobile)){
$this->mobile = $mobile;
}
}
// 患者-通知患者视频时间
public function noticePatientVideoTime(string $doctor_name,$reservation_time){
try {
// 发送短信-患者-视频预约成功
$template_code = "SMS_464481352";
$scene_desc = "通知患者视频时间";
$template_param = array();
$template_param['name'] = $doctor_name;
$template_param['time'] = date('Y-m-d H:i', strtotime($reservation_time));
Dysms::sendSms($this->mobile,$template_param,$template_code,$scene_desc);
}catch (\Throwable $e){
throw new BusinessException("短信发送失败",HttpEnumCode::CODE_FAIL);
}
}
// 患者-通知患者视频
public function noticePatientVideo(string $doctor_name){
try {
// 发送短信-患者-视频预约成功
$template_code = "SMS_464436348";
$scene_desc = "通知患者视频";
$template_param = array();
$template_param['name'] = $doctor_name;
Dysms::sendSms($this->mobile,$template_param,$template_code,$scene_desc);
}catch (\Throwable $e){
throw new BusinessException("短信发送失败",HttpEnumCode::CODE_FAIL);
}
}
// 医生-通知医生视频
public function noticeDoctorVideo(string $patient_name){
try {
// 发送短信-患者-视频预约成功
$template_code = "SMS_464486306";
$scene_desc = "通知医生视频";
$template_param = array();
$template_param['name'] = $patient_name;
Dysms::sendSms($this->mobile,$template_param,$template_code,$scene_desc);
}catch (\Throwable $e){
throw new BusinessException("短信发送失败",HttpEnumCode::CODE_FAIL);
}
}
}