Update RegisterService.php

This commit is contained in:
全栈小学生 2023-06-02 10:41:44 +08:00
parent 7eae3e6696
commit 8cd76874c5

View File

@ -39,7 +39,7 @@ class RegisterService extends BaseApiService
* 会员公共注册 * 会员公共注册
* @param $data * @param $data
*/ */
public function register(string|int $mobile, $data, string $type, bool $is_verify_mobile = true) public function register(string $mobile, $data, string $type, bool $is_verify_mobile = true)
{ {
//校验注册方式 //校验注册方式
if (empty(MemberRegisterTypeDict::getType()[ $type ])) if (empty(MemberRegisterTypeDict::getType()[ $type ]))
@ -50,7 +50,13 @@ class RegisterService extends BaseApiService
$member_id = $data; $member_id = $data;
} else { } else {
if (empty($data[ 'nickname' ])) { if (empty($data[ 'nickname' ])) {
$data['nickname'] = $data['username'] ?? !empty($mobile) ? substr_replace($mobile, '****', 3, 4) : $this->createName(); if (!empty($data[ 'username' ])) {
$data[ 'nickname' ] = $data[ 'username' ];
} elseif (!empty($mobile)) {
$data[ 'nickname' ] = substr_replace($mobile, '****', 3, 4);
} else {
$data[ 'nickname' ] = $this->createName();
}
} }
$data[ 'register_channel' ] = $this->channel; $data[ 'register_channel' ] = $this->channel;
$data[ 'register_type' ] = $type; $data[ 'register_type' ] = $type;
@ -87,6 +93,7 @@ class RegisterService extends BaseApiService
return $microtime . strtoupper(base_convert(time() - 1420070400, 10, 36)) . $username; return $microtime . strtoupper(base_convert(time() - 1420070400, 10, 36)) . $username;
} }
/** /**
* 账号注册 * 账号注册
* @param string $username * @param string $username
@ -120,7 +127,9 @@ class RegisterService extends BaseApiService
* @param $mobile * @param $mobile
* @return Member|array|mixed|\think\Model * @return Member|array|mixed|\think\Model
*/ */
public function mobile($mobile){ public
function mobile($mobile)
{
//登录注册配置 //登录注册配置
$config = ( new MemberConfigService() )->getLoginConfig(); $config = ( new MemberConfigService() )->getLoginConfig();
$is_mobile = $config[ 'is_mobile' ]; $is_mobile = $config[ 'is_mobile' ];
@ -141,7 +150,9 @@ class RegisterService extends BaseApiService
* 校验是否启用第三方登录注册 * 校验是否启用第三方登录注册
* @return true * @return true
*/ */
public function checkAuth(){ public
function checkAuth()
{
$config = ( new MemberConfigService() )->getLoginConfig(); $config = ( new MemberConfigService() )->getLoginConfig();
$is_auth_register = $config[ 'is_auth_register' ]; $is_auth_register = $config[ 'is_auth_register' ];
if ($is_auth_register != 1) throw new AuthException('AUTH_LOGIN_NOT_OPEN');//手机号已存在 if ($is_auth_register != 1) throw new AuthException('AUTH_LOGIN_NOT_OPEN');//手机号已存在
@ -156,7 +167,8 @@ class RegisterService extends BaseApiService
* @param bool $is_verify * @param bool $is_verify
* @return array|mixed * @return array|mixed
*/ */
public function bindByMobile(string|int $mobile, array $data, string $type, bool $is_verify = true){ public
function bindByMobile(string|int $mobile, array $data, string $type, bool $is_verify = true){
$config = ( new MemberConfigService() )->getLoginConfig(); $config = ( new MemberConfigService() )->getLoginConfig();
$is_bind_mobile = $config[ 'is_bind_mobile' ]; $is_bind_mobile = $config[ 'is_bind_mobile' ];