Authored by xiaofeng.yao@yoho.cn

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

@@ -70,7 +70,8 @@ class SystemController extends BaseController @@ -70,7 +70,8 @@ class SystemController extends BaseController
70 } 70 }
71 } 71 }
72 72
73 - public function actionVest(){ 73 + public function actionVest()
  74 + {
74 $cache_prefix = Yii::$app->params['cache_prefix']; 75 $cache_prefix = Yii::$app->params['cache_prefix'];
75 $imVestNums = Yii::$app->redisIm->llen($cache_prefix.'vest_users'); 76 $imVestNums = Yii::$app->redisIm->llen($cache_prefix.'vest_users');
76 if(Yii::$app->request->isAjax){ 77 if(Yii::$app->request->isAjax){
@@ -101,5 +102,61 @@ class SystemController extends BaseController @@ -101,5 +102,61 @@ class SystemController extends BaseController
101 return $this->render('vest',['imVestNums'=>$imVestNums]); 102 return $this->render('vest',['imVestNums'=>$imVestNums]);
102 } 103 }
103 104
  105 + public function actionGetaudnums()
  106 + {
  107 + $cache_prefix = Yii::$app->params['cache_prefix'];
  108 + $room_id = trim(Yii::$app->request->post('room_id'));
  109 + $ret = [
  110 + 'audience'=>0,
  111 + 'like'=>0,
  112 + 'addup'=>0,
  113 + ];
  114 + if($room_id) {
  115 + $keys = [
  116 + 'audience'=>$cache_prefix.'audience_nums_room_'.$room_id,
  117 + 'like'=>$cache_prefix.'like_numbers_room_'.$room_id,
  118 + 'addup'=>$cache_prefix.'addup_num_'.$room_id,
  119 + ];
  120 + $index = array_keys($keys);
  121 + $values = $keys ? call_user_func_array(array(Yii::$app->redisIm,'mget'), $keys) : [];
  122 + foreach ($values as $k=>$v) {
  123 + $ret[$index[$k]] = $v ? :0;
  124 + }
  125 + }
  126 + $data = [
  127 + 'code'=>'200',
  128 + 'msg'=>'',
  129 + 'data'=>$ret
  130 + ];
  131 + echo json_encode($data);exit;
  132 + }
104 133
  134 + public function actionModifycache()
  135 + {
  136 + $cache_prefix = Yii::$app->params['cache_prefix'];
  137 + $room_id = trim(Yii::$app->request->post('room_id'));
  138 + $cache_key = trim(Yii::$app->request->post('cache_key'));
  139 + $cache_val = trim(Yii::$app->request->post('cache_val'));
  140 + if($room_id && $cache_key && $cache_val){
  141 + $expire = 86400;
  142 + if($cache_key == 'addup'){
  143 + $res = Yii::$app->redisIm->setex($cache_prefix.'addup_num_'.$room_id,$expire,$cache_val);
  144 + }
  145 + if($cache_key == 'like'){
  146 + $res = Yii::$app->redisIm->setex($cache_prefix.'like_numbers_room_'.$room_id,$expire,$cache_val);
  147 + }
  148 + $data = [
  149 + 'code'=>'200',
  150 + 'msg'=>'修改成功',
  151 + 'data'=>$res
  152 + ];
  153 + }else{
  154 + $data = [
  155 + 'code'=>'400',
  156 + 'msg'=>'参数不能为空',
  157 + 'data'=>''
  158 + ];
  159 + }
  160 + echo json_encode($data);exit;
  161 + }
105 } 162 }
@@ -5,10 +5,11 @@ $this->title = '管理后台首页'; @@ -5,10 +5,11 @@ $this->title = '管理后台首页';
5 ?> 5 ?>
6 6
7 <div class="col-md-6"> 7 <div class="col-md-6">
8 - <p><span>剩余马甲数:</span><?php echo $imVestNums?></p> 8 +
9 <div class="panel panel-default"> 9 <div class="panel panel-default">
10 <div class="panel-heading"> 10 <div class="panel-heading">
11 <h5 class="panel-title">导入马甲</h5> 11 <h5 class="panel-title">导入马甲</h5>
  12 + <p>剩余马甲数:<?php echo $imVestNums?></p>
