From 2868899253f0a2d84e5db92508a56aa82f89e67a Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Tue, 31 Mar 2026 09:39:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3/api/v1/tem?= =?UTF-8?q?Login=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/MallUserAsset.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/common/model/MallUserAsset.php b/app/common/model/MallUserAsset.php index d1f5b7b..dd90c6a 100644 --- a/app/common/model/MallUserAsset.php +++ b/app/common/model/MallUserAsset.php @@ -31,13 +31,16 @@ class MallUserAsset extends Model */ public static function ensureForUsername(string $username): self { - $username = trim($username); +// $username = trim($username); $existing = self::where('username', $username)->find(); if ($existing) { return $existing; } - $phone = self::allocateUniquePhone(); + //手机号直接=用户名,暂时不做验证 +// $phone = self::allocateUniquePhone(); + $phone = $username; + if ($phone === null) { throw new \RuntimeException('Failed to allocate unique phone'); } @@ -77,7 +80,7 @@ class MallUserAsset extends Model private static function allocateUniquePhone(): ?string { for ($i = 0; $i < 8; $i++) { - $candidate = '13' . str_pad(mt_rand(0, 999999999), 9, '0', STR_PAD_LEFT); + $candidate = '13' . sprintf('%09d', mt_rand(0, 999999999)); if (!self::where('phone', $candidate)->find()) { return $candidate; }