From cf6738ab4b1c1ba111316693741529ffe1416a18 Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Sun, 23 Dec 2018 02:39:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=EF=BC=8C=E6=B6=88=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E4=BB=98=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Agreement.php | 67 --- application/admin/controller/Article.php | 403 +++++------------ .../admin/controller/ArticleCategory.php | 110 +---- application/admin/controller/Message.php | 200 +++------ application/admin/controller/Navigation.php | 3 +- application/admin/controller/PayLog.php | 159 ++----- .../admin/view/default/article/index.html | 62 +-- .../admin/view/default/article/save_info.html | 26 +- .../index.html | 10 +- .../admin/view/default/brand/index.html | 6 +- .../admin/view/default/message/index.html | 50 +-- .../admin/view/default/paylog/index.html | 44 +- application/index/controller/Article.php | 15 +- application/index/controller/Index.php | 3 +- application/index/controller/Message.php | 2 +- .../index/view/default/article/index.html | 2 +- .../index/view/default/index/index.html | 2 +- application/service/ArticleService.php | 412 +++++++++++++++++- application/service/CustomViewService.php | 2 +- application/service/MessageService.php | 154 ++++++- application/service/PayLogService.php | 164 +++++++ 21 files changed, 1054 insertions(+), 842 deletions(-) delete mode 100755 application/admin/controller/Agreement.php rename application/admin/view/default/{article_category => articlecategory}/index.html (87%) create mode 100644 application/service/PayLogService.php diff --git a/application/admin/controller/Agreement.php b/application/admin/controller/Agreement.php deleted file mode 100755 index 924285c20..000000000 --- a/application/admin/controller/Agreement.php +++ /dev/null @@ -1,67 +0,0 @@ -Is_Login(); - - // 权限校验 - $this->Is_Power(); - } - - /** - * [Index 配置列表] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-06T21:31:53+0800 - */ - public function Index() - { - // 配置信息 - $data = db('Config')->getField('only_tag,name,describe,value,error_tips'); - $this->assign('data', $data); - $type = I('type', 'kehu'); - $this->assign('nav_type', $type); - if($type == 'kehu') - { - $this->display('Kehu'); - } else { - $this->display('Shanghu'); - } - } - - /** - * [Save 配置数据保存] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2017-01-02T23:08:19+0800 - */ - public function Save() - { - $this->MyConfigSave(); - } -} -?> \ No newline at end of file diff --git a/application/admin/controller/Article.php b/application/admin/controller/Article.php index 29d80abfc..8883de087 100755 --- a/application/admin/controller/Article.php +++ b/application/admin/controller/Article.php @@ -1,8 +1,7 @@ GetIndexWhere(); - - // 分页 - $number = MyC('admin_page_number'); - $page_param = array( - 'number' => $number, - 'total' => $m->where($where)->count(), - 'where' => $param, - 'url' => url('Admin/Article/Index'), - ); - $page = new \base\Page($page_param); - - // 获取列表 - $list = $this->SetDataHandle($m->where($where)->limit($page->GetPageStarNumber(), $number)->order('id desc')->select()); - - // 是否启用 + $params = input(); + + // 分页 + $number = MyC('admin_page_number', 10, true); + + // 条件 + $where = ArticleService::ArticleListWhere($params); + + // 获取总数 + $total = ArticleService::ArticleTotal($where); + + // 分页 + $page_params = array( + 'number' => $number, + 'total' => $total, + 'where' => $params, + 'page' => isset($params['page']) ? intval($params['page']) : 1, + 'url' => url('admin/article/index'), + ); + $page = new \base\Page($page_params); + $this->assign('page_html', $page->GetPageHtml()); + + // 获取列表 + $data_params = array( + 'm' => $page->GetPageStarNumber(), + 'n' => $number, + 'where' => $where, + 'field' => 'a.*', + ); + $data = ArticleService::ArticleList($data_params); + $this->assign('data_list', $data['data']); + + // 是否启用 $this->assign('common_is_enable_list', lang('common_is_enable_list')); // 是否 $this->assign('common_is_text_list', lang('common_is_text_list')); - // 文章分类 - $this->assign('article_category_list', db('ArticleCategory')->field(array('id', 'name'))->where(array('is_enable'=>1))->select()); - - // 参数 - $this->assign('param', $param); - - // 分页 - $this->assign('page_html', $page->GetPageHtml()); - - // 数据列表 - $this->assign('list', $list); + // 文章分类 + $article_category = ArticleService::ArticleCategoryList(['field'=>'id,name']); + $this->assign('article_category_list', $article_category['data']); - $this->display('Index'); - } - - /** - * [SetDataHandle 数据处理] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-29T21:27:15+0800 - * @param [array] $data [文章数据] - * @return [array] [处理好的数据] - */ - private function SetDataHandle($data) - { - if(!empty($data)) - { - $ac = db('ArticleCategory'); - foreach($data as &$v) - { - // 时间 - $v['add_time'] = date('Y-m-d H:i:s', $v['add_time']); - $v['upd_time'] = date('Y-m-d H:i:s', $v['upd_time']); - - // 是否启用 - $v['is_enable_text'] = lang('common_is_enable_list')[$v['is_enable']]['name']; - - // 文章分类 - $v['article_category_name'] = $ac->where(array('id'=>$v['article_category_id']))->getField('name'); - - // url - $v['url'] = HomeUrl('Article', 'Index', ['id'=>$v['id']]); - } - } - return $data; - } - - /** - * [GetIndexWhere 文章列表条件] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-10T22:16:29+0800 - */ - private function GetIndexWhere() - { - $where = array(); - - // 模糊 - if(!empty($_REQUEST['keyword'])) - { - $where[] = array( - 'title' => array('like', '%'.I('keyword').'%'), - ); - } - - // 是否更多条件 - if(I('is_more', 0) == 1) - { - // 等值 - if(I('is_enable', -1) > -1) - { - $where['is_enable'] = intval(I('is_enable', 1)); - } - if(I('article_category_id', -1) > -1) - { - $where['article_category_id'] = intval(I('article_category_id')); - } - if(I('is_home_recommended', -1) > -1) - { - $where['is_home_recommended'] = intval(I('is_home_recommended', 1)); - } - - // 表达式 - if(!empty($_REQUEST['time_start'])) - { - $where['add_time'][] = array('gt', strtotime(I('time_start'))); - } - if(!empty($_REQUEST['time_end'])) - { - $where['add_time'][] = array('lt', strtotime(I('time_end'))); - } - } - return $where; + // 参数 + $this->assign('params', $params); + return $this->fetch(); } /** @@ -175,27 +97,37 @@ class Article extends Common */ public function SaveInfo() { - // 文章信息 - if(empty($_REQUEST['id'])) - { - $data = array(); - } else { - $data = db('Article')->find(I('id')); - if(!empty($data['content'])) - { - // 静态资源地址处理 - $data['content'] = ResourcesService::ContentStaticReplace($data['content'], 'get'); - } - } - $this->assign('data', $data); + // 参数 + $params = input(); + + // 数据 + if(!empty($params['id'])) + { + // 获取列表 + $data_params = array( + 'm' => 0, + 'n' => 1, + 'where' => ['a.id'=>intval($params['id'])], + 'field' => 'a.*', + ); + $data = ArticleService::ArticleList($data_params); + $this->assign('data', empty($data['data'][0]) ? [] : $data['data'][0]); + } // 是否启用 $this->assign('common_is_enable_list', lang('common_is_enable_list')); // 文章分类 - $this->assign('article_category_list', db('ArticleCategory')->field(array('id', 'name'))->where(array('is_enable'=>1))->select()); + $article_category = ArticleService::ArticleCategoryList(['field'=>'id,name']); + $this->assign('article_category_list', $article_category['data']); - $this->display('SaveInfo'); + // 参数 + $this->assign('params', $params); + + // 编辑器文件存放地址 + $this->assign('editor_path_type', 'article'); + + return $this->fetch(); } /** @@ -208,124 +140,15 @@ class Article extends Common public function Save() { // 是否ajax请求 - if(!IS_AJAX) - { - $this->error('非法访问'); - } - - // 数据处理 - $_POST['is_enable'] = isset($_POST['is_enable']) ? intval($_POST['is_enable']) : 0; - - // 添加 - if(empty($_POST['id'])) - { - $this->Add(); - - // 编辑 - } else { - $this->Edit(); - } - } - - /** - * [Add 文章添加] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-18T16:20:59+0800 - */ - private function Add() - { - // 文章模型 - $m = D('Article'); - - // 数据自动校验 - if($m->create($_POST, 1)) - { - // 额外数据处理 - $m->add_time = time(); - $m->upd_time = time(); - $m->title = I('title'); - - // 静态资源地址处理 - $m->content = ResourcesService::ContentStaticReplace($m->content, 'add'); - - // 正则匹配文章图片 - $temp_image = $this->MatchContentImage($m->content); - $m->image = json_encode($temp_image); - $m->image_count = count($temp_image); - $m->is_home_recommended = intval(I('is_home_recommended', 0)); - - // 数据添加 - if($m->add()) - { - $this->ajaxReturn('新增成功'); - } else { - $this->ajaxReturn('新增失败', -100); - } - } else { - $this->ajaxReturn($m->getError(), -1); - } - } - - /** - * [Edit 文章编辑] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-17T22:13:40+0800 - */ - private function Edit() - { - // 文章模型 - $m = D('Article'); - - // 数据自动校验 - if($m->create($_POST, 2)) - { - // 额外数据处理 - $m->upd_time = time(); - $m->title = I('title'); - - // 静态资源地址处理 - $m->content = ResourcesService::ContentStaticReplace($m->content, 'add'); - - // 正则匹配文章图片 - $temp_image = $this->MatchContentImage($m->content); - $m->image = json_encode($temp_image); - $m->image_count = count($temp_image); - $m->is_home_recommended = intval(I('is_home_recommended', 0)); - - // 数据更新 - if($m->where(array('id'=>I('id')))->save()) - { - $this->ajaxReturn('编辑成功'); - } else { - $this->ajaxReturn('编辑失败或数据未改变', -100); - } - } else { - $this->ajaxReturn($m->getError(), -1); - } - } - - /** - * [MatchContentImage 正则匹配文章图片] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2017-01-22T18:06:53+0800 - * @param [string] $content [文章内容] - * @return [array] [文章图片数组(一维)] - */ - private function MatchContentImage($content) - { - if(!empty($content)) - { - $pattern = '//'; - preg_match_all($pattern, $content, $match); - return empty($match[1]) ? array() : $match[1]; - } - return array(); + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始处理 + $params = input(); + $ret = ArticleService::ArticleSave($params); + return json($ret); } /** @@ -338,24 +161,16 @@ class Article extends Common public function Delete() { // 是否ajax请求 - if(!IS_AJAX) - { - $this->error('非法访问'); - } - - // 删除数据 - if(!empty($_POST['id'])) - { - // 更新 - if(db('Article')->delete(I('id'))) - { - $this->ajaxReturn('删除成功'); - } else { - $this->ajaxReturn('删除失败或资源不存在', -100); - } - } else { - $this->ajaxReturn('参数错误', -1); - } + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始处理 + $params = input(); + $params['admin'] = $this->admin; + $ret = ArticleService::ArticleDelete($params); + return json($ret); } /** @@ -367,19 +182,18 @@ class Article extends Common */ public function StatusUpdate() { - // 参数 - if(empty($_POST['id']) || !isset($_POST['state'])) - { - $this->ajaxReturn('参数错误', -1); - } - - // 数据更新 - if(db('Article')->where(array('id'=>I('id')))->save(array('is_enable'=>I('state')))) - { - $this->ajaxReturn('编辑成功'); - } else { - $this->ajaxReturn('编辑失败或数据未改变', -100); - } + // 是否ajax请求 + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始处理 + $params = input(); + $params['admin'] = $this->admin; + $params['field'] = 'is_enable'; + $ret = ArticleService::ArticleStatusUpdate($params); + return json($ret); } /** @@ -391,19 +205,18 @@ class Article extends Common */ public function StatusHomeRecommended() { - // 参数 - if(empty($_POST['id']) || !isset($_POST['state'])) - { - $this->ajaxReturn('参数错误', -1); - } - - // 数据更新 - if(db('Article')->where(array('id'=>I('id')))->save(array('is_home_recommended'=>I('state')))) - { - $this->ajaxReturn('编辑成功'); - } else { - $this->ajaxReturn('编辑失败或数据未改变', -100); - } + // 是否ajax请求 + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始处理 + $params = input(); + $params['admin'] = $this->admin; + $params['field'] = 'is_home_recommended'; + $ret = ArticleService::ArticleStatusUpdate($params); + return json($ret); } } ?> \ No newline at end of file diff --git a/application/admin/controller/ArticleCategory.php b/application/admin/controller/ArticleCategory.php index 3e4abc36a..2fbd96295 100755 --- a/application/admin/controller/ArticleCategory.php +++ b/application/admin/controller/ArticleCategory.php @@ -1,7 +1,8 @@ assign('common_is_enable_list', lang('common_is_enable_list')); - $this->display('Index'); + + return $this->fetch(); } /** @@ -58,39 +61,9 @@ class ArticleCategory extends Common $this->error('非法访问'); } - // 获取数据 - $field = array('id', 'name', 'sort', 'is_enable'); - $data = db('ArticleCategory')->field($field)->where(array('pid'=>intval(I('id', 0))))->select(); - if(!empty($data)) - { - foreach($data as $k=>$v) - { - $data[$k]['is_son'] = $this->IsExistSon($v['id']); - $data[$k]['ajax_url'] = url('Admin/ArticleCategory/GetNodeSon', array('id'=>$v['id'])); - $data[$k]['delete_url'] = url('Admin/ArticleCategory/Delete'); - $data[$k]['json'] = json_encode($v); - } - } - $msg = empty($data) ? '没有相关数据' : '操作成功'; - $this->ajaxReturn($msg, 0, $data); - } - - /** - * [IsExistSon 节点是否存在子数据] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-25T15:22:47+0800 - * @param [int] $id [节点id] - * @return [string] [有数据ok, 则no] - */ - private function IsExistSon($id) - { - if(!empty($id)) - { - return (db('ArticleCategory')->where(array('pid'=>$id))->count() > 0) ? 'ok' : 'no'; - } - return 'no'; + // 开始操作 + $ret = ArticleService::ArticleCategoryNodeSon(input()); + return json($ret); } /** @@ -108,50 +81,9 @@ class ArticleCategory extends Common $this->error('非法访问'); } - // id为空则表示是新增 - $m = D('ArticleCategory'); - - // 公共额外数据处理 - $m->sort = intval(I('sort')); - - // 添加 - if(empty($_POST['id'])) - { - if($m->create($_POST, 1)) - { - // 额外数据处理 - $m->add_time = time(); - $m->name = I('name'); - - // 写入数据库 - if($m->add()) - { - $this->ajaxReturn('新增成功'); - } else { - $this->ajaxReturn('新增失败', -100); - } - } - } else { - // 编辑 - if($m->create($_POST, 2)) - { - // 额外数据处理 - $m->name = I('name'); - $m->upd_time = time(); - - // 移除 id - unset($m->id); - - // 更新数据库 - if($m->where(array('id'=>I('id')))->save()) - { - $this->ajaxReturn('编辑成功'); - } else { - $this->ajaxReturn('编辑失败或数据未改变', -100); - } - } - } - $this->ajaxReturn($m->getError(), -1); + // 开始操作 + $ret = ArticleService::ArticleCategorySave(input()); + return json($ret); } /** @@ -163,23 +95,17 @@ class ArticleCategory extends Common */ public function Delete() { + // 是否ajax if(!IS_AJAX) { - $this->error('非法访问'); + return $this->error('非法访问'); } - $m = D('ArticleCategory'); - if($m->create($_POST, 5)) - { - if($m->delete(I('id'))) - { - $this->ajaxReturn('删除成功'); - } else { - $this->ajaxReturn('删除失败或资源不存在', -100); - } - } else { - $this->ajaxReturn($m->getError(), -1); - } + // 开始操作 + $params = input('post.'); + $params['admin'] = $this->admin; + $ret = ArticleService::ArticleCategoryDelete($params); + return json($ret); } } ?> \ No newline at end of file diff --git a/application/admin/controller/Message.php b/application/admin/controller/Message.php index 8e106127e..3c513d7d7 100755 --- a/application/admin/controller/Message.php +++ b/application/admin/controller/Message.php @@ -1,7 +1,8 @@ GetIndexWhere(); - - // 模型 - $m = db('Message'); - - // 分页 - $number = MyC('admin_page_number'); - $page_param = array( - 'number' => $number, - 'total' => $m->alias('m')->join('__USER__ AS u ON u.id=m.user_id')->where($where)->count(), - 'where' => $param, - 'url' => url('Admin/Message/Index'), - ); - $page = new \base\Page($page_param); - - // 获取列表 - $field = 'm.*,u.username,u.nickname,u.mobile,u.gender'; - $list = $this->SetDataHandle($m->alias('m')->join('__USER__ AS u ON u.id=m.user_id')->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('m.id desc')->select()); + $params = input(); + $params['user'] = $this->admin; + $params['user_type'] = 'admin'; + + // 消息更新未已读 + MessageService::MessageRead($params); + + // 分页 + $number = MyC('admin_page_number', 10, true); + + // 条件 + $where = MessageService::AdminMessageListWhere($params); + + // 获取总数 + $total = MessageService::AdminMessageTotal($where); + + // 分页 + $page_params = array( + 'number' => $number, + 'total' => $total, + 'where' => $params, + 'page' => isset($params['page']) ? intval($params['page']) : 1, + 'url' => url('admin/message/index'), + ); + $page = new \base\Page($page_params); + $this->assign('page_html', $page->GetPageHtml()); + + // 获取列表 + $data_params = array( + 'm' => $page->GetPageStarNumber(), + 'n' => $number, + 'where' => $where, + ); + $data = MessageService::AdminMessageList($data_params); + $this->assign('data_list', $data['data']); // 性别 $this->assign('common_gender_list', lang('common_gender_list')); @@ -72,103 +87,8 @@ class Message extends Common $this->assign('common_is_read_list', lang('common_is_read_list')); // 参数 - $this->assign('param', $param); - - // 分页 - $this->assign('page_html', $page->GetPageHtml()); - - // 数据列表 - $this->assign('list', $list); - $this->display('Index'); - } - - /** - * [SetDataHandle 数据处理] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-29T21:27:15+0800 - * @param [array] $data [消息数据] - * @return [array] [处理好的数据] - */ - private function SetDataHandle($data) - { - if(!empty($data)) - { - $common_gender_list = lang('common_gender_list'); - $common_is_read_list = lang('common_is_read_list'); - $common_message_type_list = lang('common_message_type_list'); - foreach($data as &$v) - { - // 消息类型 - $v['type_text'] = $common_message_type_list[$v['type']]['name']; - - // 是否已读 - $v['is_read_text'] = $common_is_read_list[$v['is_read']]['name']; - - // 性别 - $v['gender_text'] = $common_gender_list[$v['gender']]['name']; - - // 添加时间 - $v['add_time'] = date('Y-m-d H:i:s', $v['add_time']); - } - } - return $data; - } - - /** - * [GetIndexWhere 消息列表条件] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-10T22:16:29+0800 - */ - private function GetIndexWhere() - { - $where = array('m.is_delete_time'=>0); - - // 模糊 - if(!empty($_REQUEST['keyword'])) - { - $like_keyword = array('like', '%'.I('keyword').'%'); - $where[] = array( - 'u.username' => $like_keyword, - 'u.nickname' => $like_keyword, - 'u.mobile' => $like_keyword, - 'm.title' => $like_keyword, - '_logic' => 'or', - ); - } - - // 是否更多条件 - if(I('is_more', 0) == 1) - { - // 等值 - if(I('type', -1) > -1) - { - $where['m.type'] = intval(I('type', 0)); - } - if(I('is_read', -1) > -1) - { - $where['m.is_read'] = intval(I('is_read', 0)); - } - if(I('gender', -1) > -1) - { - $where['u.gender'] = intval(I('gender', 0)); - } - - // 表达式 - if(!empty($_REQUEST['time_start'])) - { - $where['m.add_time'][] = array('gt', strtotime(I('time_start'))); - } - if(!empty($_REQUEST['time_end'])) - { - $where['m.add_time'][] = array('lt', strtotime(I('time_end'))); - } - } - - return $where; + $this->assign('params', $params); + return $this->fetch(); } /** @@ -181,38 +101,16 @@ class Message extends Common public function Delete() { // 是否ajax请求 - if(!IS_AJAX) - { - $this->error('非法访问'); - } - - // 参数处理 - $id = I('id'); - - // 删除数据 - if(!empty($id)) - { - // 消息模型 - $m = db('Message'); - - // 消息是否存在 - $user = $m->where(array('id'=>$id))->getField('id'); - if(empty($user)) - { - $this->ajaxReturn('资源不存在或已被删除', -2); - } - - // 删除消息 - $status = $m->where(array('id'=>$id))->save(['is_delete_time'=>time()]); - if($status !== false) - { - $this->ajaxReturn('删除成功'); - } else { - $this->ajaxReturn('删除失败或资源不存在', -100); - } - } else { - $this->ajaxReturn('参数错误', -1); - } + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始处理 + $params = input(); + $params['admin'] = $this->admin; + $ret = MessageService::MessageDelete($params); + return json($ret); } } ?> \ No newline at end of file diff --git a/application/admin/controller/Navigation.php b/application/admin/controller/Navigation.php index 13305de41..addfa2044 100755 --- a/application/admin/controller/Navigation.php +++ b/application/admin/controller/Navigation.php @@ -54,7 +54,8 @@ class Navigation extends Common $this->assign('nav_header_pid_list', NavigationService::LevelOneNav(['nav_type'=>$this->nav_type])); // 获取分类和文章 - $this->assign('article_list', ArticleService::ArticleCategoryList()); + $article_category_content = ArticleService::ArticleCategoryListContent(); + $this->assign('article_list', $article_category_content['data']); // 商品分类 $this->assign('goods_category_list', GoodsService::GoodsCategory()); diff --git a/application/admin/controller/PayLog.php b/application/admin/controller/PayLog.php index ca4c2e7d0..142c7a9b8 100755 --- a/application/admin/controller/PayLog.php +++ b/application/admin/controller/PayLog.php @@ -1,7 +1,8 @@ GetIndexWhere(); - - // 模型 - $m = db('PayLog'); - - // 分页 - $number = MyC('admin_page_number'); - $page_param = array( - 'number' => $number, - 'total' => $m->alias('p')->join('__USER__ AS u ON u.id=p.user_id')->where($where)->count(), - 'where' => $param, - 'url' => url('Admin/PayLog/Index'), - ); - $page = new \base\Page($page_param); - - // 获取列表 - $field = 'p.*,u.username,u.nickname,u.mobile,u.gender'; - $list = $this->SetDataHandle($m->alias('p')->join('__USER__ AS u ON u.id=p.user_id')->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('p.id desc')->select()); + $params = input(); + $params['user'] = $this->admin; + $params['user_type'] = 'admin'; + + // 分页 + $number = MyC('admin_page_number', 10, true); + + // 条件 + $where = PayLogService::AdminPayLogListWhere($params); + + // 获取总数 + $total = PayLogService::AdminPayLogTotal($where); + + // 分页 + $page_params = array( + 'number' => $number, + 'total' => $total, + 'where' => $params, + 'page' => isset($params['page']) ? intval($params['page']) : 1, + 'url' => url('admin/paylog/index'), + ); + $page = new \base\Page($page_params); + $this->assign('page_html', $page->GetPageHtml()); + + // 获取列表 + $data_params = array( + 'm' => $page->GetPageStarNumber(), + 'n' => $number, + 'where' => $where, + ); + $data = PayLogService::AdminPayLogList($data_params); + $this->assign('data_list', $data['data']); // 性别 $this->assign('common_gender_list', lang('common_gender_list')); - // 支付日志类型 - $pay_list = $m->field('payment AS id, payment_name AS name')->group('payment')->select(); - $this->assign('common_pay_type_list', $pay_list); - // 业务类型 $this->assign('common_business_type_list', lang('common_business_type_list')); - // 参数 - $this->assign('param', $param); - - // 分页 - $this->assign('page_html', $page->GetPageHtml()); - - // 数据列表 - $this->assign('list', $list); - $this->display('Index'); - } - - /** - * [SetDataHandle 数据处理] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-29T21:27:15+0800 - * @param [array] $data [支付日志数据] - * @return [array] [处理好的数据] - */ - private function SetDataHandle($data) - { - if(!empty($data)) - { - $common_gender_list = lang('common_gender_list'); - $common_business_type_list = lang('common_business_type_list'); - foreach($data as &$v) - { - // 业务类型 - $v['business_type_text'] = $common_business_type_list[$v['business_type']]['name']; - - // 性别 - $v['gender_text'] = $common_gender_list[$v['gender']]['name']; - - // 添加时间 - $v['add_time'] = date('Y-m-d H:i:s', $v['add_time']); - } - } - return $data; - } - - /** - * [GetIndexWhere 支付日志列表条件] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-10T22:16:29+0800 - */ - private function GetIndexWhere() - { - $where = array(); - - // 模糊 - if(!empty($_REQUEST['keyword'])) - { - $like_keyword = array('like', '%'.I('keyword').'%'); - $where[] = array( - 'u.username' => $like_keyword, - 'u.nickname' => $like_keyword, - 'u.mobile' => $like_keyword, - 'p.trade_no' => $like_keyword, - '_logic' => 'or', - ); - } - - // 是否更多条件 - if(I('is_more', 0) == 1) - { - // 等值 - if(!empty($_REQUEST['pay_type'])) - { - $where['p.payment'] = I('pay_type'); - } - if(I('business_type', -1) > -1) - { - $where['p.business_type'] = intval(I('business_type', 0)); - } - if(I('gender', -1) > -1) - { - $where['u.gender'] = intval(I('gender', 0)); - } - - // 表达式 - if(!empty($_REQUEST['time_start'])) - { - $where['p.add_time'][] = array('gt', strtotime(I('time_start'))); - } - if(!empty($_REQUEST['time_end'])) - { - $where['p.add_time'][] = array('lt', strtotime(I('time_end'))); - } - } + // 支付日志类型 + $pay_type_list = PayLogService::PayLogTypeList($params); + $this->assign('common_pay_type_list', $pay_type_list['data']); - return $where; + // 参数 + $this->assign('params', $params); + return $this->fetch(); } } ?> \ No newline at end of file diff --git a/application/admin/view/default/article/index.html b/application/admin/view/default/article/index.html index fc2427483..4a6b0c123 100755 --- a/application/admin/view/default/article/index.html +++ b/application/admin/view/default/article/index.html @@ -4,39 +4,39 @@
-
+
- value="{{$param.keyword}}"{{/if}} /> + -
+
-
+
+ ~ - +
@@ -44,13 +44,13 @@ -
新增 + - @@ -63,19 +63,19 @@ - {{if !empty($list)}} - - + {{if !empty($data_list)}} + {{foreach $data_list as $v}} + {{/foreach}} @@ -126,8 +126,8 @@ - {{if !empty($list)}} - {{$page_html}} + {{if !empty($data_list)}} + {{$page_html|raw}} {{/if}} diff --git a/application/admin/view/default/article/save_info.html b/application/admin/view/default/article/save_info.html index 227774b6e..89a1874fd 100755 --- a/application/admin/view/default/article/save_info.html +++ b/application/admin/view/default/article/save_info.html @@ -4,25 +4,25 @@
- + - {{if empty($data['id'])}} 文章添加 {{else /}} 文章编辑 {{/if}} - 返回 + 返回
- value="{{$data.title}}" {{/if}} {{if !empty($data['title_color'])}} style="color:{{$data.title_color}};" {{/if}} required /> +
@@ -31,29 +31,29 @@
- - value="{{$data.jump_url}}"{{/if}} /> + +
- +
- +
- +
- value="{{$data.id}}"{{/if}}" /> +
diff --git a/application/admin/view/default/article_category/index.html b/application/admin/view/default/articlecategory/index.html similarity index 87% rename from application/admin/view/default/article_category/index.html rename to application/admin/view/default/articlecategory/index.html index 1f516b471..f428c0e14 100755 --- a/application/admin/view/default/article_category/index.html +++ b/application/admin/view/default/articlecategory/index.html @@ -18,7 +18,7 @@
-
+
@@ -27,7 +27,7 @@
- + {{include file="lib/enable" /}}
@@ -40,9 +40,9 @@ -
- +

