Browse Source

fix: 注册事务+昵称

master
liyang 2 weeks ago
parent
commit
83b411ff1e
  1. 12
      app/home/service/LoginService.php
  2. 2
      app/home/service/UserService.php
  3. 4
      app/home/validate/UserValidate.php

12
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

2
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();

4
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',
];

Loading…
Cancel
Save