1.优化开奖逻辑

2.优化后台开奖派彩
3.优化接口规范
This commit is contained in:
2026-04-17 13:56:13 +08:00
parent 3cf386756b
commit bf3d50a309
50 changed files with 1036 additions and 770 deletions

View File

@@ -27,7 +27,14 @@ class Auth extends \ba\Auth
protected int $keepTime = 86400;
protected int $refreshTokenKeepTime = 2592000;
protected array $allowFields = ['id', 'username', 'nickname', 'email', 'mobile', 'avatar', 'gender', 'birthday', 'money', 'score', 'join_time', 'motto', 'last_login_time', 'last_login_ip'];
/** 注册失败原因:`username`/`email` 表示账号已占用,供接口返回友好提示 */
protected string $registerDuplicateKind = '';
protected array $allowFields = [
'id', 'username', 'nickname', 'email', 'phone', 'avatar', 'gender', 'birthday',
'coin', 'channel_id', 'risk_flags', 'uuid',
'join_time', 'motto', 'last_login_time', 'last_login_ip',
];
public function __construct(array $config = [])
{
@@ -73,7 +80,7 @@ class Auth extends \ba\Auth
return false;
}
$this->token = $token;
$this->loginSuccessful();
$this->loginEd = true;
return true;
}
}
@@ -84,6 +91,7 @@ class Auth extends \ba\Auth
public function register(string $username, string $password = '', string $phone = '', string $email = '', int $group = 1, array $extend = []): bool
{
$this->registerDuplicateKind = '';
$request = function_exists('request') ? request() : null;
$ip = $request ? $request->getRealIp() : '0.0.0.0';
@@ -98,13 +106,20 @@ class Auth extends \ba\Auth
return false;
}
if (User::where('email', $email)->find() && $email) {
$this->registerDuplicateKind = 'email';
$this->setError(__('Email') . ' ' . __('already exists'));
return false;
}
if (User::where('username', $username)->find()) {
$this->registerDuplicateKind = 'username';
$this->setError(__('Username') . ' ' . __('already exists'));
return false;
}
if ($phone !== '' && User::where('phone', $phone)->find()) {
$this->registerDuplicateKind = 'phone';
$this->setError(__('Mobile') . ' ' . __('already exists'));
return false;
}
$nickname = preg_replace_callback('/1[3-9]\d{9}/', fn($m) => substr($m[0], 0, 3) . '****' . substr($m[0], 7), $username);
$time = time();
@@ -116,6 +131,8 @@ class Auth extends \ba\Auth
'last_login_ip' => $ip,
'last_login_time' => $time,
'status' => 1,
'uuid' => User::generateUniquePublicCode10(),
'remark' => User::formatLoginRemark($time, $ip),
];
$data = array_merge(compact('username', 'password', 'phone', 'email'), $data, $extend);
@@ -215,6 +232,7 @@ class Auth extends \ba\Auth
$this->model->login_failure = 0;
$this->model->last_login_time = time();
$this->model->last_login_ip = $ip;
$this->model->remark = User::formatLoginRemark(time(), $ip);
$this->model->save();
$this->loginEd = true;
$this->model->commit();
@@ -344,6 +362,11 @@ class Auth extends \ba\Auth
return $this->error ? __($this->error) : '';
}
public function getRegisterDuplicateKind(): string
{
return $this->registerDuplicateKind;
}
protected function reset(bool $deleteToken = true): bool
{
if ($deleteToken && $this->token) {
@@ -353,6 +376,7 @@ class Auth extends \ba\Auth
$this->loginEd = false;
$this->model = null;
$this->refreshToken = '';
$this->registerDuplicateKind = '';
$this->setError('');
$this->setKeepTime((int)config('buildadmin.user_token_keep_time', 86400));
return true;