ShopNoticeController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\shop\classes\ShopNoticeClass;
  4. use common\components\util;
  5. use Yii;
  6. /**
  7. * 商城客户端:门店通知公告(xhShopNotice)
  8. */
  9. class ShopNoticeController extends BaseController
  10. {
  11. /**
  12. * 客户端公告列表(仅上架、未删除)
  13. * GET /shop-notice/show-list?position=2
  14. */
  15. public function actionShowList()
  16. {
  17. $user = $this->user;
  18. if (empty($user) || empty($this->mainId)) {
  19. util::success([
  20. 'totalNum' => 0,
  21. 'totalPage' => 0,
  22. 'moreData' => 0,
  23. 'list' => [],
  24. ]);
  25. }
  26. $get = Yii::$app->request->get();
  27. $list = ShopNoticeClass::searchList([
  28. 'mainId' => $this->mainId,
  29. 'title' => $get['title'] ?? '',
  30. 'position' => $get['position'] ?? '',
  31. 'isDel' => 0,
  32. 'status' => 1,
  33. 'order' => 'sort DESC, id DESC',
  34. ]);
  35. util::success($list);
  36. }
  37. /**
  38. * 客户端公告详情
  39. * GET /shop-notice/detail?id=
  40. */
  41. public function actionDetail()
  42. {
  43. $user = $this->user;
  44. if (empty($user) || empty($this->mainId)) {
  45. util::fail('请先登录哈');
  46. }
  47. $id = intval(Yii::$app->request->get('id', 0));
  48. if ($id <= 0) {
  49. util::fail('公告id不对');
  50. }
  51. $info = ShopNoticeClass::getById($id);
  52. ShopNoticeClass::valid($info, $this->mainId);
  53. if (intval($info['status']) !== 1) {
  54. util::fail('公告已下架');
  55. }
  56. util::success(ShopNoticeClass::getDetail($id));
  57. }
  58. }