From 83b411ff1e53b9f449a52b2e21ce2783fe5e464b Mon Sep 17 00:00:00 2001 From: liyang <2154243450@qq.com> Date: Tue, 2 Sep 2025 14:58:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B3=A8=E5=86=8C=E4=BA=8B=E5=8A=A1+?= =?UTF-8?q?=E6=98=B5=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/home/service/LoginService.php | 12 +++++------- app/home/service/UserService.php | 2 +- app/home/validate/UserValidate.php | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/home/service/LoginService.php b/app/home/service/LoginService.php index cd1f1ae8..efedd90d 100644 --- a/app/home/service/LoginService.php +++ b/app/home/service/LoginService.php @@ -454,7 +454,7 @@ class LoginService extends BaseHomeService // 校验验证码 $mobile = $param['nation'] . ltrim($param['phone'], '0'); - // $mobile = $param['nation'] . $param['phone']; + $smsKey = 'DB:USER:UNLOGIN:SMS_CODE:' . $mobile; if (!$this->checkCode($smsKey, $param['sms_code'])) { //注册验证码 @@ -464,7 +464,6 @@ class LoginService extends BaseHomeService } } - // 手机号是否已经存在 $phoneExists = UserModel::checkPhoneExists($param['phone']); if ($phoneExists) { @@ -569,7 +568,7 @@ class LoginService extends BaseHomeService $chatUrl = env('CHAT_SERVER.BASE_URL') . '/api/user/register'; $chatRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatUrl, $chatData); if (!isset($chatRes['data']['uuid'])) { - return $this->toData('500', lang('account_registration_failed')); + throw new \Exception(lang('account_registration_failed')); } // 绑定注册账号与聊天账号 UserChatLinkModel::create([ @@ -584,7 +583,7 @@ class LoginService extends BaseHomeService $customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID Log::info("手机号注册 - 获取客服列表结果==" . json_encode($customerIds)); if (empty($customerIds)) { - return $this->toData('500', lang('account_registration_failed')); + throw new \Exception(lang('account_registration_failed')); } $counterKey = 'counter_of_bind_customer:' . $agentId; $counterIndex = Cache::store('redis')->get($counterKey); //客服绑定计数器索引 @@ -604,7 +603,7 @@ class LoginService extends BaseHomeService // 将注册账号的chat_id与绑定客服的chat_id加为好友 $customerChatInfo = UserChatLinkModel::where(['user_id' => $tagCustomerId, 'user_type' => UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); //查询客服的聊天账号uuid if (empty($customerChatInfo)) { - return $this->toData('100400', 'The customer uuid is error.', []); + throw new \Exception('The customer uuid is error.'); } $chatFriendsData = [ 'UserUuid' => $chatRes['data']['uuid'], @@ -616,7 +615,7 @@ class LoginService extends BaseHomeService // 将当前用户加入到代理创建的群聊中 【需要查出当前用户的代理创建的群聊信息】 $agentGroup = UserChatGroupModel::where(['user_id' => $agentId, 'remark' => UserChatGroupModel::USER_CHAT_GROUP_REMARK_ADMIN_INIT])->find(); if (empty($agentGroup)) { - return $this->toData('500', lang('account_registration_failed')); + throw new \Exception(lang('account_registration_failed')); } $joinChatGroupUrl = env('CHAT_SERVER.BASE_URL') . '/api/group/join/' . $chatRes['data']['uuid'] . '/' . $agentGroup->group_uuid; $joinChatGroupRes = (new \app\utility\RequestChatServer())->ReqChatServer($joinChatGroupUrl, []); @@ -639,7 +638,6 @@ class LoginService extends BaseHomeService return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); } } - /** * @desc 短信验证码登陆 * @param array $param diff --git a/app/home/service/UserService.php b/app/home/service/UserService.php index 732422aa..dc4f56d1 100644 --- a/app/home/service/UserService.php +++ b/app/home/service/UserService.php @@ -634,7 +634,7 @@ class UserService extends BaseHomeService } $user->nick_name = $param['nick_name']; $user->gender = $param['gender']; - $user->lastName = $param['last_name'] ?? $user->lastName; + $user->last_name = $param['last_name'] ?? $user->last_name; $user->first_name = $param['first_name'] ?? $user->first_name; $user->save(); diff --git a/app/home/validate/UserValidate.php b/app/home/validate/UserValidate.php index f1940139..5fc77f7f 100644 --- a/app/home/validate/UserValidate.php +++ b/app/home/validate/UserValidate.php @@ -20,8 +20,8 @@ class UserValidate extends BaseHomeValidate 'password' => 'require|isString', 'password_new' => 'require|isString|length:6,150', 'nick_name' => 'require|isString|length:2,100', - 'first_name' => 'isString|length:2,100', - 'last_name' => 'isString|length:2,100', + 'first_name' => 'isString|length:1,100', + 'last_name' => 'isString|length:1,100', 'gender' => 'isString|in:0,1,2', ];