61 lines
2.0 KiB
PHP
61 lines
2.0 KiB
PHP
<?php
|
|
/*
|
|
* @author: liudiao
|
|
* @Date: 2023-07-31 16:36:28
|
|
* @Description: 处方审被拒绝通知医生
|
|
*/
|
|
namespace common\jobs\Sms;
|
|
|
|
use common\enums\PrescriptionEnum;
|
|
use common\jobs\BaseJob;
|
|
use common\models\Prescription;
|
|
use common\models\PrescriptionLog;
|
|
use common\models\RegisterLog;
|
|
use common\models\ServiceUser;
|
|
use common\services\SmsService;
|
|
use yii\base\Exception;
|
|
use yii\queue\JobInterface;
|
|
use yii\queue\Queue;
|
|
|
|
class PrescriptionRefuseMessageJob extends BaseJob implements JobInterface
|
|
{
|
|
public $orderId;
|
|
|
|
/**
|
|
* @param Queue $queue which pushed and is handling the job
|
|
*/
|
|
public function execute($queue)
|
|
{
|
|
PrescriptionLog::saveLog($this->orderId,'处方审核被拒绝通知医生短信息发送队列start');
|
|
try {
|
|
$this->setRequest();
|
|
$prescription = Prescription::find()->where([
|
|
'id' => $this->orderId,
|
|
'status' => PrescriptionEnum::UNPASSED
|
|
])->with('doctorInfo')->one();
|
|
if (!$prescription) {
|
|
throw new Exception('处方不存在');
|
|
}
|
|
|
|
$serviceUser = ServiceUser::find()->where([
|
|
'role' => 2, //药师
|
|
'status' => 2, //已审核
|
|
'is_delete' => 0
|
|
])->asArray()->all();
|
|
if(!$serviceUser || count($serviceUser)==0){
|
|
throw new Exception('获取药师数据错误');
|
|
}
|
|
|
|
(new SmsService())->sendPrescriptionRefuse($prescription->doctorInfo->mobile, [
|
|
'prescription_no' => $prescription->prescription_no,
|
|
'reason' => $prescription->reject_reason
|
|
]);
|
|
|
|
PrescriptionLog::saveLog($this->orderId,'处方审核被拒绝通知医生短信息发送队列end');
|
|
} catch (\Exception $exception) {
|
|
PrescriptionLog::saveLog($this->orderId,'处方审核被拒绝通知医生短信息发送队列异常:'.$exception->getMessage());
|
|
return;
|
|
}
|
|
}
|
|
}
|