更新直播送礼

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