feat : user
This commit is contained in:
@@ -24,16 +24,20 @@ use App\Model\CouponTemplate;
|
||||
use App\Model\User;
|
||||
use App\Model\UserAccount;
|
||||
use App\Model\UserCoupon;
|
||||
use App\Model\UserInvite;
|
||||
use App\Model\UserThird;
|
||||
use App\Service\Api\BaseService;
|
||||
use App\Service\ServiceTrait\Api\GetUserInfoTrait;
|
||||
use App\Service\ServiceTrait\Common\UserTrait;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Random\RandomException;
|
||||
|
||||
abstract class LoginBaseService extends BaseService
|
||||
{
|
||||
use GetUserInfoTrait;
|
||||
use GetUserInfoTrait,
|
||||
UserTrait;
|
||||
|
||||
/**
|
||||
* 注入缓存类
|
||||
@@ -62,6 +66,12 @@ abstract class LoginBaseService extends BaseService
|
||||
#[Inject]
|
||||
protected ConfigCache $configCache;
|
||||
|
||||
/**
|
||||
* @var UserInvite $userInviteModel
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserInvite $userInviteModel;
|
||||
|
||||
|
||||
/**
|
||||
* 锁定注册
|
||||
@@ -240,5 +250,41 @@ abstract class LoginBaseService extends BaseService
|
||||
$this->isNewcomerCouponPopUp = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws RandomException
|
||||
*/
|
||||
protected function addInviteCode(): void
|
||||
{
|
||||
$inviteCode = $this->generateStableCode($this->userId);
|
||||
|
||||
if ($this->userModel->checkInviteCodeIsUse($inviteCode) == 1) return;
|
||||
|
||||
if (!$this->userModel->where('id', $inviteCode)->update(['invite_code' => $inviteCode])) throw new ErrException('注册失败-00004');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function checkInvite(): void
|
||||
{
|
||||
if (!$this->request->input('invite_code')) return;
|
||||
|
||||
$userId = $this->userModel->getUserIdByInviteCode($this->request->input('invite_code'));
|
||||
|
||||
if (empty($userId)) return;
|
||||
|
||||
if ($this->userInviteModel->checkIsInvite($this->userId) == 1) return;
|
||||
|
||||
$userInviteModel = new UserInvite();
|
||||
|
||||
$userInviteModel->user_id = $this->userId;
|
||||
$userInviteModel->invitee_user_id = $userId;
|
||||
$userInviteModel->channel = UserCode::INVITE_CHANNEL_USER; //todo 预先普通用户渠道
|
||||
$userInviteModel->status = UserCode::INVITE_STATUS_REGISTER;
|
||||
|
||||
if (!$userInviteModel->save()) throw new ErrException('注册失败-00005');
|
||||
}
|
||||
|
||||
abstract protected function register();
|
||||
}
|
||||
Reference in New Issue
Block a user