[ 'class' => LoginBehavior::className(), ], ]); } public function actionIndex() { if(\Yii::$app->request->isAjax){ $form = new CommonFeedbackListForm(); $form->attributes = \Yii::$app->request->get(); $form->cx_mch_id = $this->cx_mch_id; $data = $form->search(); return $this->responseHandler($data); } $cat_list = Cat::find() ->where([ 'cx_mch_id' => $this->cx_mch_id, 'is_delete' => 0, 'type' => Cat::TYPE_FEEDBACK, ]) ->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC]) ->select('id,name')->asArray()->all(); return $this->render('index',[ 'cat_list' => $cat_list ]); } public function actionDelete() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CommonFeedbackActionForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->user_id = \Yii::$app->admin->identity->user_id; $data = $form->delete(); return $this->responseHandler($data); } public function actionReview() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CommonFeedbackActionForm(); $form->scenario = 'review'; $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->user_id = \Yii::$app->admin->identity->user_id; $data = $form->review(); return $this->responseHandler($data); } public function actionCat() { if(\Yii::$app->request->isAjax){ $form = new CommonCatListForm(); $form->attributes = \Yii::$app->request->get(); $form->cx_mch_id = $this->cx_mch_id; $form->type = Cat::TYPE_FEEDBACK; $data = $form->search(); return $this->responseHandler($data); } return $this->render('cat'); } public function actionCatEdit($id = 0) { $model = Cat::findOne([ 'cx_mch_id' => $this->cx_mch_id, 'is_delete' => 0, 'id' => $id, 'type' => Cat::TYPE_FEEDBACK, ]); if($model == null){ $model = new Cat(); $model->status = 1; } if(\Yii::$app->request->isPost){ $form = new CommonCatEditForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->model = $model; $form->type = Cat::TYPE_FEEDBACK; $data = $form->save(); return $this->responseHandler($data); } $cat_ids = []; $cat_ids[] = $model->isNewRecord ? 0 : $model->id; $parent_list = Cat::find() ->where([ 'cx_mch_id' => $this->cx_mch_id, 'is_delete' => 0, 'type' => Cat::TYPE_FEEDBACK, ]) ->andWhere([ 'NOT IN', 'id', $cat_ids ]) ->select('id,name')->asArray()->all(); $is_has_parent = false;//开启是否有父节点 $parent_list = $is_has_parent ? $parent_list : []; array_unshift($parent_list,['id' => 0, 'name' => '无父节点']); $return_url = \Yii::$app->request->referrer; return $this->render('cat-edit', [ 'model' => $model, 'return_url' => $return_url, 'parent_list' => $parent_list ]); } public function actionCatDelete() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CommonCatActionForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->type = Cat::TYPE_FEEDBACK; $data = $form->delete(); return $this->responseHandler($data); } public function actionCatShow() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CommonCatActionForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->type = Cat::TYPE_FEEDBACK; $data = $form->show(); return $this->responseHandler($data); } public function actionCatHide() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CommonCatActionForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->type = Cat::TYPE_FEEDBACK; $data = $form->hide(); return $this->responseHandler($data); } public function actionCatOpen() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CommonCatActionForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->type = Cat::TYPE_FEEDBACK; $data = $form->open(); return $this->responseHandler($data); } public function actionCatClose() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CommonCatActionForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->type = Cat::TYPE_FEEDBACK; $data = $form->close(); return $this->responseHandler($data); } }