You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/application/web/model/live/LiveBarrage.php

80 lines
3.4 KiB

10 months ago
<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace app\web\model\live;
use basic\ModelBasic;
use service\SystemConfigService;
use traits\ModelTrait;
use app\web\model\user\User;
/**直播间评论表
* Class LiveBarrage
* @package app\web\model\live
*/
class LiveBarrage extends ModelBasic
{
use ModelTrait;
public static function getCommentList($uids, $live_id, $page = 0, $limit = 10)
{
$model = self::where('live_id', $live_id)->where('is_show', 1);
if ($uids) $model = $model->where('uid', 'in', $uids);
$list = $model->field('type,barrage as content,uid,live_id,id')->order('add_time desc')->page($page, $limit)->select();
$list = count($list) ? $list->toArray() : [];
$commentList = [];
foreach ($list as &$item) {
$userinfo = User::where('uid', $item['uid'])->field(['nickname', 'avatar'])->find();
$item['nickname'] = $userinfo['nickname'] ? $userinfo['nickname'] : '';
$item['avatar'] = $userinfo['avatar'] ? $userinfo['avatar'] : '';
$type = LiveHonouredGuest::where(['uid' => $item['uid'], 'live_id' => $item['live_id']])->value('type');
if (is_null($type))
$item['user_type'] = 2;
else
$item['user_type'] = $type;
if ($item['type'] == 4) {
$live_reward_list = LiveReward::where(['id' => $item['content']])->find();
if ($live_reward_list ? $live_reward_list = $live_reward_list->toArray() : []) {
$live_gift = LiveGift::liveGiftOne($live_reward_list['gift_id']);
if ($live_gift) {
$item['content'] = "赠送给主播";
$item['gift_num'] = $live_reward_list['gift_num'];
$item['gift_image'] = $live_gift ? $live_gift['live_gift_show_img'] : "";
$item['gift_name'] = $live_reward_list['gift_name'];
array_push($commentList, $item);
}
}
} else {
array_push($commentList, $item);
}
}
$page--;
if (count($commentList) == 0 || count($commentList) < $limit) {
$ystemConfig = SystemConfigService::more(['site_name', 'home_logo']);
$data = [
'nickname' => $ystemConfig['site_name'],
'avatar' => $ystemConfig['home_logo'],
'user_type' => 2,
'content' => LiveStudio::where('id', $live_id)->value('auto_phrase'),
'id' => 0,
'type' => 1,
'uid' => 0
];
array_push($commentList, $data);
}
return ['list' => $commentList, 'page' => $page];
}
}