Authored by xiaofeng.yao@yoho.cn

合并

@@ -9,141 +9,141 @@ $this->title = $this->params['main_title'].'-'.$this->params['sub_title']; @@ -9,141 +9,141 @@ $this->title = $this->params['main_title'].'-'.$this->params['sub_title'];
9 $this->registerJsFile('/js/php.js',array('postion'=>View::POS_END)); 9 $this->registerJsFile('/js/php.js',array('postion'=>View::POS_END));
10 ?> 10 ?>
11 <script type="text/javascript"> 11 <script type="text/javascript">
12 - <?php $this->beginBlock('javascript');?>  
13 - var i = 0;  
14 - var room_id = <?=$room->room_id?>;  
15 - var interval_handle;  
16 - var default_interval = 3;  
17 - /**  
18 - * websocket推送指令  
19 - * @returns {undefined}  
20 - */  
21 - function callWebsocket(callback){  
22 - if (!window.ws || window.ws.readyState === undefined || window.ws.readyState != 1) {  
23 - websocket('192.168.102.17',9501,'/',function(){  
24 - consoleLog('连接服务器');  
25 -  
26 - callback();  
27 - },function(evt){  
28 - consoleLog('收到消息: '+evt.data);  
29 - data = JSON.parse(evt.data);  
30 - if (data.status == 1){  
31 - consoleLog('请求推送成功');  
32 - }else{  
33 - consoleLog('请求推送失败');  
34 - }  
35 - },function(){  
36 - consoleLog('连接已关闭');  
37 - },function(){  
38 - consoleLog('有错误出现');  
39 - });  
40 - }else{ 12 +<?php $this->beginBlock('javascript');?>
  13 +var i = 0;
  14 +var room_id = <?=$room->room_id?>;
  15 +var interval_handle;
  16 +var default_interval = 3;
  17 +/**
  18 + * websocket推送指令
  19 + * @returns {undefined}
  20 + */
  21 +function callWebsocket(callback){
  22 + if (!window.ws || window.ws.readyState === undefined || window.ws.readyState != 1) {
  23 + websocket('192.168.102.17',9501,'/',function(){
  24 + consoleLog('连接服务器');
  25 +
41 callback(); 26 callback();
42 - }  
43 - }  
44 - /**  
45 - * 推送商品列表刷新指令  
46 - * @param {type} product_id  
47 - * @returns {undefined}  
48 - */  
49 - function refreshProduct(){  
50 - if (!confirm('将推送商品列表刷新指令,确定?')){  
51 - return;  
52 - }  
53 -  
54 - callWebsocket(function(){  
55 - consoleLog('');  
56 - consoleLog('发起推送商品列表刷新指令');  
57 -  
58 - cmd = {cmd:10002,room:room_id,msg:'',refresh:'Y'};  
59 - cmd['secret'] = makeSign(cmd);  
60 - delete(cmd['private_key']);  
61 -  
62 - cmd = JSON.stringify(cmd);  
63 - consoleLog('发送消息: '+cmd);  
64 - ws.send(cmd);  
65 - getPushlog(default_interval); 27 + },function(evt){
  28 + consoleLog('收到消息: '+evt.data);
  29 + data = JSON.parse(evt.data);
  30 + if (data.status == 1){
  31 + consoleLog('请求推送成功');
  32 + }else{
  33 + consoleLog('请求推送失败');
  34 + }
  35 + },function(){
  36 + consoleLog('连接已关闭');
  37 + },function(){
  38 + consoleLog('有错误出现');
66 }); 39 });
  40 + }else{
  41 + callback();
67 } 42 }
68 - /**  
69 - * 推送商品  
70 - * @param {type} product_id  
71 - * @returns {undefined}  
72 - */  
73 - function sendProduct(product_id){  
74 - if (!confirm('将推送该商品,确定?')){  
75 - return;  
76 - }  
77 -  
78 - i++;  
79 - if (i>5){  
80 - $('#runtime').html('');  
81 - i = 1;  
82 - }  
83 -  
84 - callWebsocket(function(){  
85 - consoleLog('');  
86 - consoleLog('发起推送,商品ID: '+product_id);  
87 -  
88 - cmd = {cmd:10001,room:room_id,skn:product_id};  
89 - cmd['secret'] = makeSign(cmd);  
90 - delete(cmd['private_key']);  
91 -  
92 - cmd = JSON.stringify(cmd);  
93 - consoleLog('发送消息: '+cmd);  
94 - ws.send(cmd);  
95 - getPushlog(default_interval);  
96 - });  
97 - 43 +}
  44 +/**
  45 + * 推送商品列表刷新指令
  46 + * @param {type} product_id
  47 + * @returns {undefined}
  48 + */
  49 +function refreshProduct(){
  50 + if (!confirm('将推送商品列表刷新指令,确定?')){
  51 + return;
98 } 52 }
99 - /**  
100 - * 监听推送记录  
101 - * @param {type} package  
102 - * @returns {unresolved}  
103 - */  
104 - function getPushlog(interval){  
105 - clearInterval(interval_handle);  
106 -  
107 - if (interval){  
108 - interval_handle = setInterval(function(){  
109 - $.get('/ajax/pushgoodslog','',function(json){  
110 - console.log(json);  
111 - if (json.data){  
112 - consoleLog('监听到推送记录: '+json.data);  
113 - }  
114 - },'json');  
115 - },interval*1000);  
116 - $('#pushlog').text('推送记录监听中...再次点击停止').attr('onclick','getPushlog(false)');  
117 - }else{  
118 - $('#pushlog').text('开始监听推送记录').attr('onclick','getPushlog('+default_interval+')');  
119 - } 53 +
  54 + callWebsocket(function(){
  55 + consoleLog('');
  56 + consoleLog('发起推送商品列表刷新指令');
  57 +
  58 + cmd = {cmd:10002,room:room_id,msg:'',refresh:'Y'};
  59 + cmd['secret'] = makeSign(cmd);
  60 + delete(cmd['private_key']);
  61 +
  62 + cmd = JSON.stringify(cmd);
  63 + consoleLog('发送消息: '+cmd);
  64 + ws.send(cmd);
  65 + getPushlog(default_interval);
  66 + });
  67 +}
  68 +/**
  69 + * 推送商品
  70 + * @param {type} product_id
  71 + * @returns {undefined}
  72 + */
  73 +function sendProduct(product_id){
  74 + if (!confirm('将推送该商品,确定?')){
  75 + return;
120 } 76 }
121 - /**  
122 - * 页面打印发送记录  
123 - * @param {type} msg  
124 - * @returns {undefined}  
125 - */  
126 - function consoleLog(msg){  
127 - $('#runtime').append('&nbsp;'+msg+'<br />'); 77 +
  78 + i++;
  79 + if (i>5){
  80 + $('#runtime').html('');
  81 + i = 1;
  82 + }
  83 +
  84 + callWebsocket(function(){
  85 + consoleLog('');
  86 + consoleLog('发起推送,商品ID: '+product_id);
  87 +
  88 + cmd = {cmd:10001,room:room_id,skn:product_id};
  89 + cmd['secret'] = makeSign(cmd);
  90 + delete(cmd['private_key']);
  91 +
  92 + cmd = JSON.stringify(cmd);
  93 + consoleLog('发送消息: '+cmd);
  94 + ws.send(cmd);
  95 + getPushlog(default_interval);
  96 + });
  97 +
  98 +}
  99 +/**
  100 + * 监听推送记录
  101 + * @param {type} package
  102 + * @returns {unresolved}
  103 + */
  104 +function getPushlog(interval){
  105 + clearInterval(interval_handle);
  106 +
  107 + if (interval){
  108 + interval_handle = setInterval(function(){
  109 + $.get('/ajax/pushgoodslog','',function(json){
  110 + console.log(json);
  111 + if (json.data){
  112 + consoleLog('监听到推送记录: '+json.data);
  113 + }
  114 + },'json');
  115 + },interval*1000);
  116 + $('#pushlog').text('推送记录监听中...再次点击停止').attr('onclick','getPushlog(false)');
  117 + }else{
  118 + $('#pushlog').text('开始监听推送记录').attr('onclick','getPushlog('+default_interval+')');
128 } 119 }
129 - /**  
130 - * 密钥生成  
131 - * @param {type} package  
132 - * @returns {unresolved}  
133 - */  
134 - function makeSign(package){  
135 - package['private_key'] = 'a85bb0674e08986c6b115d5e3a4884fa';  
136 - package = ksort(package);  
137 - packageList = [];  
138 - for (key in package){  
139 - packageList.push(trim(key + '=' + package[key]));  
140 - }  
141 - return strtolower(md5(implode('&', packageList))); 120 +}
  121 +/**
  122 + * 页面打印发送记录
  123 + * @param {type} msg
  124 + * @returns {undefined}
  125 + */
  126 +function consoleLog(msg){
  127 + $('#runtime').append('&nbsp;'+msg+'<br />');
  128 +}
  129 +/**
  130 + * 密钥生成
  131 + * @param {type} package
  132 + * @returns {unresolved}
  133 + */
  134 +function makeSign(package){
  135 + package['private_key'] = 'a85bb0674e08986c6b115d5e3a4884fa';
  136 + package = ksort(package);
  137 + packageList = [];
  138 + for (key in package){
  139 + packageList.push(trim(key + '=' + package[key]));
142 } 140 }
143 - <?php  
144 - $this->endBlock();  
145 - $this->registerJs($this->blocks['javascript'],View::POS_END)  
146 - ?> 141 + return strtolower(md5(implode('&', packageList)));
  142 +}
  143 +<?php
  144 +$this->endBlock();
  145 +$this->registerJs($this->blocks['javascript'],View::POS_END)
  146 +?>
