67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\User;
|
|
use GuzzleHttp\Client;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class CheckFriend implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected User $user;
|
|
|
|
public function __construct(User $user)
|
|
{
|
|
$this->user = $user;
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
$imParams = [
|
|
'From_Account' => (string) $this->user->id,
|
|
'StartIndex' => 0,
|
|
'StandardSequence' => 0,
|
|
'CustomSequence' => 0,
|
|
];
|
|
|
|
$vars = app('im')->send('sns', 'friend_get', $imParams);
|
|
|
|
$this->user->f = count($vars['UserDataItem']);
|
|
|
|
$params = [
|
|
'jsonrpc' => '2.0',
|
|
'id' => 1,
|
|
'method' => 'Chain33.Query',
|
|
'params' => [
|
|
[
|
|
'execer' => 'chat',
|
|
'funcName' => 'GetFriends',
|
|
'payload' => [
|
|
'mainAddress' => $this->user->username,
|
|
'count' => 2000,
|
|
]
|
|
]
|
|
],
|
|
];
|
|
$client = new Client([
|
|
'base_uri' => '152.136.224.167:8901'
|
|
]);
|
|
$result = $client->post('', [
|
|
'body' => json_encode($params),
|
|
]);
|
|
|
|
$json = json_decode($result->getBody()->getContents(), true);
|
|
$collect = count($json['result']['friends']);
|
|
$this->user->c = $collect;
|
|
|
|
$this->user->save();
|
|
}
|
|
}
|