12 </div> 13 </div>
13 <div class="panel-body"> 14 <div class="panel-body">
14 15
@@ -30,12 +31,59 @@ $this->title = '管理后台首页'; @@ -30,12 +31,59 @@ $this->title = '管理后台首页';
30 31
31 </div> 32 </div>
32 </div> 33 </div>
  34 + <div class="panel panel-default">
  35 + <div class="panel-heading">
  36 + <h5 class="panel-title">查看观看人数</h5>
  37 + </div>
  38 + <div class="panel-body">
  39 + <div class="form-group">
  40 + <label class="col-sm-3 control-label">请输入房间号:</label>
  41 + <div class="col-sm-3">
  42 + <input type="text" class="form-control" id="room_id" name="room_id" >
  43 + </div>
  44 + <div class="col-sm-4">
  45 + <button type="button" class="btn btn-primary mr5" id="search_audi_btn">查询</button>
  46 + </div>
  47 + </div>
  48 + <div class="form-group">
  49 + <label class="col-sm-3 control-label">观看数:</label>
  50 + <div class="col-sm-2">
  51 + <input type="text" class="form-control" id="actual_num" disabled>
  52 + </div>
  53 + <div class="col-sm-1">
  54 + +
  55 + </div>
  56 + <div class="col-sm-2">
  57 + <input type="text" class="form-control" id="addup_num">
  58 + </div>
  59 + <div class="col-sm-1">
  60 + *10 =
  61 + </div>
  62 + <div class="col-sm-2">
  63 + <input type="text" class="form-control" id="result_num" disabled>
  64 + </div>
  65 + <div class="col-sm-1">
  66 + <button type="button" class="btn btn-primary" id="modify_addup_btn">修改</button>
  67 + </div>
  68 + </div>
  69 + <div class="form-group">
  70 + <label class="col-sm-3 control-label">点赞数:</label>
  71 + <div class="col-sm-3">
  72 + <input type="text" class="form-control" id="like_num">
  73 + </div>
  74 + <div class="col-sm-1">
  75 + <button type="button" class="btn btn-primary" id="modify_like_btn">修改</button>
  76 + </div>
  77 + </div>
  78 +
  79 + </div>
  80 + </div>
33 </div> 81 </div>
34 <div class="col-md-6"> 82 <div class="col-md-6">
35 - 马甲库里总共可用马甲为4902条,如果要全部导入,须分5批导入,每批1000条  
36 - offset:导入马甲的起始序号,第一次填0,后面会自动根据导入的批量累加<br>  
37 - limit:每批次导入马甲的数量<br>  
38 - (ps:不会的不要乱添加,否则后果自负!!!)<br> 83 + <p>马甲库里总共可用马甲为4902条,如果要全部导入,须分5批导入,每批1000条</p>
  84 + <p>offset:导入马甲的起始序号,第一次填0,后面会自动根据导入的批量累加</p>
  85 + <p>limit:每批次导入马甲的数量</p>
  86 + <p>(ps:不会的不要乱添加,否则后果自负!!!)</p>
39 </div> 87 </div>
40 <script> 88 <script>
41 $(function(){ 89 $(function(){
@@ -59,5 +107,48 @@ $this->title = '管理后台首页'; @@ -59,5 +107,48 @@ $this->title = '管理后台首页';
59 $("#btn_bar").html(import_html); 107 $("#btn_bar").html(import_html);
60 },'json'); 108 },'json');
61 }); 109 });
  110 + //查询房间信息
  111 + $('#search_audi_btn').live("click",function(){
  112 +
  113 + var room_id = $('#room_id').val();
  114 + if(room_id == '')
  115 + return;
  116 + $.post("/system/getaudnums",{room_id:room_id},function(data){
  117 + if(data.code==200){
  118 + var values = data.data;
  119 + $("#actual_num").val(values.audience);
  120 + $("#addup_num").val(values.addup);
  121 + $("#result_num").val(Number(values.audience)+Number(values.addup)*10);
  122 + $("#like_num").val(values.like);
  123 + }
  124 + },'json')
  125 + });
  126 + //修改观看数
  127 + $('#modify_addup_btn').live("click",function(){
  128 +
  129 + var room_id = $('#room_id').val();
  130 + var addup_num = $('#addup_num').val();
  131 + if(room_id == '')
  132 + return;
  133 + modify_cache(room_id,'addup',addup_num);
  134 + });
  135 + //修改点赞数
  136 + $('#modify_like_btn').live("click",function(){
  137 +
  138 + var room_id = $('#room_id').val();
  139 + var like_num = $('#like_num').val();
  140 + if(room_id == '')
  141 + return;
  142 + modify_cache(room_id,'like',like_num);
  143 + });
  144 + function modify_cache(room_id,cache_key,cache_val) {
  145 + $.post("/system/modifycache",{room_id:room_id,cache_key:cache_key,cache_val:cache_val},function(data){
  146 + if(data.code==200) {
  147 + alert(data.msg);
  148 + }else {
  149 + alert(data.msg);
  150 + }
  151 + },'json')
  152 + }
62 }); 153 });
63 </script> 154 </script>