新增api通知处方生成功能

This commit is contained in:
2025-03-06 17:11:45 +08:00
parent baa9a34e5e
commit cf169fb514
2 changed files with 48 additions and 11 deletions

View File

@@ -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'];
}
}

View File

@@ -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([