|
@@ -13,6 +13,7 @@ namespace App\Services;
|
|
|
|
|
|
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
|
|
|
use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
|
|
|
+use App\Models\LiveGiftModel;
|
|
|
use App\Models\LiveModel;
|
|
|
use App\Models\MemberModel;
|
|
|
use App\Models\VideoCollectModel;
|
|
@@ -293,6 +294,52 @@ class LiveService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取直播间礼物列表
|
|
|
+ * @param $params
|
|
|
+ * @param $pageSize
|
|
|
+ * @param int $userId
|
|
|
+ * @return array|mixed
|
|
|
+ */
|
|
|
+ public function getGiftList($params, $pageSize=30, $userId=0)
|
|
|
+ {
|
|
|
+ $liveId = isset($params['live_id'])? $params['live_id'] : 0;
|
|
|
+ $cachekey = "caches:live:gift_{$liveId}_{$userId}";
|
|
|
+ $datas = RedisService::get($cachekey);
|
|
|
+ if($datas || RedisService::exists($cachekey)){
|
|
|
+ return $datas? $datas : [
|
|
|
+ 'pageSize'=> $pageSize,
|
|
|
+ 'total' => 0,
|
|
|
+ 'list' => []
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = LiveGiftModel::from('live_gift as a')
|
|
|
+ ->where(['a.status'=>1,'a.mark'=>1])
|
|
|
+ ->select(['a.id','a.name','a.code','a.money','a.icon','a.file_url','a.sort'])
|
|
|
+ ->orderBy('a.sort','desc')
|
|
|
+ ->orderBy('a.create_time','asc')
|
|
|
+ ->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
+ $list = $list ? $list->toArray() : [];
|
|
|
+ if ($list && $list['data']) {
|
|
|
+ foreach ($list['data'] as &$item) {
|
|
|
+ $item['icon'] = isset($member['icon']) && $member['icon']? get_image_url($member['icon']) : get_image_url('/images/gift/0.png');
|
|
|
+ $item['file_url'] = isset($member['file_url']) && $member['file_url']? get_image_url($member['file_url']) : '';
|
|
|
+ }
|
|
|
+ RedisService::set($cachekey, [
|
|
|
+ 'pageSize' => $pageSize,
|
|
|
+ 'total' => isset($list['total']) ? $list['total'] : 0,
|
|
|
+ 'list' => isset($list['data']) ? $list['data'] : []
|
|
|
+ ], rand(5,10));
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'pageSize' => $pageSize,
|
|
|
+ 'total' => isset($list['total']) ? $list['total'] : 0,
|
|
|
+ 'list' => isset($list['data']) ? $list['data'] : []
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 更新播放浏览历史
|
|
|
* @param $userId 用户ID
|
|
|
* @param $id 视频ID
|