NoticeController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace backend\modules\mall\controllers;
  3. use backend\controllers\MallController;
  4. use backend\modules\mall\services\NoticeService;
  5. /**
  6. * 消息控制器
  7. *
  8. * Class NoticeController
  9. * @package backend\modules\mall\controllers
  10. */
  11. class NoticeController extends MallController
  12. {
  13. /**
  14. * 消息列表
  15. *
  16. * @return mixed
  17. */
  18. public function actionIndex()
  19. {
  20. if ($this->request->isAjax) {
  21. $params = $this->request->get();
  22. $service = new NoticeService(['mall_id' => $this->mall_id]);
  23. return $this->success('ok', $service->getPageList($params));
  24. }
  25. return $this->render($this->action->id);
  26. }
  27. /**
  28. * 消息阅读
  29. *
  30. * @return mixed
  31. */
  32. public function actionRead()
  33. {
  34. $id = $this->request->get('id');
  35. $service = new NoticeService(['mall_id' => $this->mall_id]);
  36. $service->readNotice($id);
  37. return $this->success('ok');
  38. }
  39. /**
  40. * 未读消息
  41. *
  42. * @return mixed
  43. */
  44. public function actionUnreadCount()
  45. {
  46. $service = new NoticeService(['mall_id' => $this->mall_id]);
  47. $unread_count = $service->getUnReadCount();
  48. return $this->success('ok', compact('unread_count'));
  49. }
  50. }