| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <?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 Help extends BaseModel
- {
- /****************************************************************帮助文章******************************************/
- /**
- * 添加帮助文章
- * @param array $data
- */
- public function addHelp($data)
- {
- $help_id = model('help')->add($data);
- Cache::tag("help")->clear();
- return $this->success($help_id);
- }
- /**
- * 修改帮助文章
- * @param array $data
- */
- public function editHelp($data, $condition)
- {
- $res = model('help')->update($data, $condition);
- Cache::tag("help")->clear();
- return $this->success($res);
- }
- /**
- * 删除文章
- * @param unknown $coupon_type_id
- */
- public function deleteHelp($condition)
- {
- $res = model('help')->delete($condition);
- Cache::tag("help")->clear();
- return $this->success($res);
- }
- /**
- * 获取帮助文章详情
- * @param int $help_id
- * @return multitype:string mixed
- */
- public function getHelpInfo($help_id)
- {
- $cache = Cache::get("help_getHelpInfo_" . $help_id);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $res = model('help')->getInfo([ [ 'id', '=', $help_id ] ], 'id, title, content, class_id, class_name, sort, link_address, create_time, modify_time');
- Cache::tag("help")->set("help_getHelpInfo_" . $help_id, $res);
- return $this->success($res);
- }
- /**
- * 获取菜单列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param string $limit
- */
- public function getHelpList($condition = [], $field = 'id, title, content, class_id, class_name, sort, create_time', $order = '', $limit = null)
- {
- $data = json_encode([ $condition, $field, $order, $limit ]);
- $cache = Cache::get("help_getHelpList_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $list = model('help')->getList($condition, $field, $order, '', '', '', $limit);
- Cache::tag("help")->set("help_getHelpList_" . $data, $list);
- return $this->success($list);
- }
- /**
- * 获取帮助文章分页列表
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function getHelpPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'sort asc,create_time desc', $field = 'id, title, content, class_id, class_name, sort, link_address, create_time')
- {
- $data = json_encode([ $condition, $field, $order, $page, $page_size ]);
- $cache = Cache::get("help_getHelpPageList_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $list = model('help')->pageList($condition, $field, $order, $page, $page_size);
- Cache::tag("help")->set("help_getHelpList_" . $data, $list);
- return $this->success($list);
- }
- /**
- * 修改排序
- * @param int $sort
- * @param int $help_id
- */
- public function modifyHelpSort($sort, $help_id)
- {
- $res = model('help')->update([ 'sort' => $sort ], [ [ 'id', '=', $help_id ] ]);
- Cache::tag('help')->clear();
- return $this->success($res);
- }
- /****************************************************************帮助文章表******************************************/
- /**
- * 添加帮助类型
- * @param array $data
- */
- public function addHelpClass($data)
- {
- $model = model('help_class');
- $res = $model->add($data);
- if ($res) {
- Cache::tag("help_class")->clear();
- return $this->success($res);
- } else {
- return $this->error($res);
- }
- }
- /**
- * 修改帮助类型(主键修改,不修改排序)
- * @param array $data
- * @param int $class_id
- */
- public function editHelpClass($data, $class_id)
- {
- $res = model('help_class')->update($data, [ [ 'class_id', '=', $class_id ] ]);
- if ($res !== false) {
- Cache::tag("help_class")->clear();
- model('help')->update([ 'class_name' => $data[ 'class_name' ] ], [ [ 'class_id', '=', $class_id ] ]);
- Cache::tag("help")->clear();
- return $this->success($res);
- } else {
- return $this->error($res);
- }
- }
- /**
- * 获取帮助文章分类详情
- * @param array $condition
- * @param string $field
- */
- public function getHelpClassInfo($condition, $field = 'class_id, class_name, sort')
- {
- $data = json_encode([ $condition, $field ]);
- $cache = Cache::get("help_class_getHelpClassInfo_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $res = model('help_class')->getInfo($condition, $field);
- Cache::tag("help_class")->set("help_class_getHelpClassInfo_" . $data, $res);
- return $this->success($res);
- }
- /**
- * 获取帮助文章分类分页列表
- * @param array $condition
- * @param number $page
- * @param number $page_size
- * @param string $order
- * @param string $field
- */
- public function getHelpClassPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'sort asc,create_time desc', $field = 'class_id, class_name, sort')
- {
- $data = json_encode([ $condition, $field, $order, $page, $page_size ]);
- $cache = Cache::get("help_class_getHelpClassInfo_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $res = model('help_class')->pageList($condition, $field, $order, $page, $page_size);
- $check_condition = array_column($condition, 2, 0);
- if ($check_condition) {
- unset($check_condition[ 'class_name' ]);
- }
- $help_data = model('help')->getList($check_condition, 'class_id');
- $arr = [];
- if ($help_data) {
- $arr = array_column($help_data, 'class_id');
- $arr = array_unique($arr);
- }
- if ($res[ 'list' ]) {
- foreach ($res[ 'list' ] as $k => $v) {
- if (in_array($v[ 'class_id' ], $arr)) {
- $res[ 'list' ][ $k ][ 'child' ] = 1;
- } else {
- $res[ 'list' ][ $k ][ 'child' ] = 0;
- }
- }
- }
- Cache::tag("help_class")->set("help_class_getHelpClassPageList_" . $data, $res);
- return $this->success($res);
- }
- /**
- * 获取帮助文章分类列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param number $limit
- */
- public function getHelpClassList($condition = [], $field = 'class_id, class_name, sort', $order = '', $limit = null)
- {
- $data = json_encode([ $condition, $field, $order, $limit ]);
- $cache = Cache::get("help_class_getHelpClassList_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $res = model('help_class')->getList($condition, $field, $order, $alias = 'a', $join = [], $group = '', $limit);
- Cache::tag("help_class")->set("help_class_getHelpClassList_" . $data, $res);
- return $this->success($res);
- }
- /**
- * 删除帮助文章分类
- * @param array $condition
- */
- public function deleteHelpClass($condition)
- {
- $model = model('help_class');
- $res = $model->delete($condition);
- Cache::tag("help_class")->clear();
- if ($res) {
- return $this->success($res);
- } else {
- return $this->error($res);
- }
- }
- /**
- * 修改排序
- * @param int $sort
- * @param int $class_id
- */
- public function modifyHelpClassSort($sort, $class_id)
- {
- $res = model('help_class')->update([ 'sort' => $sort ], [ [ 'class_id', '=', $class_id ] ]);
- Cache::tag('help_class')->clear();
- return $this->success($res);
- }
- /**
- * 生成推广二维码链接
- * @param $qrcode_param
- * @param $site_id
- * @return array
- */
- public function urlQrcode($qrcode_param, $site_id)
- {
- $h5_page = '/pages_tool/help/detail';
- $pc_page = '/cms/help/detail';
- $params = [
- 'site_id' => $site_id,
- 'data' => $qrcode_param,
- 'pc_data' => $qrcode_param,
- 'page' => $h5_page,
- 'h5_path' => $h5_page . '?id=' . $qrcode_param[ 'id' ],
- 'pc_page' => $pc_page,
- 'pc_path' => $pc_page . '?id=' . $qrcode_param[ 'id' ],
- 'qrcode_path' => 'upload/qrcode/help',
- 'qrcode_name' => [
- 'h5_name' => 'help_qrcode' . '_h5_' . $qrcode_param[ 'id' ] . '_' . $site_id,
- 'weapp_name' => 'help_qrcode' . '_weapp_' . $qrcode_param[ 'id' ] . '_' . $site_id,
- 'pc_name' => 'help_qrcode' . '_pc_' . $qrcode_param[ 'id' ] . '_' . $site_id
- ]
- ];
- $solitaire = event('ExtensionInformation', $params);
- return $this->success($solitaire[ 0 ]);
- }
- }
|