This commit is contained in:
2023-08-09 14:02:00 +08:00
parent 92d67d4492
commit af3295eaa5
6 changed files with 139 additions and 36 deletions
+38 -20
View File
@@ -7,6 +7,7 @@ use App\Amqp\Producer\SendStationMessageProducer;
use App\Amqp\Producer\SendSubMessageProducer;
use App\Constants\HttpEnumCode;
use App\Exception\BusinessException;
use App\Model\BasicDetectionOrgan;
use App\Model\DetectionProject;
use App\Model\DoctorWithdrawal;
use App\Model\OrderDetection;
@@ -22,7 +23,8 @@ use App\Model\User;
use App\Model\UserDoctor;
use App\Utils\Log;
use Hyperf\Amqp\Producer;
use Hyperf\Utils\ApplicationContext;
//use Hyperf\Utils\ApplicationContext;
use Hyperf\Context\ApplicationContext;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@@ -418,7 +420,7 @@ class MessagePush extends BaseService
// 问诊内容
$disease_desc = $order_inquiry_case['disease_desc'];
if (mb_strlen($disease_desc) > 15){
if (mb_strlen($disease_desc) > 15) {
$disease_desc = mb_substr($disease_desc, 0, 15, 'UTF-8') . '...';
}
@@ -1421,7 +1423,7 @@ class MessagePush extends BaseService
// 短信
$sms_data = array();
$sms_data['template_code'] = "SMS_271905264";
$sms_data['scene_desc'] = "您为{$this->order_inquiry['patient_name']}患者开具的电子处方药师审核不通过,请尽快前往微信小程序“处方管理”中查看原因,并重开处方。模版codeSMS_271905264";
$sms_data['scene_desc'] = "您为{$this->order_inquiry['patient_name']}患者开具的电子处方药师审核不通过,请尽快前往微信小程序“处方管理”中查看原因,并重开处方。";
$sms_data['phone'] = $this->user['mobile'];
$sms_data['user_id'] = $this->user['user_id'];
@@ -2255,7 +2257,7 @@ class MessagePush extends BaseService
$params = array();
$params['detection_project_id'] = $order_detection['detection_project_id'];
$detection_project = DetectionProject::getOne($params);
if (empty($detection_project)){
if (empty($detection_project)) {
Log::getInstance("MessagePush")->error("错误:加入推送队列失败,检测项目错误");
return;
}
@@ -2287,16 +2289,23 @@ class MessagePush extends BaseService
}
}
// 患者-新报告生成通知
// 订阅发送失败发送短信
public function patientDetectionResultNotice(string $order_detection_id){
/**
* 患者-新报告生成通知
* 订阅发送失败发送短信
* @param string $order_detection_id
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function patientDetectionResultNotice(string $order_detection_id): void
{
try {
// 获取检测订单
$params = array();
$params['order_detection_id'] = $order_detection_id;
$order_detection = OrderDetection::getOne($params);
if (empty($order_detection)) {
Log::getInstance("MessagePush-patientDetectionResultNotice")->error("错误:加入推送队列失败,无检测订单数据");
Log::getInstance("MessagePush-patientDetectionResultNotice")->error("无检测订单数据");
return;
}
@@ -2304,8 +2313,17 @@ class MessagePush extends BaseService
$params = array();
$params['detection_project_id'] = $order_detection['detection_project_id'];
$detection_project = DetectionProject::getOne($params);
if (empty($detection_project)){
Log::getInstance("MessagePush-patientDetectionResultNotice")->error("错误:加入推送队列失败,检测项目错误");
if (empty($detection_project)) {
Log::getInstance("MessagePush-patientDetectionResultNotice")->error("检测项目错误");
return;
}
// 获取检测机构名称
$params = array();
$params['detection_organ_id'] = $order_detection['detection_organ_id'];
$basic_detection_organ = BasicDetectionOrgan::getOne($params);
if (empty($basic_detection_organ)){
Log::getInstance("MessagePush-patientDetectionResultNotice")->error("检测机构错误");
return;
}
@@ -2315,22 +2333,22 @@ class MessagePush extends BaseService
$sub_data['wx_template_id'] = "dNj3azLupP_w3j649v6lqz7je_ScqwgwFsnug6pKvyI"; // 处方审核结果通知
$sub_data['params']['page'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['detection_no'];
$sub_data['params']['data'] = [
"thing1" => $order_detection['patient_name'],// 报告名称
"time3" => (string)$detection_project['detection_project_name'],// 生成时间
"thing9" => date('Y年m月d日 H:i'),// 就诊人
"thing4" => $order_detection['payment_amount_total'],// 单位名称-检测所名称
"thing8" => "订单取消成功,支付金额将立即原路退回",// 测评结果
"thing1" => "" . $detection_project['detection_project_name'] . "】报告已出",// 报告名称
"time3" => date('Y年m月d日 H:i'),// 生成时间
"thing9" => $order_detection['patient_name'],// 就诊人
"thing4" => $basic_detection_organ['gts_ccis_name'],// 单位名称-检测所名称
"thing8" => "请联系医生做报告解读,您有5个沟通回合",// 测评结果
];
// 短信
$sms_data = array();
$sms_data['template_code'] = "SMS_271905264";
$sms_data['scene_desc'] = "{$this->order_inquiry['patient_name']}患者开具的电子处方药师审核不通过,请尽快前往微信小程序“处方管理”中查看原因,并重开处方。模版code:SMS_271905264";
$sms_data['template_code'] = "SMS_462035956";
$sms_data['scene_desc'] = "${$detection_project['detection_project_name']}报告单已出,请联系医生做报告解读。平台已赠送您和医生5个沟通回合,请珍惜沟通机会,请前往肝胆相照互联网医院微信小程序“个人中心”-“检测订单”-“订单详情”查看报告。";
$sms_data['phone'] = $this->user['mobile'];
$sms_data['user_id'] = $this->user['user_id'];
$template_param = array();
$template_param['name'] = $this->order_inquiry['patient_name'];
$template_param['name'] = $order_detection['patient_name'];
$sms_data['template_param'] = $template_param;
$data = array();
@@ -2341,10 +2359,10 @@ class MessagePush extends BaseService
$producer = ApplicationContext::getContainer()->get(Producer::class);
$result = $producer->produce($message);
if (!$result) {
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
Log::getInstance("MessagePush-patientDetectionResultNotice")->error(json_encode($data, JSON_UNESCAPED_UNICODE));
}
} catch (\Exception $e) {
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . $e->getMessage());
Log::getInstance("MessagePush-patientDetectionResultNotice")->error($e->getMessage());
}
}
}