61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Api\User;
|
|
|
|
use App\Model\User;
|
|
use App\Model\UserInvite;
|
|
use App\Service\Api\BaseService;
|
|
use App\Service\ServiceTrait\Api\GetUserInfoTrait;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
class InviteListService extends BaseService
|
|
{
|
|
use GetUserInfoTrait;
|
|
|
|
/**
|
|
* @var UserInvite $userInviteModel
|
|
*/
|
|
#[Inject]
|
|
protected UserInvite $userInviteModel;
|
|
|
|
/**
|
|
* @var User
|
|
*/
|
|
#[Inject]
|
|
protected User $userModel;
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function handle(): array
|
|
{
|
|
$limit = $this->request->input('limit', 20);
|
|
|
|
$list = $this->userInviteModel
|
|
->where('invitee_user_id', $this->userId)
|
|
->orderBy('id', 'desc')
|
|
->paginate($limit)
|
|
->toArray();
|
|
|
|
if (!empty($list['data'])) {
|
|
$userIds = array_column($list['data'], 'user_id');
|
|
$userInfoArr = $this->userModel->getInfoByIds($userIds);
|
|
|
|
foreach ($list['data'] as &$item) {
|
|
$item['user_nick_name'] = $userInfoArr[$item['user_id']]['nick_name'];
|
|
}
|
|
}
|
|
|
|
$userInfo = $this->getUserInfo($this->userId);
|
|
|
|
return $this->return->success('success',['list' => $list,'invite_code'=> $userInfo['invite_code']]);
|
|
}
|
|
} |