新增api通知处方生成功能

This commit is contained in:
2025-03-11 13:02:42 +08:00
parent 72f22c8942
commit 8beb1129df
3 changed files with 9 additions and 41 deletions

View File

@@ -230,10 +230,7 @@ class DataController extends BaseAdminController
// ['prescription', 'required'],
// ['product_order', 'required'],
// ]);
// return [
// gettype($prescription),
// $prescription
// ];
// $productOrder = $param['product_order'];
//触发处方自动失效事件
// $prescriptionEvent = new PrescriptionEvent();

View File

@@ -29,7 +29,8 @@ class ProductOrderSubmitForm extends BaseModel
public function getPayData($post)
{
$ProductOrder = ProductOrder::find()->where([
// category
$ProductOrder = ProductOrder::find()->with(['prescription'])->where([
'id' => $post['order_id'],
'user_id' => \Yii::$app->user->identity->getId(),
])->one();
@@ -128,6 +129,12 @@ class ProductOrderSubmitForm extends BaseModel
$paymentProductOrder->order_no = $productOrder['order_no'];
$paymentProductOrder->pay_order_no = $pay_order_no;
$paymentProductOrder->amount = $productOrder['total_pay_price'];
if ($productOrder->prescription->category?? 1 === 2) {
if ($productOrder->delivery_method === 0) {
$paymentProductOrder->amount = $productOrder['trans_expenses'];
}
}
$paymentProductOrder->saveOrFail();
if(bccomp($total_fee,0,2) <= 0){ //无需支付

View File

@@ -58,7 +58,6 @@ class PrescriptionController extends BaseAppController
{
// public $optional = ['process-rule-list', 'process-note-list'];
public $optional = ['notify-order-generation'];
public function beforeAction($action){
$ret = parent::beforeAction($action);
@@ -699,41 +698,6 @@ 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'];
}
/**
* 中药剂数列表
*/