NoticeController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace addons\QiShangTong\backend\controllers;
  3. use addons\QiShangTong\common\service\NoticeService;
  4. use Yii;
  5. class NoticeController extends BaseController
  6. {
  7. public $enableCsrfValidation = false;
  8. /**
  9. * 首页
  10. *
  11. * @return string
  12. */
  13. public function actionIndex()
  14. {
  15. if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
  16. $data = Yii::$app->request->get();
  17. $valid = Yii::$app->services->validate->validate($data, [
  18. [['limit', 'page'], 'integer'],
  19. [['keyword', 'type'], 'string'],
  20. ]);
  21. if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  22. $ret = (new NoticeService())->page($this->mall_id, $data);
  23. return is_string($ret) ? $this->error($ret) : $this->success('获取成功', $ret);
  24. }
  25. return $this->render('index',[]);
  26. }
  27. public function actionCompensate()
  28. {
  29. if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
  30. $data = Yii::$app->request->get();
  31. $valid = Yii::$app->services->validate->validate($data, [
  32. [['id'], 'integer'],
  33. [['id'], 'required'],
  34. ]);
  35. if ($valid === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  36. $ret = (new NoticeService())->compensate($this->mall_id, $data['id']);
  37. return is_string($ret) ? $this->error($ret) : $this->success('操作成功', $ret);
  38. }
  39. }
  40. }