| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <?php
- /**
- * Niushop商城系统 - 团队十年电商经验汇集巨献!
- * =========================================================
- * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
- * ----------------------------------------------
- * 官方网址: https://www.niushop.com
- * =========================================================
- */
- namespace app\model\web;
- use think\facade\Cache;
- use app\model\BaseModel;
- /**
- * 公告管理
- * @author Administrator
- *
- */
- class Notice extends BaseModel
- {
- /**
- * 添加公告
- * @param unknown $data
- */
- public function addNotice($data)
- {
- $data[ 'create_time' ] = time();
- $res = model('notice')->add($data);
- Cache::tag("notice")->clear();
- return $this->success($res);
- }
- /**
- * 修改公告
- * @param $data
- * @param $condition
- * @return array
- */
- public function editNotice($data, $condition)
- {
- $data[ 'modify_time' ] = time();
- $res = model('notice')->update($data, $condition);
- Cache::tag("notice")->clear();
- return $this->success($res);
- }
- /**
- * 删除公告
- * @param array $condition
- */
- public function deleteNotice($condition)
- {
- $res = model('notice')->delete($condition);
- Cache::tag("notice")->clear();
- return $this->success($res);
- }
- /**
- * 获取公告数量
- * @param $condition
- * @return array
- */
- public function getNoticeCount($condition)
- {
- $count = model('notice')->getCount($condition);
- return $this->success($count);
- }
- /**
- * 获取公告信息
- * @param array $condition
- * @param string $field
- */
- public function getNoticeInfo($condition, $field = 'id, title, content, create_time, modify_time, is_top,receiving_type,receiving_name')
- {
- $data = json_encode([ $condition, $field ]);
- $cache = Cache::get("notice_getNoticeInfo_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $res = model('notice')->getInfo($condition, $field);
- Cache::tag("notice")->set("notice_getNoticeInfo_" . $data, $res);
- return $this->success($res);
- }
- /**
- * 获取公告列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param string $limit
- */
- public function getNoticeList($condition = [], $field = 'id, title, content, create_time, modify_time, is_top,receiving_type,receiving_name', $order = '', $limit = null)
- {
- $data = json_encode([ $condition, $field, $order, $limit ]);
- $cache = Cache::get("notice_getNoticeList_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $list = model('notice')->getList($condition, $field, $order, '', '', '', $limit);
- Cache::tag("notice")->set("notice_getNoticeList_" . $data, $list);
- return $this->success($list);
- }
- /**
- * 获取公告分页列表
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function getNoticePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'is_top desc,create_time desc', $field = 'id, title,content, create_time, is_top,receiving_type,receiving_name,sort')
- {
- $data = json_encode([ $condition, $field, $order, $page, $page_size ]);
- $cache = Cache::get("notice_getNoticePageList_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $list = model('notice')->pageList($condition, $field, $order, $page, $page_size);
- Cache::tag("notice")->set("notice_getNoticePageList_" . $data, $list);
- return $this->success($list);
- }
- /**
- * 修改标签排序
- * @param $sort
- * @param $id
- * @return array
- */
- public function modifyNoticeSort($sort, $id)
- {
- $res = model('notice')->update([ 'sort' => $sort ], [ [ 'id', '=', $id ] ]);
- Cache::tag("notice")->clear();
- return $this->success($res);
- }
- /**
- * 生成推广二维码链接
- * @param $qrcode_param
- * @param $site_id
- * @return array
- */
- public function urlQrcode($qrcode_param, $site_id)
- {
- $h5_page = '/pages_tool/notice/detail';
- $pc_page = '/cms/notice/detail';
- $params = [
- 'site_id' => $site_id,
- 'data' => $qrcode_param,
- 'pc_data' => [ 'id' => $qrcode_param[ 'notice_id' ] ],
- 'page' => $h5_page,
- 'h5_path' => $h5_page . '?notice_id=' . $qrcode_param[ 'notice_id' ],
- 'pc_page' => $pc_page,
- 'pc_path' => $pc_page . '?id=' . $qrcode_param[ 'notice_id' ],
- 'qrcode_path' => 'upload/qrcode/notice',
- 'qrcode_name' => [
- 'h5_name' => 'notice_qrcode' . '_h5_' . $qrcode_param[ 'notice_id' ] . '_' . $site_id,
- 'weapp_name' => 'notice_qrcode' . '_weapp_' . $qrcode_param[ 'notice_id' ] . '_' . $site_id,
- 'pc_name' => 'notice_qrcode' . '_pc_' . $qrcode_param[ 'notice_id' ] . '_' . $site_id
- ]
- ];
- $solitaire = event('ExtensionInformation', $params);
- return $this->success($solitaire[ 0 ]);
- }
- }
|