新增 医生xx时间未接诊提醒队列
This commit is contained in:
parent
bea292cd5e
commit
857536e8bd
@ -6,6 +6,7 @@ namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Amqp\Producer\AssignDoctorDelayDirectProducer;
|
||||
use App\Amqp\Producer\CancelUnInquiryOrdersDelayDirectProducer;
|
||||
use App\Amqp\Producer\DoctorNotYetInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\UserCouponExpiredDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\OrderInquiry;
|
||||
@ -131,8 +132,8 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
}
|
||||
|
||||
// 检测分配时间
|
||||
if ($diff_time > 300) {
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:超出5分钟,执行退款");
|
||||
if ($diff_time > 600) {
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:超出10分钟,执行退款");
|
||||
|
||||
$InquiryService = new InquiryService();
|
||||
|
||||
@ -284,6 +285,16 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
// 医生-医生有新问诊 站内、订阅失败发送短信
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->doctorHaveNewInquiry();
|
||||
|
||||
// 加入xx时间未接诊通知队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
$time = 1000 * 60 * 3;
|
||||
$message = new DoctorNotYetInquiryDelayDirectProducer($data);
|
||||
$message->setDelayMs($time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$producer->produce($message);
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-AssignDoctor")->error("发送消息异常错误:" . $e->getMessage());
|
||||
return Result::ACK;
|
||||
@ -355,7 +366,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
}
|
||||
|
||||
// 执行次数过多
|
||||
if ($redis_value > 3) {
|
||||
if ($redis_value > 4) {
|
||||
// 加入短信队列,通知管理员
|
||||
|
||||
return false;
|
||||
|
||||
@ -151,6 +151,7 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息失败:医生数据错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 发送IM消息-医生未接诊
|
||||
|
||||
@ -49,7 +49,7 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error("开始执行 取消未支付订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
Log::getInstance("queue-CancelUnpayOrders")->info("开始执行 取消未支付订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
|
||||
80
app/Amqp/Consumer/DoctorNotYetInquiryDelayDirectConsumer.php
Normal file
80
app/Amqp/Consumer/DoctorNotYetInquiryDelayDirectConsumer.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\MessagePush;
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
||||
/**
|
||||
* 医生xx时间未接诊提醒
|
||||
*/
|
||||
#[Consumer(nums: 1)]
|
||||
class DoctorNotYetInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
use ConsumerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected ?string $queue = 'doctor.not.uet.inquiry.delay.queue';
|
||||
|
||||
protected string $type = Type::DIRECT; //Type::FANOUT;
|
||||
|
||||
protected string|array $routingKey = 'DoctorNotYetInquiry';
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
if (!isset($data['order_inquiry_id'])){
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error("缺少参数");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error("未找到对应问诊订单");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 检测问诊订单状态
|
||||
if ($order_inquiry['inquiry_status'] != 3){
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error("状态非待接诊,无需发送");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 获取订单医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error("医生数据错误");
|
||||
}
|
||||
|
||||
// 发送站内、订阅消息-医生-超时未接诊
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->doctorNotYetInquiry();
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error("失败:" . $e->getMessage());
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
return Result::ACK;
|
||||
}
|
||||
}
|
||||
30
app/Amqp/Producer/DoctorNotYetInquiryDelayDirectProducer.php
Normal file
30
app/Amqp/Producer/DoctorNotYetInquiryDelayDirectProducer.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
/**
|
||||
* 医生xx时间未接诊提醒
|
||||
*/
|
||||
#[Producer]
|
||||
class DoctorNotYetInquiryDelayDirectProducer extends ProducerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected string $type = Type::DIRECT;
|
||||
|
||||
protected string|array $routingKey = 'DoctorNotYetInquiry';
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->payload = $data;
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Amqp\Producer\AssignDoctorDelayDirectProducer;
|
||||
use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\DoctorNotYetInquiryDelayDirectProducer;
|
||||
use App\Constants\DoctorTitleCode;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
@ -196,6 +197,16 @@ class CallBackController extends AbstractController
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'], $order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->doctorHaveNewInquiry();
|
||||
|
||||
// 加入xx时间未接诊通知队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
$time = 1000 * 60 * 60 * 2;
|
||||
$message = new DoctorNotYetInquiryDelayDirectProducer($data);
|
||||
$message->setDelayMs($time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$producer->produce($message);
|
||||
|
||||
Log::getInstance()->info("发送im消息成功");
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +168,10 @@ class UserController extends AbstractController
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
// 上报用户地址
|
||||
/**
|
||||
* 上报用户地址
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function postLocation(): ResponseInterface
|
||||
{
|
||||
$UserService = new UserService();
|
||||
|
||||
@ -1178,78 +1178,69 @@ class MessagePush extends BaseService
|
||||
throw new BusinessException("加入推送队列失败:问诊病例为空");
|
||||
}
|
||||
|
||||
if ($this->push_type == 1) {
|
||||
// 站内
|
||||
$data = array();
|
||||
$data['user_id'] = $this->user['user_id'];
|
||||
$data['notice_type'] = 1;
|
||||
$data['inquiry_type'] = $this->order_inquiry['inquiry_type']; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
$data['from_name'] = "肝胆小秘书";
|
||||
$data['notice_brief_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。";
|
||||
$data['notice_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。";
|
||||
$data['notice_content'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。";
|
||||
$data['link_type'] = 1; // 聊天详情页
|
||||
// 站内
|
||||
$data = array();
|
||||
$data['user_id'] = $this->user['user_id'];
|
||||
$data['notice_type'] = 1;
|
||||
$data['inquiry_type'] = $this->order_inquiry['inquiry_type']; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
$data['from_name'] = "肝胆小秘书";
|
||||
$data['notice_brief_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。";
|
||||
$data['notice_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。";
|
||||
$data['notice_content'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。";
|
||||
$data['link_type'] = 1; // 聊天详情页
|
||||
|
||||
$link_params = array();
|
||||
$link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
|
||||
$link_params['inquiry_type'] = $this->order_inquiry['inquiry_type'];
|
||||
$link_params['doctor_user_id'] = $this->user['user_id'];
|
||||
$link_params['patient_user_id'] = $this->order_inquiry['user_id'];
|
||||
$data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数
|
||||
$link_params = array();
|
||||
$link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
|
||||
$link_params['inquiry_type'] = $this->order_inquiry['inquiry_type'];
|
||||
$link_params['doctor_user_id'] = $this->user['user_id'];
|
||||
$link_params['patient_user_id'] = $this->order_inquiry['user_id'];
|
||||
$data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数
|
||||
|
||||
$message = new SendStationMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
} elseif ($this->push_type == 2) {
|
||||
// 订阅
|
||||
$inquiry_type = inquiryTypeToString($this->order_inquiry['inquiry_type']);
|
||||
$message = new SendStationMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$sub_data = array();
|
||||
$sub_data['push_user_id'] = $this->user['user_id'];
|
||||
$sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc"; // 咨询提醒
|
||||
$sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen";
|
||||
$sub_data['params']['data'] = [
|
||||
"thing1" => "您好医生,{$this->order_inquiry['patient_name']}患者的({$inquiry_type})服务您还未接诊;",// 提醒内容
|
||||
$inquiry_type = inquiryTypeToString($this->order_inquiry['inquiry_type']);
|
||||
|
||||
"name2" => $this->order_inquiry['patient_name'],// 患者姓名
|
||||
// 订阅
|
||||
$sub_data = array();
|
||||
$sub_data['push_user_id'] = $this->user['user_id'];
|
||||
$sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc"; // 咨询提醒
|
||||
$sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen";
|
||||
$sub_data['params']['data'] = [
|
||||
"thing1" => "您好医生,{$this->order_inquiry['patient_name']}患者的({$inquiry_type})服务您还未接诊;",// 提醒内容
|
||||
"name2" => $this->order_inquiry['patient_name'],// 患者姓名
|
||||
"thing4" => mb_substr($order_inquiry_case['disease_desc'], 0, 18),// 病情描述
|
||||
"thing6" => "24小时内未接诊,平台将自动取消问诊。",// 提示说明
|
||||
"thing5" => "",// 咨询内容
|
||||
];
|
||||
|
||||
"thing4" => mb_substr($order_inquiry_case['disease_desc'], 0, 18),// 病情描述
|
||||
$sms_data = array();
|
||||
$sms_data['template_code'] = "SMS_272SMS_271905266120097";
|
||||
$sms_data['scene_desc'] = "医生xx时间后还未接诊";
|
||||
$sms_data['phone'] = $this->user['mobile'];
|
||||
$sms_data['user_id'] = $this->user['user_id'];
|
||||
|
||||
"thing6" => "24小时内未接诊,平台将自动取消问诊。",// 提示说明
|
||||
$template_param = array();
|
||||
$template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']);
|
||||
$template_param['name'] = $this->order_inquiry['patient_name'];
|
||||
$sms_data['template_param'] = $template_param;
|
||||
|
||||
"thing5" => "",// 咨询内容
|
||||
|
||||
];
|
||||
|
||||
// 短信
|
||||
$sms_data = array();
|
||||
$sms_data['template_code'] = "SMS_271905266";
|
||||
$sms_data['scene_desc'] = "医生xx时间后还未接诊";
|
||||
$sms_data['phone'] = $this->user['mobile'];
|
||||
$sms_data['user_id'] = $this->user['user_id'];
|
||||
|
||||
$template_param = array();
|
||||
$template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']);
|
||||
$template_param['name'] = $this->order_inquiry['patient_name'];
|
||||
$sms_data['template_param'] = $template_param;
|
||||
|
||||
$data = array();
|
||||
$data['sub_data'] = $sub_data;
|
||||
$data['sms_data'] = $sms_data;
|
||||
|
||||
$message = new SendSubMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$data = array();
|
||||
$data['sub_data'] = $sub_data;
|
||||
$data['sms_data'] = $sms_data;
|
||||
|
||||
$message = new SendSubMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new BusinessException("加入推送队列失败" . $e->getMessage());
|
||||
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -4,6 +4,7 @@ namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\AssignDoctorDelayDirectProducer;
|
||||
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||
use App\Amqp\Producer\DoctorNotYetInquiryDelayDirectProducer;
|
||||
use App\Constants\DoctorTitleCode;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\BasicLogisticsCompany;
|
||||
@ -985,6 +986,16 @@ class PatientOrderService extends BaseService
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'], $order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->doctorHaveNewInquiry();
|
||||
|
||||
// 加入xx时间未接诊通知队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
$time = 1000 * 60 * 60 * 2;
|
||||
$message = new DoctorNotYetInquiryDelayDirectProducer($data);
|
||||
$message->setDelayMs($time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$producer->produce($message);
|
||||
|
||||
Log::getInstance()->info("发送im消息成功");
|
||||
}
|
||||
|
||||
|
||||
@ -686,6 +686,9 @@ Router::addGroup('/user', function () {
|
||||
|
||||
// 上报用户地址
|
||||
Router::post('/location', [UserController::class, 'postLocation']);
|
||||
//
|
||||
// // 获取用户地址
|
||||
// Router::get('/location', [UserController::class, 'getLocation']);
|
||||
});
|
||||
|
||||
// 获取患者问诊病例
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user