处理中...

@@ -55,5 +55,5 @@ {{include file="public/footer" /}} \ No newline at end of file diff --git a/application/admin/view/default/brand/index.html b/application/admin/view/default/brand/index.html index 6008f1711..b3767c7c6 100755 --- a/application/admin/view/default/brand/index.html +++ b/application/admin/view/default/brand/index.html @@ -6,7 +6,7 @@
- +
diff --git a/application/admin/view/default/message/index.html b/application/admin/view/default/message/index.html index f47faa0b8..56f2b9cb3 100755 --- a/application/admin/view/default/message/index.html +++ b/application/admin/view/default/message/index.html @@ -4,39 +4,39 @@
- +
- value="{{$param.keyword}}"{{/if}} /> + -
+
-
+
+ ~ - +
@@ -44,7 +44,7 @@ -
标题
- {{$v.title}} + {{$v.title}} {{$v.article_category_name}} {{$v.access_count}} - - + 查看更多 @@ -101,20 +101,20 @@
{{$v.is_enable_text}}
创建时间
-
{{$v.add_time}}
+
{{$v.add_time_time}}
更新时间
-
{{$v.upd_time}}
+
{{$v.upd_time_time}}
- + - +
@@ -57,8 +57,8 @@ - {{if !empty($list)}} - + {{if !empty($data_list)}} + {{foreach $data_list as $v}} {{/foreach}} @@ -101,8 +101,8 @@ - {{if !empty($list)}} - {{$page_html}} + {{if !empty($data_list)}} + {{$page_html|raw}} {{/if}} diff --git a/application/admin/view/default/paylog/index.html b/application/admin/view/default/paylog/index.html index baa93140b..a6db13459 100755 --- a/application/admin/view/default/paylog/index.html +++ b/application/admin/view/default/paylog/index.html @@ -4,41 +4,41 @@
- +
- value="{{$param.keyword}}"{{/if}} /> + -
+
-
+
+ ~ - +
@@ -46,7 +46,7 @@ -
用户信息
{{if !empty($v['username'])}} @@ -74,7 +74,7 @@ {{$v.gender_text}} - {{if empty($v['type_text'])}}未填写{{else /}}{{$v.type_text}}{{/if}} + {{if empty($v['type_name'])}}未填写{{else /}}{{$v.type_name}}{{/if}} {{if empty($v['title'])}}未填写{{else /}}{{$v.title}}{{/if}} @@ -83,13 +83,13 @@ {{if empty($v['detail'])}}未填写{{else /}}{{$v.detail}}{{/if}} - {{if empty($v['is_read_text'])}}未设置{{else /}}{{$v.is_read_text}}{{/if}} + {{if empty($v['is_read_name'])}}未设置{{else /}}{{$v.is_read_name}}{{/if}} - {{if empty($v['add_time'])}}未设置{{else /}}{{$v.add_time}}{{/if}} + {{if empty($v['add_time_time'])}}未设置{{else /}}{{$v.add_time_time}}{{/if}} - +
@@ -62,8 +62,8 @@ - {{if !empty($list)}} - + {{if !empty($data_list)}} + {{foreach $data_list as $v}} {{/foreach}} @@ -115,8 +115,8 @@ - {{if !empty($list)}} - {{$page_html}} + {{if !empty($data_list)}} + {{$page_html|raw}} {{/if}} diff --git a/application/index/controller/Article.php b/application/index/controller/Article.php index b08a84e5b..373f30645 100755 --- a/application/index/controller/Article.php +++ b/application/index/controller/Article.php @@ -38,29 +38,30 @@ class Article extends Common $id = input('id'); $params = [ 'where' => ['a.is_enable'=>1, 'a.id'=>$id], - 'field' => 'a.id,a.title,a.title_color,a.content,a.access_count,a.article_category_id,a.add_time', + 'field' => 'a.id,a.title,a.title_color,a.jump_url,a.content,a.access_count,a.article_category_id,a.add_time', 'm' => 0, 'n' => 1, ]; $article = ArticleService::ArticleList($params); - if(!empty($article[0])) + if(!empty($article['data'][0])) { // 访问统计 ArticleService::ArticleAccessCountInc(['id'=>$id]); // 是否外部链接 - if(!empty($article[0]['jump_url'])) + if(!empty($article['data'][0]['jump_url'])) { - return redirect($article[0]['jump_url']); + return redirect($article['data'][0]['jump_url']); } // 浏览器标题 - $this->assign('home_seo_site_title', $this->GetBrowserSeoTitle($article[0]['title'], 1)); + $this->assign('home_seo_site_title', $this->GetBrowserSeoTitle($article['data'][0]['title'], 1)); // 获取分类和文字 - $this->assign('category_list', ArticleService::ArticleCategoryList()); + $article_category_content = ArticleService::ArticleCategoryListContent(); + $this->assign('category_list', $article_category_content['data']); - $this->assign('article', $article[0]); + $this->assign('article', $article['data'][0]); return $this->fetch(); } else { $this->assign('msg', '文章不存在或已删除'); diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 07b51f067..58a19b09f 100755 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -63,7 +63,8 @@ class Index extends Common 'm' => 0, 'n' => 9, ]; - $this->assign('article_list', ArticleService::ArticleList($params)); + $article_list = ArticleService::ArticleList($params); + $this->assign('article_list', $article_list['data']); // 用户订单状态 $user_order_status = OrderService::OrderStatusStepTotal(['user_type'=>'user', 'user'=>$this->user, 'is_comments'=>1]); diff --git a/application/index/controller/Message.php b/application/index/controller/Message.php index 481fe0b33..360872eed 100755 --- a/application/index/controller/Message.php +++ b/application/index/controller/Message.php @@ -50,7 +50,7 @@ class Message extends Common $number = 10; // 条件 - $where = MessageService::MessgeListWhere($params); + $where = MessageService::MessageListWhere($params); // 获取总数 $total = MessageService::MessageTotal($where); diff --git a/application/index/view/default/article/index.html b/application/index/view/default/article/index.html index 8948f39bf..af0ef40dd 100755 --- a/application/index/view/default/article/index.html +++ b/application/index/view/default/article/index.html @@ -44,7 +44,7 @@ diff --git a/application/index/view/default/index/index.html b/application/index/view/default/index/index.html index 94496d75f..00d3ff653 100755 --- a/application/index/view/default/index/index.html +++ b/application/index/view/default/index/index.html @@ -107,7 +107,7 @@ {{if !empty($article_list)}} {{foreach $article_list as $article}}
  • - + [{{$article.category_name}}] {{$article.title}} diff --git a/application/service/ArticleService.php b/application/service/ArticleService.php index df467026b..b4a28c0d0 100755 --- a/application/service/ArticleService.php +++ b/application/service/ArticleService.php @@ -32,8 +32,25 @@ class ArticleService $data = Db::name('Article')->alias('a')->join(['__ARTICLE_CATEGORY__'=>'ac'], 'a.article_category_id=ac.id')->field($field)->where($where)->order('a.id desc')->limit($m, $n)->select(); if(!empty($data)) { + $common_is_enable_tips = lang('common_is_enable_tips'); foreach($data as &$v) { + // url + $v['url'] = HomeUrl('article', 'index', ['id'=>$v['id']]); + + // 分类名称 + if(isset($v['article_category_id'])) + { + $v['article_category_name'] = Db::name('ArticleCategory')->where(['id'=>$v['article_category_id']])->value('name'); + } + + // 是否启用 + if(isset($v['is_enable'])) + { + $v['is_enable_text'] = $common_is_enable_tips[$v['is_enable']]['name']; + } + + // 内容 if(isset($v['content'])) { $v['content'] = ResourcesService::ContentStaticReplace($v['content'], 'get'); @@ -43,9 +60,172 @@ class ArticleService $v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']); $v['add_time_date'] = date('Y-m-d', $v['add_time']); } + if(isset($v['upd_time'])) + { + $v['upd_time_time'] = date('Y-m-d H:i:s', $v['upd_time']); + $v['upd_time_date'] = date('Y-m-d', $v['upd_time']); + } } } - return $data; + return DataReturn('处理成功', 0, $data); + } + + /** + * 文章总数 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-10T22:16:29+0800 + * @param [array] $where [条件] + */ + public static function ArticleTotal($where) + { + return (int) Db::name('Article')->alias('a')->join(['__ARTICLE_CATEGORY__'=>'ac'], 'a.article_category_id=ac.id')->where($where)->count(); + } + + /** + * 列表条件 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-29 + * @desc description + * @param [array] $params [输入参数] + */ + public static function ArticleListWhere($params = []) + { + $where = []; + + if(!empty($params['keywords'])) + { + $where[] = ['a.title', 'like', '%'.$params['keywords'].'%']; + } + + // 是否更多条件 + if(isset($params['is_more']) && $params['is_more'] == 1) + { + // 等值 + if(isset($params['is_enable']) && $params['is_enable'] > -1) + { + $where[] = ['a.is_enable', '=', intval($params['is_enable'])]; + } + if(isset($params['article_category_id']) && $params['article_category_id'] > -1) + { + $where[] = ['a.article_category_id', '=', intval($params['article_category_id'])]; + } + if(isset($params['is_home_recommended']) && $params['is_home_recommended'] > -1) + { + $where[] = ['a.is_home_recommended', '=', intval($params['is_home_recommended'])]; + } + + if(!empty($params['time_start'])) + { + $where[] = ['a.add_time', '>', strtotime($params['time_start'])]; + } + if(!empty($params['time_end'])) + { + $where[] = ['a.add_time', '<', strtotime($params['time_end'])]; + } + } + + return $where; + } + + /** + * 文章保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-18 + * @desc description + * @param [array] $params [输入参数] + */ + public static function ArticleSave($params = []) + { + // 请求类型 + $p = [ + [ + 'checked_type' => 'length', + 'key_name' => 'title', + 'checked_data' => '2,60', + 'error_msg' => '标题长度 2~60 个字符', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'article_category_id', + 'error_msg' => '请选择文章分类', + ], + [ + 'checked_type' => 'fun', + 'key_name' => 'jump_url', + 'checked_data' => 'CheckUrl', + 'is_checked' => 1, + 'error_msg' => '跳转url地址格式有误', + ], + [ + 'checked_type' => 'length', + 'key_name' => 'content', + 'checked_data' => '10,105000', + 'error_msg' => '内容 10~105000 个字符', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 数据 + $content = ResourcesService::ContentStaticReplace($params['content'], 'add'); + $image = self::MatchContentImage($content); + $data = [ + 'title' => $params['title'], + 'title_color' => empty($params['title_color']) ? '' : $params['title_color'], + 'article_category_id' => intval($params['article_category_id']), + 'jump_url' => empty($params['jump_url']) ? '' : $params['jump_url'], + 'content' => $content, + 'image' => empty($image) ? '' : json_encode($image), + 'image_count' => count($image), + 'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0, + 'is_home_recommended' => isset($params['is_home_recommended']) ? intval($params['is_home_recommended']) : 0, + ]; + + if(empty($params['id'])) + { + $data['add_time'] = time(); + if(Db::name('Article')->insertGetId($data) > 0) + { + return DataReturn('添加成功', 0); + } + return DataReturn('添加失败', -100); + } else { + $data['upd_time'] = time(); + if(Db::name('Article')->where(['id'=>intval($params['id'])])->update($data)) + { + return DataReturn('编辑成功', 0); + } + return DataReturn('编辑失败', -100); + } + } + + /** + * 正则匹配文章图片 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2017-01-22T18:06:53+0800 + * @param [string] $content [文章内容] + * @return [array] [文章图片数组(一维)] + */ + private static function MatchContentImage($content) + { + if(!empty($content)) + { + $pattern = '//'; + preg_match_all($pattern, $content, $match); + return empty($match[1]) ? [] : $match[1]; + } + return array(); } /** @@ -57,17 +237,26 @@ class ArticleService * @desc description * @param [array] $params [输入参数] */ - public static function ArticleCategoryList($params = []) + public static function ArticleCategoryListContent($params = []) { $data = Db::name('ArticleCategory')->field('id,name')->where(['is_enable'=>1])->order('id asc, sort asc')->select(); if(!empty($data)) { foreach($data as &$v) { - $v['items'] = Db::name('Article')->field('id,title,title_color')->where(['article_category_id'=>$v['id'], 'is_enable'=>1])->select(); + $items = Db::name('Article')->field('id,title,title_color')->where(['article_category_id'=>$v['id'], 'is_enable'=>1])->select(); + if(!empty($items)) + { + foreach($items as &$vs) + { + // url + $vs['url'] = HomeUrl('article', 'index', ['id'=>$vs['id']]); + } + } + $v['items'] = $items; } } - return $data; + return DataReturn('处理成功', 0, $data); } /** @@ -87,5 +276,220 @@ class ArticleService } return false; } + + /** + * 文章分类 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-08-29 + * @desc description + * @param [array] $params [输入参数] + */ + public static function ArticleCategoryList($params = []) + { + $field = empty($params['field']) ? '*' : $params['field']; + $order_by = empty($params['order_by']) ? 'sort asc' : trim($params['order_by']); + + $data = Db::name('ArticleCategory')->where(['is_enable'=>1])->field($field)->order($order_by)->select(); + + return DataReturn('处理成功', 0, $data); + } + + /** + * 删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-18 + * @desc description + * @param [array] $params [输入参数] + */ + public static function ArticleDelete($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '操作id有误', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 删除操作 + if(Db::name('Article')->where(['id'=>$params['id']])->delete()) + { + return DataReturn('删除成功'); + } + + return DataReturn('删除失败或资源不存在', -100); + } + + /** + * 状态更新 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-06T21:31:53+0800 + * @param [array] $params [输入参数] + */ + public static function ArticleStatusUpdate($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '操作id有误', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'field', + 'error_msg' => '操作字段有误', + ], + [ + 'checked_type' => 'in', + 'key_name' => 'state', + 'checked_data' => [0,1], + 'error_msg' => '状态有误', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 数据更新 + if(Db::name('Article')->where(['id'=>intval($params['id'])])->update([$params['field']=>intval($params['state'])])) + { + return DataReturn('编辑成功'); + } + return DataReturn('编辑失败或数据未改变', -100); + } + + /** + * 获取文章分类节点数据 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2018-12-16T23:54:46+0800 + * @param [array] $params [输入参数] + */ + public static function ArticleCategoryNodeSon($params = []) + { + // id + $id = isset($params['id']) ? intval($params['id']) : 0; + + // 获取数据 + $field = '*'; + $data = Db::name('ArticleCategory')->field($field)->where(['pid'=>$id])->order('sort asc')->select(); + if(!empty($data)) + { + foreach($data as &$v) + { + $v['is_son'] = (Db::name('ArticleCategory')->where(['pid'=>$v['id']])->count() > 0) ? 'ok' : 'no'; + $v['ajax_url'] = url('admin/articlecategory/getnodeson', array('id'=>$v['id'])); + $v['delete_url'] = url('admin/articlecategory/delete'); + $v['json'] = json_encode($v); + } + return DataReturn('操作成功', 0, $data); + } + return DataReturn('没有相关数据', -100); + } + + /** + * 文章分类保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2018-12-17T01:04:03+0800 + * @param [array] $params [输入参数] + */ + public static function ArticleCategorySave($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'length', + 'key_name' => 'name', + 'checked_data' => '2,16', + 'error_msg' => '名称格式 2~16 个字符', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 数据 + $data = [ + 'name' => $params['name'], + 'pid' => isset($params['pid']) ? intval($params['pid']) : 0, + 'sort' => isset($params['sort']) ? intval($params['sort']) : 0, + 'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0, + ]; + + // 添加 + if(empty($params['id'])) + { + $data['add_time'] = time(); + if(Db::name('ArticleCategory')->insertGetId($data) > 0) + { + return DataReturn('添加成功', 0); + } + return DataReturn('添加失败', -100); + } else { + $data['upd_time'] = time(); + if(Db::name('ArticleCategory')->where(['id'=>intval($params['id'])])->update($data)) + { + return DataReturn('编辑成功', 0); + } + return DataReturn('编辑失败', -100); + } + } + + /** + * 文章分类删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2018-12-17T02:40:29+0800 + * @param [array] $params [输入参数] + */ + public static function ArticleCategoryDelete($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '删除数据id有误', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'admin', + 'error_msg' => '用户信息有误', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 开始删除 + if(Db::name('ArticleCategory')->where(['id'=>intval($params['id'])])->delete()) + { + return DataReturn('删除成功', 0); + } + return DataReturn('删除失败', 0); + } } ?> \ No newline at end of file diff --git a/application/service/CustomViewService.php b/application/service/CustomViewService.php index b90e56b01..8204eb593 100644 --- a/application/service/CustomViewService.php +++ b/application/service/CustomViewService.php @@ -226,7 +226,7 @@ class CustomViewService { if(!empty($content)) { - $pattern = '//'; + $pattern = '//'; preg_match_all($pattern, $content, $match); return empty($match[1]) ? [] : $match[1]; } diff --git a/application/service/MessageService.php b/application/service/MessageService.php index 4f4372d8b..3631f33dc 100755 --- a/application/service/MessageService.php +++ b/application/service/MessageService.php @@ -51,7 +51,7 @@ class MessageService * @desc description * @param [array] $params [输入参数] */ - public static function MessgeListWhere($params = []) + public static function MessageListWhere($params = []) { $where = [ ['is_delete_time', '=', 0], @@ -149,7 +149,7 @@ class MessageService { return 0; } - return self::MessageTotal(self::MessgeListWhere($params)); + return self::MessageTotal(self::MessageListWhere($params)); } /** @@ -224,5 +224,155 @@ class MessageService $ret = Db::name('Message')->where($where)->update(['is_read'=>1]); return DataReturn('处理成功', 0, $ret); } + + /** + * 后台管理员列表 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-29 + * @desc description + * @param [array] $params [输入参数] + */ + public static function AdminMessageList($params = []) + { + $where = empty($params['where']) ? [] : $params['where']; + $m = isset($params['m']) ? intval($params['m']) : 0; + $n = isset($params['n']) ? intval($params['n']) : 10; + $field = 'm.*,u.username,u.nickname,u.mobile,u.gender'; + $order_by = empty($params['order_by']) ? 'm.id desc' : $params['order_by']; + + // 获取数据列表 + $data = Db::name('Message')->alias('m')->join(['__USER__'=>'u'], 'u.id=m.user_id')->where($where)->field($field)->limit($m, $n)->order($order_by)->select(); + if(!empty($data)) + { + $common_business_type_list = lang('common_business_type_list'); + $common_is_read_list = lang('common_is_read_list'); + $common_message_type_list = lang('common_message_type_list'); + $common_gender_list = lang('common_gender_list'); + foreach($data as &$v) + { + // 消息类型 + $v['type_name'] = $common_message_type_list[$v['type']]['name']; + + // 是否已读 + $v['is_read_name'] = $common_is_read_list[$v['is_read']]['name']; + + // 业务类型 + $v['business_type_name'] = $common_business_type_list[$v['business_type']]['name']; + + // 性别 + $v['gender_text'] = $common_gender_list[$v['gender']]['name']; + + // 时间 + $v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']); + $v['add_time_date'] = date('Y-m-d', $v['add_time']); + } + } + return DataReturn('处理成功', 0, $data); + } + + /** + * 后台消息总数 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-29 + * @desc description + * @param [array] $where [条件] + */ + public static function AdminMessageTotal($where = []) + { + return (int) Db::name('Message')->alias('m')->join(['__USER__'=>'u'], 'u.id=m.user_id')->where($where)->count(); + } + + /** + * 后台消息列表条件 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-29 + * @desc description + * @param [array] $params [输入参数] + */ + public static function AdminMessageListWhere($params = []) + { + $where = [ + ['m.is_delete_time', '=', 0], + ]; + + // 关键字 + if(!empty($params['keywords'])) + { + $where[] = ['m.title|m.detail|u.username|u.nickname|u.mobile', 'like', '%'.$params['keywords'].'%']; + } + + // 是否更多条件 + if(isset($params['is_more']) && $params['is_more'] == 1) + { + // 等值 + if(isset($params['business_type']) && $params['business_type'] > -1) + { + $where[] = ['m.business_type', '=', intval($params['business_type'])]; + } + if(isset($params['type']) && $params['type'] > -1) + { + $where[] = ['m.type', '=', intval($params['type'])]; + } + if(isset($params['is_read']) && $params['is_read'] > -1) + { + $where[] = ['m.is_read', '=', intval($params['is_read'])]; + } + if(isset($params['gender']) && $params['gender'] > -1) + { + $where[] = ['u.gender', '=', intval($params['gender'])]; + } + + if(!empty($params['time_start'])) + { + $where[] = ['m.add_time', '>', strtotime($params['time_start'])]; + } + if(!empty($params['time_end'])) + { + $where[] = ['m.add_time', '<', strtotime($params['time_end'])]; + } + } + + return $where; + } + + /** + * 删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-18 + * @desc description + * @param [array] $params [输入参数] + */ + public static function MessageDelete($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '操作id有误', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 删除操作 + if(Db::name('Message')->where(['id'=>$params['id']])->delete()) + { + return DataReturn('删除成功'); + } + + return DataReturn('删除失败或资源不存在', -100); + } } ?> \ No newline at end of file diff --git a/application/service/PayLogService.php b/application/service/PayLogService.php new file mode 100644 index 000000000..f171e660c --- /dev/null +++ b/application/service/PayLogService.php @@ -0,0 +1,164 @@ +field('payment AS id, payment_name AS name')->group('payment')->select(); + return DataReturn('处理成功', 0, $data); + } + /** + * 后台管理员列表 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-29 + * @desc description + * @param [array] $params [输入参数] + */ + public static function AdminPayLogList($params = []) + { + $where = empty($params['where']) ? [] : $params['where']; + $m = isset($params['m']) ? intval($params['m']) : 0; + $n = isset($params['n']) ? intval($params['n']) : 10; + $field = 'p.*,u.username,u.nickname,u.mobile,u.gender'; + $order_by = empty($params['order_by']) ? 'p.id desc' : $params['order_by']; + + // 获取数据列表 + $data = Db::name('PayLog')->alias('p')->join(['__USER__'=>'u'], 'u.id=p.user_id')->where($where)->field($field)->limit($m, $n)->order($order_by)->select(); + if(!empty($data)) + { + $common_business_type_list = lang('common_business_type_list'); + $common_gender_list = lang('common_gender_list'); + foreach($data as &$v) + { + // 业务类型 + $v['business_type_name'] = $common_business_type_list[$v['business_type']]['name']; + + // 性别 + $v['gender_text'] = $common_gender_list[$v['gender']]['name']; + + // 时间 + $v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']); + $v['add_time_date'] = date('Y-m-d', $v['add_time']); + } + } + return DataReturn('处理成功', 0, $data); + } + + /** + * 后台消息总数 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-29 + * @desc description + * @param [array] $where [条件] + */ + public static function AdminPayLogTotal($where = []) + { + return (int) Db::name('PayLog')->alias('p')->join(['__USER__'=>'u'], 'u.id=p.user_id')->where($where)->count(); + } + + /** + * 后台消息列表条件 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-29 + * @desc description + * @param [array] $params [输入参数] + */ + public static function AdminPayLogListWhere($params = []) + { + $where = []; + + // 关键字 + if(!empty($params['keywords'])) + { + $where[] = ['p.trade_no|u.username|u.nickname|u.mobile', 'like', '%'.$params['keywords'].'%']; + } + + // 是否更多条件 + if(isset($params['is_more']) && $params['is_more'] == 1) + { + // 等值 + if(isset($params['business_type']) && $params['business_type'] > -1) + { + $where[] = ['p.business_type', '=', intval($params['business_type'])]; + } + if(!empty($params['pay_type'])) + { + $where[] = ['p.payment', '=', $params['pay_type']]; + } + if(isset($params['gender']) && $params['gender'] > -1) + { + $where[] = ['u.gender', '=', intval($params['gender'])]; + } + + if(!empty($params['time_start'])) + { + $where[] = ['p.add_time', '>', strtotime($params['time_start'])]; + } + if(!empty($params['time_end'])) + { + $where[] = ['p.add_time', '<', strtotime($params['time_end'])]; + } + } + + return $where; + } + + /** + * 删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-18 + * @desc description + * @param [array] $params [输入参数] + */ + public static function PayLogDelete($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '操作id有误', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 删除操作 + if(Db::name('PayLog')->where(['id'=>$params['id']])->delete()) + { + return DataReturn('删除成功'); + } + + return DataReturn('删除失败或资源不存在', -100); + } +} +?> \ No newline at end of file -- GitLab
  • 用户信息
    {{if !empty($v['username'])}} @@ -82,7 +82,7 @@ {{if empty($v['payment_name'])}}未填写{{else /}}{{$v.payment_name}}{{/if}} - {{if empty($v['business_type_text'])}}未填写{{else /}}{{$v.business_type_text}}{{/if}} + {{if empty($v['business_type_name'])}}未填写{{else /}}{{$v.business_type_name}}{{/if}} {{if empty($v['order_id'])}}未填写{{else /}}{{$v.order_id}}{{/if}} @@ -103,7 +103,7 @@ {{if empty($v['subject'])}}未填写{{else /}}{{$v.subject}}{{/if}} - {{if empty($v['add_time'])}}未填写{{else /}}{{$v.add_time}}{{/if}} + {{if empty($v['add_time_time'])}}未填写{{else /}}{{$v.add_time_time}}{{/if}}