Authored by xiaofeng.yao@yoho.cn

后台开发可以修改总观看人数

... ... @@ -70,7 +70,8 @@ class SystemController extends BaseController
}
}
public function actionVest(){
public function actionVest()
{
$cache_prefix = Yii::$app->params['cache_prefix'];
$imVestNums = Yii::$app->redisIm->llen($cache_prefix.'vest_users');
if(Yii::$app->request->isAjax){
... ... @@ -101,5 +102,61 @@ class SystemController extends BaseController
return $this->render('vest',['imVestNums'=>$imVestNums]);
}
public function actionGetaudnums()
{
$cache_prefix = Yii::$app->params['cache_prefix'];
$room_id = trim(Yii::$app->request->post('room_id'));
$ret = [
'audience'=>0,
'like'=>0,
'addup'=>0,
];
if($room_id) {
$keys = [
'audience'=>$cache_prefix.'audience_nums_room_'.$room_id,
'like'=>$cache_prefix.'like_numbers_room_'.$room_id,
'addup'=>$cache_prefix.'addup_num_'.$room_id,
];
$index = array_keys($keys);
$values = $keys ? call_user_func_array(array(Yii::$app->redisIm,'mget'), $keys) : [];
foreach ($values as $k=>$v) {
$ret[$index[$k]] = $v ? :0;
}
}
$data = [
'code'=>'200',
'msg'=>'',
'data'=>$ret
];
echo json_encode($data);exit;
}
public function actionModifycache()
{
$cache_prefix = Yii::$app->params['cache_prefix'];
$room_id = trim(Yii::$app->request->post('room_id'));
$cache_key = trim(Yii::$app->request->post('cache_key'));
$cache_val = trim(Yii::$app->request->post('cache_val'));
if($room_id && $cache_key && $cache_val){
$expire = 86400;
if($cache_key == 'addup'){
$res = Yii::$app->redisIm->setex($cache_prefix.'addup_num_'.$room_id,$expire,$cache_val);
}
if($cache_key == 'like'){
$res = Yii::$app->redisIm->setex($cache_prefix.'like_numbers_room_'.$room_id,$expire,$cache_val);
}
$data = [
'code'=>'200',
'msg'=>'修改成功',
'data'=>$res
];
}else{
$data = [
'code'=>'400',
'msg'=>'参数不能为空',
'data'=>''
];
}
echo json_encode($data);exit;
}
}
... ...
... ... @@ -5,10 +5,11 @@ $this->title = '管理后台首页';
?>
<div class="col-md-6">
<p><span>剩余马甲数:</span><?php echo $imVestNums?></p>
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">导入马甲</h5>
<p>剩余马甲数:<?php echo $imVestNums?></p>
</div>
<div class="panel-body">
... ... @@ -30,12 +31,59 @@ $this->title = '管理后台首页';
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">查看观看人数</h5>
</div>
<div class="panel-body">
<div class="form-group">
<label class="col-sm-3 control-label">请输入房间号:</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="room_id" name="room_id" >
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-primary mr5" id="search_audi_btn">查询</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">观看数:</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="actual_num" disabled>
</div>
<div class="col-sm-1">
+
</div>
<div class="col-sm-2">
<input type="text" class="form-control" id="addup_num">
</div>
<div class="col-sm-1">
*10 =
</div>
<div class="col-sm-2">
<input type="text" class="form-control" id="result_num" disabled>
</div>
<div class="col-sm-1">
<button type="button" class="btn btn-primary" id="modify_addup_btn">修改</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">点赞数:</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="like_num">
</div>
<div class="col-sm-1">
<button type="button" class="btn btn-primary" id="modify_like_btn">修改</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
马甲库里总共可用马甲为4902条,如果要全部导入,须分5批导入,每批1000条
offset:导入马甲的起始序号,第一次填0,后面会自动根据导入的批量累加<br>
limit:每批次导入马甲的数量<br>
(ps:不会的不要乱添加,否则后果自负!!!)<br>
<p>马甲库里总共可用马甲为4902条,如果要全部导入,须分5批导入,每批1000条</p>
<p>offset:导入马甲的起始序号,第一次填0,后面会自动根据导入的批量累加</p>
<p>limit:每批次导入马甲的数量</p>
<p>(ps:不会的不要乱添加,否则后果自负!!!)</p>
</div>
<script>
$(function(){
... ... @@ -59,5 +107,48 @@ $this->title = '管理后台首页';
$("#btn_bar").html(import_html);
},'json');
});
//查询房间信息
$('#search_audi_btn').live("click",function(){
var room_id = $('#room_id').val();
if(room_id == '')
return;
$.post("/system/getaudnums",{room_id:room_id},function(data){
if(data.code==200){
var values = data.data;
$("#actual_num").val(values.audience);
$("#addup_num").val(values.addup);
$("#result_num").val(Number(values.audience)+Number(values.addup)*10);
$("#like_num").val(values.like);
}
},'json')
});
//修改观看数
$('#modify_addup_btn').live("click",function(){
var room_id = $('#room_id').val();
var addup_num = $('#addup_num').val();
if(room_id == '')
return;
modify_cache(room_id,'addup',addup_num);
});
//修改点赞数
$('#modify_like_btn').live("click",function(){
var room_id = $('#room_id').val();
var like_num = $('#like_num').val();
if(room_id == '')
return;
modify_cache(room_id,'like',like_num);
});
function modify_cache(room_id,cache_key,cache_val) {
$.post("/system/modifycache",{room_id:room_id,cache_key:cache_key,cache_val:cache_val},function(data){
if(data.code==200) {
alert(data.msg);
}else {
alert(data.msg);
}
},'json')
}
});
</script>
\ No newline at end of file
... ...