From c8c3f0f35f76c9f91d5c08fddadcecb05c1e4fc1 Mon Sep 17 00:00:00 2001 From: liqi Date: Thu, 6 Mar 2025 15:45:11 +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 --- .../v1/controllers/PrescriptionController.php | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/service/modules/v1/controllers/PrescriptionController.php b/service/modules/v1/controllers/PrescriptionController.php index b78e88f..74c8ba6 100644 --- a/service/modules/v1/controllers/PrescriptionController.php +++ b/service/modules/v1/controllers/PrescriptionController.php @@ -58,6 +58,7 @@ class PrescriptionController extends BaseAppController { // public $optional = ['process-rule-list', 'process-note-list']; + public $optional = ['NotifyOrderGeneration']; public function beforeAction($action){ $ret = parent::beforeAction($action); @@ -65,7 +66,6 @@ class PrescriptionController extends BaseAppController if(!$doctorInfo){ throw new Exception('无权限进行该操作'); } - $westActions = ['actionProcessRuleList','actionProcessNoteList','actionWestList', 'actionWestCommon','actionServicePackageList', 'actionServicePackageCommon', 'actionUseNum', 'actionDosage', 'actionWestCollection', 'actionWestUncollect', 'actionAddWest', 'actionAddPrescriptionWest','actionUseTime','actionUseType','actionUseFre','actionSearchDisease','actionDiseaseCommon','actionAddDiseaseCommon','actionDelDiseaseCommon','actionWestUnit','actionPrescriptionDetail']; if($doctorInfo->identity == 2 && !in_array($action->actionMethod, $westActions)){ throw new Exception('您当前并未拥有开具此方的权限'); @@ -699,6 +699,41 @@ class PrescriptionController extends BaseAppController } } + 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']; + } + /** * 中药剂数列表 */