Authored by wuxiao

修复直播详情的点赞人数和观看人数bug

修复短缓存bug
redis库使用5
@@ -11,7 +11,7 @@ return [ @@ -11,7 +11,7 @@ return [
11 'hostname' => '123.56.138.21', 11 'hostname' => '123.56.138.21',
12 'password' => 'yohoglobal', 12 'password' => 'yohoglobal',
13 'port' => 6379, 13 'port' => 6379,
14 - 'database' => 0, 14 + 'database' => 5,
15 ], 15 ],
16 'redisIm' => [ 16 'redisIm' => [
17 'class' => 'yii\redis\Connection', 17 'class' => 'yii\redis\Connection',
@@ -89,7 +89,7 @@ class LivingController extends BaseController @@ -89,7 +89,7 @@ class LivingController extends BaseController
89 }else{ 89 }else{
90 Yii::$app->db->cache(function() use (&$ret){ 90 Yii::$app->db->cache(function() use (&$ret){
91 $_ret = json_decode($ret,true); 91 $_ret = json_decode($ret,true);
92 - $models = RoomNums::find()->where(['app'=>$this->app])->indexBy('room_id')->all(); 92 + $models = RoomNums::find()->indexBy('room_id')->all();
93 foreach ($_ret as $k=>$row){ 93 foreach ($_ret as $k=>$row){
94 if (!empty($models[$row['room_id']]->online_num)){ 94 if (!empty($models[$row['room_id']]->online_num)){
95 $row['audience_num'] = (int)$models[$row['room_id']]->online_num;//在线人数 95 $row['audience_num'] = (int)$models[$row['room_id']]->online_num;//在线人数
@@ -216,11 +216,16 @@ class LivingController extends BaseController @@ -216,11 +216,16 @@ class LivingController extends BaseController
216 'rtmp_downstream_address'=>'', 216 'rtmp_downstream_address'=>'',
217 'flv_downstream_address'=>'', 217 'flv_downstream_address'=>'',
218 'hls_downstream_address'=>'', 218 'hls_downstream_address'=>'',
  219 + 'live_last_time'=>0,
219 ]; 220 ];
220 221
221 //直播时长(秒) 222 //直播时长(秒)
222 if ($model->living == 2){ 223 if ($model->living == 2){
223 - $ret['live_last_time'] = $model->videoLast ? $model->videoLast->live_end_time-$model->videoLast->live_start_time : 0; 224 + if ($model->videoLast){
  225 + $ret['live_last_time'] = max($model->videoLast->live_end_time-$model->videoLast->live_start_time,0);
  226 + $ret['like_num'] = $model->videoLast->like_num;
  227 + $ret['audience_num'] = $model->videoLast->audience_num;
  228 + }
224 } 229 }
225 230
226 /*if ($model->roomNums){ 231 /*if ($model->roomNums){