147 </script> 147 </script>
148 148
149 <div class="panel"> 149 <div class="panel">
@@ -163,17 +163,17 @@ $this->registerJsFile('/js/php.js',array('postion'=>View::POS_END)); @@ -163,17 +163,17 @@ $this->registerJsFile('/js/php.js',array('postion'=>View::POS_END));
163 <div class="table-responsive"> 163 <div class="table-responsive">
164 <table class="table mb30"> 164 <table class="table mb30">
165 <thead> 165 <thead>
166 - <tr style="white-space:nowrap">  
167 - <th><input type="checkbox" onclick="checkall(this)">选择</th>  
168 - <th>商品ID</th>  
169 - <th>商品名称</th>  
170 - <th>商品销售价</th>  
171 - <th>排序</th>  
172 - <th>操作</th>  
173 - </tr> 166 + <tr style="white-space:nowrap">
  167 + <th><input type="checkbox" onclick="checkall(this)">选择</th>
  168 + <th>商品ID</th>
  169 + <th>商品名称</th>
  170 + <th>商品销售价</th>
  171 + <th>排序</th>
  172 + <th>操作</th>
  173 + </tr>
174 </thead> 174 </thead>
175 <tbody> 175 <tbody>
176 - <?php foreach ($list as $model):?> 176 + <?php foreach ($list as $model):?>
177 <tr data-stock="1" data-source="1" data-status="2" data-id="5011880"> 177 <tr data-stock="1" data-source="1" data-status="2" data-id="5011880">
178 <td><input type="checkbox" value="<?=$model->id?>" name="product[]"></td> 178 <td><input type="checkbox" value="<?=$model->id?>" name="product[]"></td>
179 <td><?=$model->product_id?></td> 179 <td><?=$model->product_id?></td>
@@ -181,16 +181,16 @@ $this->registerJsFile('/js/php.js',array('postion'=>View::POS_END)); @@ -181,16 +181,16 @@ $this->registerJsFile('/js/php.js',array('postion'=>View::POS_END));
181 <th><?=$model->sales_price?></th> 181 <th><?=$model->sales_price?></th>
182 <td><?=$model->sort?></td> 182 <td><?=$model->sort?></td>
183 <td> 183 <td>
184 - 184 +
185 <a href="/product/edit/<?=$model->id?>" class="btn btn-default btn-white">编辑</a> 185 <a href="/product/edit/<?=$model->id?>" class="btn btn-default btn-white">编辑</a>
186 - 186 +
187 <a onclick="return confirm('删除该商品?')" href="/product/operate/<?=$model->id?>?type=del" class="btn btn-danger btn-metro">删除</a> 187 <a onclick="return confirm('删除该商品?')" href="/product/operate/<?=$model->id?>?type=del" class="btn btn-danger btn-metro">删除</a>
188 - 188 +
189 <a onclick="sendProduct(<?=$model->product_id?>)" href="javascript:;" class="btn btn-danger btn-metro">弹框</a> 189 <a onclick="sendProduct(<?=$model->product_id?>)" href="javascript:;" class="btn btn-danger btn-metro">弹框</a>
190 190
191 </td> 191 </td>
192 </tr> 192 </tr>
193 - <?php endforeach;?> 193 + <?php endforeach;?>
194 </tbody> 194 </tbody>
195 </table> 195 </table>
196 </div> 196 </div>
@@ -4,12 +4,12 @@ return [ @@ -4,12 +4,12 @@ return [
4 'components' => [ 4 'components' => [
5 'fileCache' => [ 5 'fileCache' => [
6 'class' => 'yii\caching\FileCache', 6 'class' => 'yii\caching\FileCache',
7 - 'keyPrefix' => 'YOHOLive', 7 + 'keyPrefix' => 'YOHOLive:',
8 ], 8 ],
9 'cache' => [ 9 'cache' => [
10 'class' => 'common\components\pagecache\Redis', 10 'class' => 'common\components\pagecache\Redis',
11 'redis' => 'redis', 11 'redis' => 'redis',
12 - 'keyPrefix' => 'YOHOLive', 12 + 'keyPrefix' => 'YOHOLive:',
13 ], 13 ],
14 'redis' => [ 14 'redis' => [
15 'class' => 'common\components\caching\RedisCache', 15 'class' => 'common\components\caching\RedisCache',
1 <?php 1 <?php
2 return [ 2 return [
  3 +
3 ]; 4 ];
@@ -91,7 +91,7 @@ class LivingController extends BaseController @@ -91,7 +91,7 @@ class LivingController extends BaseController
91 }else{ 91 }else{
92 $keys = []; 92 $keys = [];
93 foreach ($ret as $k=>$row){ 93 foreach ($ret as $k=>$row){
94 - $keys[] = sprintf("%s:online_nums_room_%s",Yii::$app->params['cache_prefix'],$row['room_id']); 94 + $keys[] = sprintf("%sonline_nums_room_%s",Yii::$app->params['cache_prefix'],$row['room_id']);
95 } 95 }
96 96
97 $values = $keys ? call_user_func_array(array(Yii::$app->redisIm,'mget'), $keys) : []; 97 $values = $keys ? call_user_func_array(array(Yii::$app->redisIm,'mget'), $keys) : [];