| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace hd\controllers;
- use bizHd\shop\classes\ShopNoticeClass;
- use common\components\util;
- use Yii;
- /**
- * 零售花店通知公告
- */
- class ShopNoticeController extends BaseController
- {
- /**
- * 管理端公告列表
- */
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $list = ShopNoticeClass::searchList([
- 'mainId' => $this->mainId,
- 'title' => $get['title'] ?? '',
- 'isDel' => 0,
- 'order' => 'id DESC',
- ]);
- util::success($list);
- }
- /**
- * 客户端公告列表(仅显示中的公告)
- */
- public function actionShowList()
- {
- $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);
- }
- /**
- * 新增公告
- */
- public function actionAdd()
- {
- $post = Yii::$app->request->post();
- $post['mainId'] = $this->mainId;
- $post['staffId'] = intval($this->shopAdminId);
- $id = ShopNoticeClass::addNotice($post);
- $info = ShopNoticeClass::getDetail($id);
- util::success($info);
- }
- /**
- * 更新公告
- */
- public function actionUpdate()
- {
- $post = Yii::$app->request->post();
- $id = intval($post['id'] ?? 0);
- if ($id <= 0) {
- util::fail('公告id不对');
- }
- $info = ShopNoticeClass::getById($id);
- ShopNoticeClass::valid($info, $this->mainId);
- $post['staffId'] = intval($this->shopAdminId);
- ShopNoticeClass::updateNotice($id, $post);
- util::complete('修改成功');
- }
- /**
- * 公告详情
- */
- public function actionDetail()
- {
- $id = intval(Yii::$app->request->get('id', 0));
- if ($id <= 0) {
- util::fail('公告id不对');
- }
- $info = ShopNoticeClass::getById($id);
- ShopNoticeClass::valid($info, $this->mainId);
- util::success(ShopNoticeClass::getDetail($id));
- }
- /**
- * 软删除公告
- */
- public function actionDelete()
- {
- $id = intval(Yii::$app->request->post('id', Yii::$app->request->get('id', 0)));
- if ($id <= 0) {
- util::fail('公告id不对');
- }
- $info = ShopNoticeClass::getById($id);
- ShopNoticeClass::valid($info, $this->mainId);
- ShopNoticeClass::deleteNotice($id, intval($this->shopAdminId));
- util::complete('删除成功');
- }
- /**
- * 上下架公告
- */
- public function actionUpdateStatus()
- {
- $id = intval(Yii::$app->request->post('id', Yii::$app->request->get('id', 0)));
- $status = intval(Yii::$app->request->post('status', Yii::$app->request->get('status', 0)));
- if ($id <= 0) {
- util::fail('公告id不对');
- }
- $info = ShopNoticeClass::getById($id);
- ShopNoticeClass::valid($info, $this->mainId);
- ShopNoticeClass::updateStatus($id, $status, intval($this->shopAdminId));
- util::complete('操作成功');
- }
- }
|