Authored by wuxiao

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

修复短缓存bug
redis库使用5
... ... @@ -11,7 +11,7 @@ return [
'hostname' => '123.56.138.21',
'password' => 'yohoglobal',
'port' => 6379,
'database' => 0,
'database' => 5,
],
'redisIm' => [
'class' => 'yii\redis\Connection',
... ...
... ... @@ -89,7 +89,7 @@ class LivingController extends BaseController
}else{
Yii::$app->db->cache(function() use (&$ret){
$_ret = json_decode($ret,true);
$models = RoomNums::find()->where(['app'=>$this->app])->indexBy('room_id')->all();
$models = RoomNums::find()->indexBy('room_id')->all();
foreach ($_ret as $k=>$row){
if (!empty($models[$row['room_id']]->online_num)){
$row['audience_num'] = (int)$models[$row['room_id']]->online_num;//在线人数
... ... @@ -216,11 +216,16 @@ class LivingController extends BaseController
'rtmp_downstream_address'=>'',
'flv_downstream_address'=>'',
'hls_downstream_address'=>'',
'live_last_time'=>0,
];
//直播时长(秒)
if ($model->living == 2){
$ret['live_last_time'] = $model->videoLast ? $model->videoLast->live_end_time-$model->videoLast->live_start_time : 0;
if ($model->videoLast){
$ret['live_last_time'] = max($model->videoLast->live_end_time-$model->videoLast->live_start_time,0);
$ret['like_num'] = $model->videoLast->like_num;
$ret['audience_num'] = $model->videoLast->audience_num;
}
}
/*if ($model->roomNums){
... ...