更新直播送礼

This commit is contained in:
yaooo 2023-10-26 15:39:42 +08:00
parent 2b46d24977
commit 69948eed13

View File

@ -30,6 +30,9 @@ use GuzzleHttp\Client;
*/
class Zhibo extends BaseController
{
private $checkUrl = 'https://ceshi-zhibo.lihaink.cn/api/zhibo/checkGift';
private $giftUrl = 'https://ceshi-zhibo.lihaink.cn/api/zhibo/sendGiftMessage';
//用户直播送礼
public function reward()
{
@ -40,9 +43,8 @@ class Zhibo extends BaseController
}
$token = request()->header('x-token');
//查询直播间及礼物接口,验证直播间信息及礼物信息
$checkUrl = 'https://ceshi-zhibo.lihaink.cn/api/zhibo/checkGift';
$client = new Client();
$response = $client->request('POST', $checkUrl, [
$response = $client->request('POST', $this->checkUrl, [
'verify' => false,
'headers' => ['X-Token' => $token],
'json' => [
@ -106,16 +108,16 @@ class Zhibo extends BaseController
} catch (Exception $e) {
return app('json')->fail($e->getMessage());
}
$message = "{$user['nickname']}送出了{$params['gift_name']}";
//发送礼物消息
$giftUrl = 'https://ceshi-zhibo.lihaink.cn/api/zhibo/sendGiftMessage';
$message = "{$user['nickname']} 送出了 {$params['gift_name']}";
$client = new Client();
$client->request('POST', $giftUrl, [
$client->request('POST', $this->giftUrl, [
'verify' => false,
'headers' => ['X-Token' => $token],
'json' => [
"live_stream_id" => $params['live_stream_id'],
"app_name" => 'shop',
"gift_id" => $params['gift_id'],
"message" => $message
]
]);
@ -131,7 +133,7 @@ class Zhibo extends BaseController
if (empty($params['type'])) {
return app('json')->fail('类型不能为空');
}
$user = $this->request->userInfo();
$user = $this->request->userInfo();
$where = [];
if ($params['type'] == 1) {
// 送出的礼物
@ -157,7 +159,7 @@ class Zhibo extends BaseController
'uzo.amount',
'ub.title',
'uzo.create_time'
])->fetchSql(false)->select();
])->select();
return app('json')->success(compact('count', 'list'));
}
}