| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace mall\controllers;
- use bizHd\shop\classes\ShopNoticeClass;
- use common\components\util;
- use Yii;
- /**
- * 商城客户端:门店通知公告(xhShopNotice)
- */
- class ShopNoticeController extends BaseController
- {
- /**
- * 客户端公告列表(仅上架、未删除)
- * GET /shop-notice/show-list?position=2
- */
- public function actionShowList()
- {
- $user = $this->user;
- if (empty($user) || empty($this->mainId)) {
- util::success([
- 'totalNum' => 0,
- 'totalPage' => 0,
- 'moreData' => 0,
- 'list' => [],
- ]);
- }
- $get = Yii::$app->request->get();
- $list = ShopNoticeClass::searchList([
- 'mainId' => $this->mainId,
- 'title' => $get['title'] ?? '',
- 'position' => $get['position'] ?? '',
- 'isDel' => 0,
- 'status' => 1,
- 'order' => 'sort DESC, id DESC',
- ]);
- util::success($list);
- }
- /**
- * 客户端公告详情
- * GET /shop-notice/detail?id=
- */
- public function actionDetail()
- {
- $user = $this->user;
- if (empty($user) || empty($this->mainId)) {
- util::fail('请先登录哈');
- }
- $id = intval(Yii::$app->request->get('id', 0));
- if ($id <= 0) {
- util::fail('公告id不对');
- }
- $info = ShopNoticeClass::getById($id);
- ShopNoticeClass::valid($info, $this->mainId);
- if (intval($info['status']) !== 1) {
- util::fail('公告已下架');
- }
- util::success(ShopNoticeClass::getDetail($id));
- }
- }
|