From eab81355490c36c00d4507a286f994fba87bea18 Mon Sep 17 00:00:00 2001 From: zyx Date: Tue, 15 Oct 2019 09:11:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=8F=8A=E6=9C=AA=E8=AF=BB=E6=8F=90=E9=86=92=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ArticleController.class.php | 20 +++++++++ .../Controller/PromoteController.class.php | 44 ++++++++++++++++++- .../TestResourceController.class.php | 39 ++++++++++++++-- .../Home/View/default/Promote/index.html | 40 +++++++++++++++-- .../Home/View/default/Promote/msg_list.html | 24 ++++++++-- Data/update.sql | 20 +++++++++ 6 files changed, 175 insertions(+), 12 deletions(-) diff --git a/Application/Home/Controller/ArticleController.class.php b/Application/Home/Controller/ArticleController.class.php index a87f072c6..7c0e2af26 100644 --- a/Application/Home/Controller/ArticleController.class.php +++ b/Application/Home/Controller/ArticleController.class.php @@ -9,6 +9,8 @@ namespace Home\Controller; +use mysql_xdevapi\Exception; + /** * 文档模型控制器 * 文档模型列表和详情 @@ -77,6 +79,24 @@ class ArticleController extends HomeController { $this->error('文档ID错误!'); } + $field = 'id as document_id,category_id'; + $decumentData = M('document')->field($field)->where("id={$id}")->find(); + $promote_id = get_pid(); + foreach ($decumentData as $key => $value) { + $decumentData['promote_id'] = $promote_id; + $decumentData['create_time'] = time(); + } + M('document_read')->startTrans(); //事物 + try { + $haveRead = M('document_read')->where("document_id={$id} and promote_id={$promote_id}")->find(); + if (!$haveRead) { + M('document_read')->add($decumentData); + } + } catch (Exception $e) { + M('document_read')->rollback();//回滚 + } + M('document_read')->commit(); //提交事物 + /* 页码检测 */ $p = intval($p); $p = empty($p) ? 1 : $p; diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 86764e041..35d539ef7 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -36,8 +36,8 @@ class PromoteController extends BaseController public function index($p = 1) { $this->meta_title = "首页"; - $this->display('prepare'); - exit(0); +// $this->display('prepare'); +// exit(0); header("Content-type:text/html;charset=utf-8"); $user = D('Promote')->isLogin(); @@ -56,6 +56,20 @@ class PromoteController extends BaseController $game_list = M("game", "tab_")->field("id,game_name")->order("id desc")->select(); $gg_list = M("document", "sys_")->limit('0,5')->where("category_id=56 and status=1")->order("update_time desc")->select(); //游戏公告 $zx_list = M("document", "sys_")->limit('0,5')->where("category_id=51 and status=1")->order("update_time desc")->select(); //游戏咨询 + + $field = 'id,game_name,server_name,user_account,nickname,promote_account,detail,create_time as update_time'; + $rz_list = M("protect_log","tab_")->field($field)->limit('0,5')->order("create_time desc")->select(); //日志管理 + + $promote_id = get_pid(); + $logCount = M('protect_log','tab_')->count(); + $readLogCount = M('protect_log_read','tab_')->where("promote_id = {$promote_id}")->count(); + + $gg_Count = M("document", "sys_")->where("category_id=56 and status=1")->count(); + $gg_ReadDocument = M("document_read", "sys_")->where("promote_id = {$promote_id} and category_id=56")->count(); + + $zx_Count = M("document", "sys_")->where("category_id=51 and status=1")->count(); + $zx_ReadDocument = M("document_read", "sys_")->where("promote_id = {$promote_id} and category_id=51")->count(); + $xx_list = null; $today_start = mktime(0, 0, 0, date('m'), date('d'), date('Y')); @@ -107,8 +121,12 @@ class PromoteController extends BaseController $this->assign("menu_list", $quick_menu_list); $this->assign("gg_list", $gg_list); + $this->assign("gg_count", $gg_Count-$gg_ReadDocument); $this->assign("zx_list", $zx_list); + $this->assign("zx_count", $zx_Count-$zx_ReadDocument); $this->assign("xx_list", $xx_list); + $this->assign('rz_list', $rz_list); + $this->assign("rz_count", $logCount-$readLogCount); $this->assign("today_open_server_list", $today_open_server_list); $this->assign("game_list", $game_list); $this->meta_title = "首页"; @@ -317,10 +335,29 @@ class PromoteController extends BaseController } elseif ($type == 50) { $data_list = null; $count = 0; + } else if($type == 0) { + $field = 'id,game_name,server_name,user_account,nickname,promote_account,detail,create_time as update_time'; + $data_list = M("protect_log","tab_")->field($field)->limit('0,5')->order("create_time desc")->select(); + + foreach($data_list as $key => $value) { + $data_list[$key]['title'] = '账号:'.$value['user_account'].','.$value['detail']; + } + + $count = M("protect_log","tab_")->field($field)->count(); } else { $data_list = M("document", "sys_")->limit('0,50')->where("category_id=56 and status=1")->order("update_time desc")->page($page, $row)->select(); //游戏公告 $count = M("document", "sys_")->where("category_id=56 and status=1")->count(); } + $promote_id = get_pid(); + $logCount = M('protect_log','tab_')->count(); + $readLogCount = M('protect_log_read','tab_')->where("promote_id = {$promote_id}")->count(); + + $gg_Count = M("document", "sys_")->where("category_id=56 and status=1")->count(); + $gg_ReadDocument = M("document_read", "sys_")->where("promote_id = {$promote_id} and category_id=56")->count(); + + $zx_Count = M("document", "sys_")->where("category_id=51 and status=1")->count(); + $zx_ReadDocument = M("document_read", "sys_")->where("promote_id = {$promote_id} and category_id=51")->count(); + $parameter['p'] = I('get.p', 1); $parameter['row'] = I('get.row'); $page = set_pagination($count, $row, $parameter); @@ -331,6 +368,9 @@ class PromoteController extends BaseController $this->meta_title = "公告列表"; $this->assign("type", $type); $this->assign("data_list", $data_list); + $this->assign("gg_count", $gg_Count-$gg_ReadDocument); + $this->assign("zx_count", $zx_Count-$zx_ReadDocument); + $this->assign("rz_count", $logCount-$readLogCount); $this->display(); } diff --git a/Application/Home/Controller/TestResourceController.class.php b/Application/Home/Controller/TestResourceController.class.php index d26777272..3c9ca4306 100644 --- a/Application/Home/Controller/TestResourceController.class.php +++ b/Application/Home/Controller/TestResourceController.class.php @@ -5,6 +5,7 @@ namespace Home\Controller; use Base\Model\PromoteModel; use Base\Service\PromoteService; +use OSS\Core\OssException; class TestResourceController extends BaseController @@ -150,6 +151,7 @@ class TestResourceController extends BaseController } public function protectLogList($p = 1) { + $promote_id = get_pid(); $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 $row=10; @@ -184,18 +186,47 @@ class TestResourceController extends BaseController $map['type']=I('types'); } - $field = 'game_name,server_name,user_account,nickname,promote_account,detail'; + $field = 'id,game_name,server_name,user_account,nickname,promote_account,detail'; $order = 'id DESC'; $data = D('protect_log')->getProtectLog($field,$map,'',$order,$page,$row); $count = D('protect_log')->getProtectLog($field,$map,'',$order); - $count = count($count); - $page = set_pagination($count,$row); + M('protect_log_read', 'tab_')->startTrans(); //事物 + try { + $arrUserId = array_column($data,'id'); + $logId = implode(',',$arrUserId); - $this->meta_title = '日志管理'; + $logRead = M('protect_log_read','tab_') + ->where("log_id IN({$logId}) and promote_id = {$promote_id}") + ->select(); + + $upsetData = array_column($logRead,'log_id'); + + $addData = []; + $k = 0; + foreach($arrUserId as $key => $value) { + if (in_array($value['id'],$upsetData)) { + continue; + } else { + $addData[$k]['log_id'] = $value; + $addData[$k]['promote_id'] = $promote_id; + $addData[$k]['create_time'] = time(); + $k++; + } + } + + M('protect_log_read','tab_')->addAll($addData); + + } catch (OssException $e) { + M('protect_log_read', 'tab_')->rollback();//回滚 + } + M('protect_log_read', 'tab_')->commit(); //提交事物 + $count = count($count); + $page = set_pagination($count,$row); + $this->meta_title = '日志管理'; if($page) {$this->assign('_page', $page);} $this->assign('data',$data); diff --git a/Application/Home/View/default/Promote/index.html b/Application/Home/View/default/Promote/index.html index f308c5f69..b420d1c3d 100644 --- a/Application/Home/View/default/Promote/index.html +++ b/Application/Home/View/default/Promote/index.html @@ -42,7 +42,30 @@
  • - +
    暂无公告 @@ -79,6 +102,18 @@
    +
    + + 暂无异常日志 + + +

    + 账号:{$zx.user_account},{$zx.detail} + {$zx.update_time|date="Y/m/d",###} +

    +
    +
    +
  • @@ -202,5 +237,4 @@ }); } - - \ No newline at end of file + \ No newline at end of file diff --git a/Application/Home/View/default/Promote/msg_list.html b/Application/Home/View/default/Promote/msg_list.html index 33db7955f..a40d0c3e9 100644 --- a/Application/Home/View/default/Promote/msg_list.html +++ b/Application/Home/View/default/Promote/msg_list.html @@ -13,9 +13,27 @@
    - curr">公告 - curr">消息 - curr">游戏活动
    + curr">公告 + + {$gg_count} + + + curr">消息 + + 0 + + + curr">游戏活动 + + {$zx_count} + + + curr">资源号异常日志 + + {$rz_count} + + +
    暂无信息 diff --git a/Data/update.sql b/Data/update.sql index 76738c49c..8e20756cd 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -138,3 +138,23 @@ alter table tab_user_play_info add column `create_time` int(11) NOT NULL DEFAULT alter table tab_user_play_info add column `create_ip` varchar(16) NOT NULL DEFAULT '' COMMENT '角色创建IP'; alter table tab_user_play_info add column `create_device_number` varchar(50) NOT NULL DEFAULT '' COMMENT '角色创建设备号'; alter table tab_server add column `server_id` varchar(50) not NULL default '' COMMENT '对接区服id'; + +-- ---------------------------- +-- 2019-10-11 zyx +-- ---------------------------- +CREATE TABLE `sys_document_read` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `document_id` int(11) NOT NULL DEFAULT '0' COMMENT '文档模型基础表id', + `category_id` int(10) NOT NULL DEFAULT '0' COMMENT '所属分类', + `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id', + `create_time` int(11) DEFAULT '0' COMMENT '创建时间', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +CREATE TABLE `tab_protect_log_read` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `log_id` int(11) NOT NULL DEFAULT '0' COMMENT '日志id', + `promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广员id', + `create_time` int(11) DEFAULT '0' COMMENT '创建时间', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; \ No newline at end of file