订单自动失效接口提供

This commit is contained in:
2025-03-24 16:21:20 +08:00
parent b60825c84b
commit f5ff498938

View File

@@ -5,6 +5,8 @@ namespace admin\controllers\base;
use admin\components\BaseAdminController;
use common\events\PrescriptionEvent;
use common\events\ProductOrderEvent;
use common\forms\ProductCancelForm;
use common\forms\ProductRefundForm;
use common\jobs\Sms\WaitApprovalMessageJob;
use common\jobs\templateMessage\PrescriptionCreated;
use common\models\oldDb\Prescription;
@@ -257,4 +259,32 @@ class DataController extends BaseAdminController
]));
return ['ok'];
}
/**
* 处理处方过期
* @return string[]
* @throws \yii\base\Exception
*/
public function prescriptionOver(): array
{
$orderId = \Yii::$app->request->post('order_id');
$userId = \Yii::$app->request->post('user_id');
$type = \Yii::$app->request->post('type');
if($type === 1){
// 自动退款
$ProductRefundForm = new ProductRefundForm();
$ProductRefundForm->refund([
'order_id' => $orderId,
'user_id' => $userId
]);
} else {
// 订单自动失效
$ProductCancelForm = new ProductCancelForm();
$ProductCancelForm->cancel([
'order_id' => $orderId,
'user_id' => $userId
], '处方失效,订单自动失效');
}
return ['ok'];
}
}