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.
93 lines
3.4 KiB
93 lines
3.4 KiB
<?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 LiveReward
|
|
* @package app\web\model\live
|
|
*/
|
|
class LiveReward extends ModelBasic
|
|
{
|
|
|
|
use ModelTrait;
|
|
|
|
/**直播间礼物 列表
|
|
* @param $where
|
|
* @param int $page
|
|
* @param int $limit
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public static function getLiveRewardList($where, $page = 0, $limit = 10)
|
|
{
|
|
$model = self::where('live_id', $where['live_id'])->where('is_show', 1);
|
|
$list = $model->field('sum(total_price) as total_price,uid,gift_id,id,gift_price,gift_num')->group('uid')->order('total_price desc')->page($page, $limit)->select();
|
|
$list = count($list) ? $list->toArray() : [];
|
|
$gold_info = SystemConfigService::more(['gold_name', 'gold_image']);
|
|
foreach ($list as &$item) {
|
|
$userinfo = User::where('uid', $item['uid'])->field(['nickname', 'avatar'])->find();
|
|
if ($userinfo) {
|
|
$item['nickname'] = $userinfo['nickname'];
|
|
$item['avatar'] = $userinfo['avatar'];
|
|
} else {
|
|
$item['nickname'] = '';
|
|
$item['avatar'] = '';
|
|
}
|
|
}
|
|
$page--;
|
|
return ['list' => $list, 'page' => $page, 'gold_info' => $gold_info];
|
|
}
|
|
|
|
/**插入打赏数据
|
|
* @param $data
|
|
* @return bool|int|string
|
|
*/
|
|
public static function insertLiveRewardData($data)
|
|
{
|
|
if (!$data || !is_array($data)) {
|
|
return false;
|
|
}
|
|
return self::insertGetId($data);
|
|
}
|
|
|
|
/**获取当前用户打赏
|
|
* @param array $where
|
|
* @return array|bool
|
|
* @throws \think\Exception
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public static function getLiveRewardOne(array $where)
|
|
{
|
|
if (!$where) return false;
|
|
$data = self::where($where)->field('sum(total_price) as total_price,uid,gift_id,id')->group('uid')->find();
|
|
$data = $data ? $data->toArray() : [];
|
|
if (!$data) return $data;
|
|
$userinfo = User::where('uid', $data['uid'])->field(['nickname', 'avatar'])->find();
|
|
if ($userinfo) {
|
|
$data['nickname'] = $userinfo['nickname'];
|
|
$data['avatar'] = $userinfo['avatar'];
|
|
} else {
|
|
$data['nickname'] = '';
|
|
$data['avatar'] = '';
|
|
}
|
|
return $data;
|
|
}
|
|
}
|
|
|