From cf169fb5141264cccb5aa96b231c0da323905cb5 Mon Sep 17 00:00:00 2001 From: liqi Date: Thu, 6 Mar 2025 17:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eapi=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=A4=84=E6=96=B9=E7=94=9F=E6=88=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/controllers/base/DataController.php | 40 ++++++++++++++++++- .../v1/controllers/PrescriptionController.php | 19 +++++---- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/admin/controllers/base/DataController.php b/admin/controllers/base/DataController.php index 7c07cf2..b586677 100644 --- a/admin/controllers/base/DataController.php +++ b/admin/controllers/base/DataController.php @@ -3,6 +3,10 @@ namespace admin\controllers\base; use admin\components\BaseAdminController; +use common\events\PrescriptionEvent; +use common\events\ProductOrderEvent; +use common\jobs\Sms\WaitApprovalMessageJob; +use common\jobs\templateMessage\PrescriptionCreated; use common\models\oldDb\Prescription; use common\models\oldDb\ProductOrder; use common\models\oldDb\Reconciliation; @@ -16,7 +20,7 @@ use yii\db\Exception; class DataController extends BaseAdminController { - public $optional = ['count', 'top-drugs', 'trend', 'store-number']; + public $optional = ['count', 'top-drugs', 'trend', 'store-number', 'notify-order-generation']; /** * 获取首页统计数据 @@ -219,4 +223,38 @@ class DataController extends BaseAdminController } return $newArr; } + public function actionNotifyOrderGeneration() + { + $param = \Yii::$app->request->post(); + $this->requestValidate($param, [ + ['prescription', 'required'], + ['product_order', 'required'], + ]); + $prescription = $param['prescription']; + $productOrder = $param['product_order']; + //触发处方自动失效事件 + $prescriptionEvent = new PrescriptionEvent(); + $prescriptionEvent->prescription = $prescription; + $prescriptionEvent->sender = $this; + \Yii::$app->trigger(Prescription::AUTO_EXPIRE, $prescriptionEvent); + + + //触发订单创建事件 + $event = new ProductOrderEvent(); + $event->order = $productOrder; + $event->sender = $this; + \Yii::$app->trigger(ProductOrder::EVENT_CREATED, $event); + + //处方开具待支付订阅消息通知 + \Yii::$app->queue->push(new PrescriptionCreated([ + 'orderId' => $prescription['id'], + ])); + + + //处方生成短信通知药师审方 + \Yii::$app->queue->push(new WaitApprovalMessageJob([ + 'orderId' => $prescription['id'], + ])); + return ['ok']; + } } \ No newline at end of file diff --git a/service/modules/v1/controllers/PrescriptionController.php b/service/modules/v1/controllers/PrescriptionController.php index 517db94..c602c2c 100644 --- a/service/modules/v1/controllers/PrescriptionController.php +++ b/service/modules/v1/controllers/PrescriptionController.php @@ -701,7 +701,6 @@ class PrescriptionController extends BaseAppController public function actionNotifyOrderGeneration() { - return ['测试']; $param = \Yii::$app->request->post(); $this->requestValidate($param, [ ['prescription', 'required'], @@ -709,18 +708,18 @@ class PrescriptionController extends BaseAppController ]); $prescription = $param['prescription']; $productOrder = $param['product_order']; -// //触发处方自动失效事件 -// $prescriptionEvent = new PrescriptionEvent(); -// $prescriptionEvent->prescription = $prescription; -// $prescriptionEvent->sender = $this; -// \Yii::$app->trigger(Prescription::AUTO_EXPIRE, $prescriptionEvent); + //触发处方自动失效事件 + $prescriptionEvent = new PrescriptionEvent(); + $prescriptionEvent->prescription = $prescription; + $prescriptionEvent->sender = $this; + \Yii::$app->trigger(Prescription::AUTO_EXPIRE, $prescriptionEvent); //触发订单创建事件 -// $event = new ProductOrderEvent(); -// $event->order = $productOrder; -// $event->sender = $this; -// \Yii::$app->trigger(ProductOrder::EVENT_CREATED, $event); + $event = new ProductOrderEvent(); + $event->order = $productOrder; + $event->sender = $this; + \Yii::$app->trigger(ProductOrder::EVENT_CREATED, $event); //处方开具待支付订阅消息通知 \Yii::$app->queue->push(new PrescriptionCreated([