新增问诊订单自动完成延迟队列
This commit is contained in:
parent
727b548be4
commit
dc4f85f3d9
184
app/Amqp/Consumer/AutoCompleteInquiryDelayDirectConsumer.php
Normal file
184
app/Amqp/Consumer/AutoCompleteInquiryDelayDirectConsumer.php
Normal file
@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\PatientHistoryInquiry;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\ImService;
|
||||
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\Producer;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
#[Consumer(nums: 1)]
|
||||
class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
use ConsumerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected ?string $queue = 'auto.complete.inquiry.delay.queue';
|
||||
|
||||
protected string $type = Type::DIRECT; //Type::FANOUT;
|
||||
|
||||
protected string|array $routingKey = 'AutoCompleteInquiry';
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance()->error("开始执行 自动完成问诊订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 检测入参参数
|
||||
if (empty($data['order_inquiry_id'])) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:入参错误");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:问诊订单数据为空");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
$order_inquiry = $order_inquiry->toArray();
|
||||
|
||||
// 检测问诊订单状态
|
||||
if ($order_inquiry['inquiry_status'] != 4) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行结果:无需处理");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 检测问诊订单退款状态
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])){
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行结果:订单退款中,无需处理");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 订单支付状态
|
||||
if ($order_inquiry['inquiry_pay_status'] != 2){
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行结果:订单未支付,无需处理");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 新增患者历史问诊表
|
||||
$data = array();
|
||||
$data['patient_id'] = $order_inquiry['patient_id'];
|
||||
$data['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
if (!empty($order_inquiry['pharmacist_id'])){
|
||||
$data['pharmacist_id'] = $order_inquiry['pharmacist_id'];
|
||||
}
|
||||
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$data['history_status'] = 1;
|
||||
$patient_history_inquiry = PatientHistoryInquiry::addPatientHistoryInquiry($data);
|
||||
if (empty($patient_history_inquiry)){
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行结果:新增患者历史问诊表失败");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if(empty($user_doctor)){
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行结果:缺少医生数据");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 处理问诊订单数据为已完成
|
||||
$data = array();
|
||||
$data['inquiry_status'] = 5;// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$data['complete_time'] = date('Y-m-d H:i:s',time());// 订单完成时间(问诊完成时间)
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params,$data);
|
||||
|
||||
// 处理处方数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||
$params['pharmacist_audit_status'] = 1;
|
||||
$order_prescription = OrderPrescription::getList($params);
|
||||
foreach ($order_prescription as $item){
|
||||
if ($item['prescription_status'] == 1 && $item['pharmacist_audit_status'] == 0){
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $item['order_prescription_id'];
|
||||
|
||||
$data = array();
|
||||
$data['pharmacist_audit_status'] = 2;
|
||||
$data['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());
|
||||
$data['pharmacist_fail_reason'] = "药师过期未审核";
|
||||
|
||||
OrderPrescription::edit($params,$data);
|
||||
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->prescriptionVerifyFail($order_prescription['order_prescription_id']);
|
||||
}
|
||||
}
|
||||
|
||||
// 发送IM消息-问诊已结束
|
||||
$imService = new ImService();
|
||||
$imService->inquiryEnd($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
|
||||
|
||||
// 发送IM消息-问诊结束评价通知
|
||||
$imService->inquiryEndEvaluation($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
|
||||
|
||||
// 发送站内消息-问诊结束
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->finishInquiryToDoctor();
|
||||
|
||||
// 添加自动完成队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
$message = new AutoFinishInquiryDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * 60 * 1);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行结果:添加自动结束队列失败");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行成功");
|
||||
return Result::ACK;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单执行失败:" . $e->getMessage());
|
||||
return Result::ACK; // 重回队列
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,8 @@ use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* 自动完成问诊订单
|
||||
* 自动结束问诊订单
|
||||
* 医生完成后的订单,自动结束
|
||||
* 延迟队列
|
||||
*/
|
||||
#[Consumer(nums: 1)]
|
||||
@ -46,14 +47,14 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance()->error("开始执行 自动完成问诊订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
Log::getInstance()->error("开始执行 自动结束问诊订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 检测入参参数
|
||||
if (empty($data['order_inquiry_id'])) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:入参错误");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:入参错误");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:问诊订单数据为空");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:问诊订单数据为空");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
@ -72,20 +73,20 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
if ($order_inquiry['inquiry_status'] != 5) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:问诊订单未完成,无法结束");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:问诊订单未完成,无法结束");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:问诊订单正在申请退款");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:问诊订单正在申请退款");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
if (empty($order_inquiry['doctor_id'])) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:医生id为空");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:医生id为空");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
@ -95,7 +96,7 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
$res = $this->handleDoctorAccount($order_inquiry);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:处理医生账户总表失败");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:处理医生账户总表失败");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
@ -103,7 +104,7 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
$res = $this->handleDoctorAccountDay($order_inquiry);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:处理医生账户表-日失败");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:处理医生账户表-日失败");
|
||||
return Result::DROP;
|
||||
}
|
||||
}
|
||||
@ -117,14 +118,12 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
// 处理回写患者病例-回写失败不做处理
|
||||
$this->handleOrderInquiryCase($order_inquiry);
|
||||
|
||||
// 处理处方数据
|
||||
$this->handlePrescription($order_inquiry);
|
||||
Db::commit();
|
||||
Log::getInstance()->info("自动完成问诊订单队列执行成功");
|
||||
Log::getInstance()->info("自动结束问诊订单队列执行成功");
|
||||
return Result::ACK;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单执行失败:" . $e->getMessage());
|
||||
Log::getInstance()->error("自动结束问诊订单执行失败:" . $e->getMessage());
|
||||
return Result::ACK; // 重回队列
|
||||
}
|
||||
}
|
||||
@ -289,7 +288,7 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
$patient_family_health = PatientFamilyHealth::addPatientFamilyHealth($data);
|
||||
if (empty($patient_family_health)) {
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:回写患者家庭成员信息表-健康情况表失败");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:回写患者家庭成员信息表-健康情况表失败");
|
||||
}
|
||||
} else {
|
||||
$data = array();
|
||||
@ -347,7 +346,7 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
$patient_family_personal = PatientFamilyPersonal::addPatientFamilyPersonal($data);
|
||||
if (empty($patient_family_personal)) {
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:回写患者家庭成员信息表-个人情况表失败");
|
||||
Log::getInstance()->error("自动结束问诊订单队列执行失败:回写患者家庭成员信息表-个人情况表失败");
|
||||
}
|
||||
} else {
|
||||
$data = array();
|
||||
@ -384,46 +383,5 @@ class AutoFinishInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理处方数据
|
||||
* @param array|object $order_inquiry
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function handlePrescription(array|object $order_inquiry): void
|
||||
{
|
||||
try {
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_prescription = OrderPrescription::getList($params);
|
||||
if (!empty($order_prescription)){
|
||||
foreach ($order_prescription as $item){
|
||||
if ($item['prescription_status'] == 1 && $item['pharmacist_audit_status'] == 0){
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $item['order_prescription_id'];
|
||||
|
||||
$data = array();
|
||||
$data['pharmacist_audit_status'] = 2;
|
||||
$data['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());
|
||||
$data['pharmacist_fail_reason'] = "药师过期未审核";
|
||||
|
||||
OrderPrescription::edit($params,$data);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (!empty($user_doctor)){
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->prescriptionVerifyFail();
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::getInstance()->error("自动完成问诊订单队列执行失败:处理处方数据失败" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31
app/Amqp/Producer/AutoCompleteInquiryDelayDirectProducer.php
Normal file
31
app/Amqp/Producer/AutoCompleteInquiryDelayDirectProducer.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* 自动完成问诊订单
|
||||
* 延迟队列
|
||||
*/
|
||||
#[Producer]
|
||||
class AutoCompleteInquiryDelayDirectProducer extends ProducerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected string $type = Type::DIRECT;
|
||||
|
||||
protected string|array $routingKey = 'AutoCompleteInquiry';
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->payload = $data;
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,8 @@ use Hyperf\Amqp\Message\ProducerMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
/**
|
||||
* 自动完成问诊订单
|
||||
* 自动结束问诊订单
|
||||
* 医生完成后的订单,自动结束
|
||||
* 延迟队列
|
||||
*/
|
||||
#[Producer]
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Amqp\Producer\AssignDoctorProducer;
|
||||
use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
@ -774,13 +775,15 @@ class TestController extends AbstractController
|
||||
|
||||
// 快递订阅
|
||||
public function test_14(){
|
||||
// $Kuaidi = new Kuaidi();
|
||||
// $result = $Kuaidi->subscribe("78674717911499","zhongtong","15201255314");
|
||||
// dump($result);
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = "505311998932189184";
|
||||
|
||||
$a = '{"status":"polling","message":"","lastResult":{"message":"ok","nu":"YT6074326614455","ischeck":"0","com":"yuantong","status":"200","state":"1","data":[{"time":"2023-02-02 09:57:03","context":"【长沙市】 【长沙东站】(07**-55**234) 的 长沙东站司法分部(135****1234) 已接单","ftime":"2023-02-02 09:57:03","areaCode":"CN430100000000","areaName":"湖南,长沙市","status":"揽收","location":null,"areaCenter":null,"areaPinYin":null,"statusCode":null}],"loop":false}}';
|
||||
|
||||
$b = strtoupper(md5( $a . config('kuaidi100.salt') ));
|
||||
dump($b);
|
||||
$message = new AutoCompleteInquiryDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * 10);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ namespace App\Model;
|
||||
|
||||
|
||||
use Hyperf\Contract\LengthAwarePaginatorInterface;
|
||||
use Hyperf\Database\Model\Builder;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\HasMany;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
@ -99,7 +100,7 @@ class OrderPrescription extends Model
|
||||
* 获取数据-多
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
* @return Builder[]|Collection
|
||||
*/
|
||||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\CancelUnInquiryOrdersDelayDirectProducer;
|
||||
use App\Amqp\Producer\CancelUnPayInquiryOrderDelayProducer;
|
||||
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||
@ -276,6 +277,7 @@ class InquiryService extends BaseService
|
||||
}
|
||||
|
||||
// 加入未接诊取消订单延迟队列
|
||||
// 专家问诊-公益问诊
|
||||
if (!empty($request_params['doctor_id']) && ($request_params['inquiry_type'] == 1 || $request_params['inquiry_type'] == 3)){
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
@ -395,6 +395,8 @@ class MessagePush extends BaseService
|
||||
// 获取问诊订单处方数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
|
||||
$params['doctor_id'] = $this->order_inquiry['doctor_id'];
|
||||
$params['pharmacist_audit_status'] = 1;
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)) {
|
||||
throw new BusinessException("加入推送队列失败:处方数据为空");
|
||||
@ -1167,6 +1169,8 @@ class MessagePush extends BaseService
|
||||
// 获取问诊订单处方数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
|
||||
$params['doctor_id'] = $this->order_inquiry['doctor_id'];
|
||||
$params['pharmacist_audit_status'] = 1;
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)) {
|
||||
throw new BusinessException("加入推送队列失败:处方数据为空");
|
||||
@ -1244,12 +1248,12 @@ class MessagePush extends BaseService
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function prescriptionVerifyFail(): bool
|
||||
public function prescriptionVerifyFail(string $order_prescription_id): bool
|
||||
{
|
||||
try {
|
||||
// 获取问诊订单处方数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)) {
|
||||
throw new BusinessException("加入推送队列失败:处方数据为空");
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\AssignPharmacistProducer;
|
||||
use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||||
use App\Constants\DoctorTitleCode;
|
||||
use App\Constants\HttpEnumCode;
|
||||
@ -1636,6 +1637,29 @@ class UserDoctorService extends BaseService
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->patientAcceptedInquiry();
|
||||
|
||||
if ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){
|
||||
// 专家问诊-公益问诊
|
||||
$time = 1000 * 60 * 60;
|
||||
}elseif($order_inquiry['inquiry_type'] == 2){
|
||||
// 快速问诊
|
||||
$time = 1000 * 60 * 30;
|
||||
}else{
|
||||
// 购药
|
||||
$time = 1000 * 60 * 30;
|
||||
}
|
||||
|
||||
// 添加自动完成队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
$message = new AutoCompleteInquiryDelayDirectProducer($data);
|
||||
$message->setDelayMs($time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
|
||||
@ -266,7 +266,7 @@ class UserPharmacistService extends BaseService
|
||||
}else{
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->prescriptionVerifyFail();
|
||||
$MessagePush->prescriptionVerifyFail($order_prescription['order_prescription_id']);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user