首页添加日志及未读提醒功能

master
zyx 5 years ago
parent 5dd9df5cd5
commit eab8135549

@ -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;

@ -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();
}

@ -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);

@ -42,7 +42,30 @@
</li>
<li>
<div class="fxui-tab">
<div class="fxui-tab-hand"><span class="fxui-tab-tit"><a href="#;">公告</a></span> <span class="fxui-tab-tit"><a href="#;">消息</a></span> <span class="fxui-tab-tit"><a href="#;">游戏活动</a></span><span class="more"><a href="{:U('msg_list')}">查看更多></a></span></div>
<div class="fxui-tab-hand">
<span class="fxui-tab-tit"><a href="#;">公告</a>
<span style="width: 25px;height: 25px;float: left;position: relative;bottom:50px;left:55px;text-align: center;background: rgba(255, 0, 0, 1)">
<a style="line-height: 25px;padding: 0px;color: #fff">{$gg_count}</a>
</span>
</span>
<span class="fxui-tab-tit"><a href="#;">消息</a>
<span style="width: 25px;height: 25px;float: left;position: relative;bottom:50px;left:55px;text-align: center;background: rgba(255, 0, 0, 1)">
<a style="line-height: 25px;padding: 0;color: #fff">0</a>
</span>
</span>
<span class="fxui-tab-tit"><a href="#;">游戏活动</a>
<span style="width: 25px;height: 25px;float: left;position: relative;bottom:50px;left:83px;text-align: center;background: rgba(255, 0, 0, 1)">
<a style="line-height: 25px;padding: 0px;color: #fff">{$zx_count}</a>
</span>
</span>
<span class="fxui-tab-tit"><a href="#;">资源号异常日志</a>
<span style="width: 25px;height: 25px;float: left;position: relative;bottom:50px;left:125px;text-align: center;background: rgba(255, 0, 0, 1)">
<a style="line-height: 25px;padding: 0px;color: #fff">{$rz_count}</a>
</span>
</span>
<div id="u271_ann" class="annotation"></div>
<span class="more"><a href="{:U('msg_list')}">查看更多></a></span>
</div>
<div class="fxui-tab-nav">
<empty name="gg_list">
暂无公告
@ -79,6 +102,18 @@
</volist>
</empty>
</div>
<div class="fxui-tab-nav">
<empty name="rz_list">
暂无异常日志
<else/>
<volist name="rz_list" id="zx">
<p>
<span class="title"><a href="index.php?s=/Home/TestResource/protectLogList/id/{$zx.id}.html">账号:{$zx.user_account},{$zx.detail}</a></span>
<span class="time">{$zx.update_time|date="Y/m/d",###}</span>
</p>
</volist>
</empty>
</div>
</div>
</li>
</ul>
@ -202,5 +237,4 @@
});
}
</script>
</block>
</block>

@ -13,9 +13,27 @@
<div class="trunk-list list_normal">
<div class="fxui-tab">
<div class="fxui-tab-hand" style="border-bottom: none">
<span class="fxui-tab-tit <if condition="$type==56">curr</if>"><a href="{:U('msg_list')}&type=56">公告</a></span>
<span class="fxui-tab-tit <if condition="$type==50">curr</if>"><a href="{:U('msg_list')}&type=50">消息</a></span>
<span class="fxui-tab-tit <if condition="$type==51">curr</if>"><a href="{:U('msg_list')}&type=51">游戏活动</a></span></div>
<span class="fxui-tab-tit <if condition="$type==56">curr</if>"><a href="{:U('msg_list')}&type=56">公告</a>
<span style="width: 25px;height: 25px;float: left;position: relative;bottom:50px;left:55px;text-align: center;background: rgba(255, 0, 0, 1)">
<a style="line-height: 25px;padding: 0px;color: #fff">{$gg_count}</a>
</span>
</span>
<span class="fxui-tab-tit <if condition="$type==50">curr</if>"><a href="{:U('msg_list')}&type=50">消息</a>
<span style="width: 25px;height: 25px;float: left;position: relative;bottom:50px;left:55px;text-align: center;background: rgba(255, 0, 0, 1)">
<a style="line-height: 25px;padding: 0px;color: #fff">0</a>
</span>
</span>
<span class="fxui-tab-tit <if condition="$type==51">curr</if>"><a href="{:U('msg_list')}&type=51">游戏活动</a>
<span style="width: 25px;height: 25px;float: left;position: relative;bottom:50px;left:83px;text-align: center;background: rgba(255, 0, 0, 1)">
<a style="line-height: 25px;padding: 0px;color: #fff">{$zx_count}</a>
</span>
</span>
<span class="fxui-tab-tit <if condition="$type==0">curr</if>"><a href="{:U('msg_list')}&type=0">资源号异常日志</a>
<span style="width: 25px;height: 25px;float: left;position: relative;bottom:50px;left:125px;text-align: center;background: rgba(255, 0, 0, 1)">
<a style="line-height: 25px;padding: 0px;color: #fff">{$rz_count}</a>
</span>
</span>
</div>
<div class="fxui-tab-nav">
<empty name="data_list">
暂无信息

@ -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;
Loading…
Cancel
Save