| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace backend\modules\mall\controllers;
- use backend\controllers\MallController;
- use common\enums\StatusEnum;
- use common\models\goods\Goods;
- use common\models\order\OrderComments;
- use common\models\order\OrderCommentsTemplates;
- use common\models\User;
- use Exception;
- use Yii;
- /**
- * 评价模板管理控制器
- *
- * Class OrderCommentsController
- * @Author: hua
- * @DateTime: 2021/10/7 15:57
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @package backend\modules\mall\controllers
- */
- class OrderCommentTemplatesController extends MallController
- {
- /**
- * 首页
- * @Author: hua
- * @DateTime: 2021/10/7 15:57
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|string|void
- */
- public function actionIndex()
- {
- if (\Yii::$app->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();
- }
- }
- }
|