diff --git a/admin/controllers/base/DataController.php b/admin/controllers/base/DataController.php index 11c1cea..d9c7008 100644 --- a/admin/controllers/base/DataController.php +++ b/admin/controllers/base/DataController.php @@ -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']; + } } \ No newline at end of file