From 6c9dbff813ec78e745053fe45ee015d3383d89b2 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 27 Mar 2023 18:49:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=86=E9=85=8D=E8=8D=AF?= =?UTF-8?q?=E5=B8=88=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consumer/AssignPharmacistConsumer.php | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/app/Amqp/Consumer/AssignPharmacistConsumer.php b/app/Amqp/Consumer/AssignPharmacistConsumer.php index 504421b..5f63954 100644 --- a/app/Amqp/Consumer/AssignPharmacistConsumer.php +++ b/app/Amqp/Consumer/AssignPharmacistConsumer.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Amqp\Consumer; use App\Model\OrderPrescription; +use App\Model\UserPharmacist; use App\Utils\Log; use Hyperf\Amqp\Result; use Hyperf\Amqp\Annotation\Consumer; @@ -35,18 +36,47 @@ class AssignPharmacistConsumer extends ConsumerMessage return Result::DROP;// 销毁 } - // 检测处方状态 + // 检测处方状态(1:待审核 3:待使用 4:已失效 5:已使用) if ($order_prescription['prescription_status'] != 1){ - + Db::rollBack(); + Log::getInstance()->error("分配药师队列执行失败:处方状态错误,当前为" .$order_prescription['prescription_status']); + return Result::ACK;// 销毁 } + // 检测药师审核状态 + if ($order_prescription['pharmacist_audit_status'] == 1){ + Db::rollBack(); + Log::getInstance()->error("分配药师队列执行失败:药师审核状态为已通过"); + return Result::ACK;// 销毁 + } + // 分配药师 + $params = array(); + $params['pharmacist_id'] = 3; + $user_pharmacist = UserPharmacist::getOne($params); + if (empty($user_pharmacist)){ + Db::rollBack(); + Log::getInstance()->error("分配药师队列执行失败:药师数据错误"); + return Result::DROP;// 销毁 + } + + // 分配药师 + $save_data = array(); + $save_data['pharmacist_id'] = $user_pharmacist['pharmacist_id']; + + $params = array(); + $params['order_prescription_id'] = $data['order_prescription_id']; + OrderPrescription::edit($params,$save_data); + + Db::commit(); } catch (\Exception $e) { Db::rollBack(); Log::getInstance()->error("分配药师队列执行失败原因:" . $e->getMessage()); - return Result::REQUEUE; // 重回队列 + return Result::DROP; // 重回队列 } + Log::getInstance()->info("分配药师队列执行成功"); + return Result::ACK; } }