[ 'class' => LoginBehavior::className(), ], ]); } //卡券列表 public function actionIndex() { if(\Yii::$app->request->isAjax){ $form = new CouponListForm(); $form->attributes = \Yii::$app->request->get(); $data = $form->search(); return $this->responseHandler($data); } return $this->render('index'); } //创建卡券 public function actionEdit($id = 0) { $model = Coupon::findOne([ 'id' => $id, 'is_delete' => 0 ]); if($model == null) $model = new Coupon(); if(\Yii::$app->request->post()){ $form = new CouponEditForm(); $form->attributes = \Yii::$app->request->post(); $form->model = $model; $data = $form->edit(); return $this->responseHandler($data); } $store = Store::find()->where(['is_delete' => 0,'status' => 1])->select('id as value,name')->asArray()->all(); return $this->render('edit',[ 'model' => $model, 'store' => json_encode($store), ]); } //删除卡券 public function actionDelete() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CouponActionForm(); $form->attributes = \Yii::$app->request->post(); $data = $form->delete(); return $this->responseHandler($data); } }