request->isAjax) { if (\Yii::$app->request->isGet) { $params = Yii::$app->request->get(); $params['where'] = [['mall_id' => $this->mall_id], ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]]; if (isset($params['type']) && $params['type'] != -1) $params['where'][] = ['=', 'type', $params['type']]; if (isset($params['keyword_name']) && !empty($params['keyword'])) { if ($params['keyword_name'] == 'id') $params['where'][] = ['=', 'id', $params['keyword']]; if ($params['keyword_name'] == 'title') $params['where'][] = ['=', 'title', $params['keyword']]; } $page_data = OrderCommentsTemplates::listPage($params); if ($page_data === false) return $this->error(OrderComments::getStaticError()); return $this->success('操作成功', $page_data); } } return $this->render($this->action->id); } /** * 编辑 * @Author: hua * @DateTime: 2021/10/7 16:27 * @Copyright: copyright (c) 2021 广东七件事集团 */ public function actionEdit() { if (\Yii::$app->request->isAjax) { $params = Yii::$app->request->post(); $rules = [ [['title', 'content', 'type'], 'required'], [['id'], 'safe'] ]; $res = Yii::$app->services->validate->validate($params, $rules); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params['mall_id'] = $this->mall_id; $res = OrderCommentsTemplates::setData($params); if ($res === false) return $this->error(OrderComments::getStaticError()); return $this->success(); } } /** * 删除 * @Author: hua * @DateTime: 2021/10/7 16:53 * @Copyright: copyright (c) 2021 广东七件事集团 * @return mixed|void * @throws Exception */ public function actionDestroy() { if (\Yii::$app->request->isAjax) { $params = Yii::$app->request->post(); $rules = [ [['id'], 'required'], [['id'], 'integer'] ]; $res = Yii::$app->services->validate->validate($params, $rules); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params['status'] = StatusEnum::DELETE; $res = OrderCommentsTemplates::setData($params); if ($res === false) return $this->error(OrderComments::getStaticError()); return $this->success(); } } }