public function actionCancel($id) { try { $cancelOrderForm = new CancelOrderForm($id); } catch (InvalidParamException $e) { throw new BadRequestHttpException($e->getMessage()); } if ($cancelOrderForm->load(Yii::$app->request->post()) && $cancelOrderForm->cancel()) { Yii::$app->session->setFlash('success', '取消成功!'); } else { Yii::$app->session->setFlash('danger', '取消失败!'); } return $this->redirect(['view', 'id' => $id]); }