|
@ -164,6 +164,7 @@ class LoginService extends BaseHomeService |
|
|
$salt = env('ENCRYPT.SALT'); |
|
|
$salt = env('ENCRYPT.SALT'); |
|
|
$password = (new UnqId())->encryptPassword($param['password'], $salt); |
|
|
$password = (new UnqId())->encryptPassword($param['password'], $salt); |
|
|
$userInviteCode = $this->getUniqInviteCode(); |
|
|
$userInviteCode = $this->getUniqInviteCode(); |
|
|
|
|
|
Log::info("邮箱注册 - agentId=".$agentId); |
|
|
// 需要开启事务 |
|
|
// 需要开启事务 |
|
|
\think\facade\Db::transaction(function () use ($email, $userNo, $userInviteCode, $parentUserId, $password, $ip, $salt, $agentId) { |
|
|
\think\facade\Db::transaction(function () use ($email, $userNo, $userInviteCode, $parentUserId, $password, $ip, $salt, $agentId) { |
|
|
// 生成用户数据 |
|
|
// 生成用户数据 |
|
@ -175,7 +176,7 @@ class LoginService extends BaseHomeService |
|
|
'Username' => $userNo, |
|
|
'Username' => $userNo, |
|
|
'Password' => '123456', |
|
|
'Password' => '123456', |
|
|
]; |
|
|
]; |
|
|
$chatUrl = env('CHAT_SERVER.BASE_URL') . '/user/register'; |
|
|
$chatUrl = env('CHAT_SERVER.BASE_URL') . '/api/user/register'; |
|
|
$chatRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatUrl, $chatData); |
|
|
$chatRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatUrl, $chatData); |
|
|
if (!isset($chatRes['data']['uuid'])) { |
|
|
if (!isset($chatRes['data']['uuid'])) { |
|
|
return $this->toData('100400', 'Failed to register a chat account.', []); |
|
|
return $this->toData('100400', 'Failed to register a chat account.', []); |
|
@ -187,9 +188,11 @@ class LoginService extends BaseHomeService |
|
|
'chat_uuid' => $chatRes['data']['uuid'], |
|
|
'chat_uuid' => $chatRes['data']['uuid'], |
|
|
'chat_name' => $chatRes['data']['username'] |
|
|
'chat_name' => $chatRes['data']['username'] |
|
|
]); |
|
|
]); |
|
|
|
|
|
Log::info("邮箱注册 - 用户注册chat账号 - user_id=".$userId. " chat_uiud=".$chatRes['data']['uuid']); |
|
|
// 如果有代理,绑定到代理下一个客服(轮询客服绑定) |
|
|
// 如果有代理,绑定到代理下一个客服(轮询客服绑定) |
|
|
if ($agentId > 0 ) { |
|
|
if ($agentId > 0 ) { |
|
|
$customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID |
|
|
$customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID |
|
|
|
|
|
Log::info("邮箱注册 - 代理下客服ids=".json_encode($customerIds)); |
|
|
if (empty($customerIds)) { |
|
|
if (empty($customerIds)) { |
|
|
return $this->toData('100400', 'There is no customer service account under the current agent', []); |
|
|
return $this->toData('100400', 'There is no customer service account under the current agent', []); |
|
|
} |
|
|
} |
|
@ -204,6 +207,7 @@ class LoginService extends BaseHomeService |
|
|
$tagIndex = $counterIndex % count($customerIds); |
|
|
$tagIndex = $counterIndex % count($customerIds); |
|
|
$tagCustomerId = $customerIds[$tagIndex]; |
|
|
$tagCustomerId = $customerIds[$tagIndex]; |
|
|
} |
|
|
} |
|
|
|
|
|
Log::info("邮箱注册 - 要绑定的客服id=".$tagCustomerId); |
|
|
if ($tagCustomerId > 0) { |
|
|
if ($tagCustomerId > 0) { |
|
|
CustomerRelationalModel::create([ |
|
|
CustomerRelationalModel::create([ |
|
|
'user_id' => $userId, |
|
|
'user_id' => $userId, |
|
@ -212,14 +216,16 @@ class LoginService extends BaseHomeService |
|
|
]); |
|
|
]); |
|
|
} |
|
|
} |
|
|
// 将注册账号的chat_id与绑定客服的chat_id加为好友 |
|
|
// 将注册账号的chat_id与绑定客服的chat_id加为好友 |
|
|
$customerChatInfo = UserChatLinkModel::where('user_id', $tagCustomerId)->find(); //查询客服的聊天账号uuid |
|
|
Log::info("邮箱注册 - 获取去客服聊天账号信息, $tagCustomerId=".$tagCustomerId); |
|
|
if (empty($customerChatInfo) || !$customerChatInfo->chat_uuid) { |
|
|
$customerChatInfo = UserChatLinkModel::where(['user_id'=>$tagCustomerId, 'user_type'=>2])->find(); //查询客服的聊天账号uuid |
|
|
|
|
|
if (empty($customerChatInfo)) { |
|
|
return $this->toData('100400', 'The customer uuid is error.', []); |
|
|
return $this->toData('100400', 'The customer uuid is error.', []); |
|
|
} |
|
|
} |
|
|
$chatFriendsData = [ |
|
|
$chatFriendsData = [ |
|
|
'UserUuid' => $chatRes['data']['uuid'], |
|
|
'UserUuid' => $chatRes['data']['uuid'], |
|
|
'CustomerUuid' => $customerChatInfo->chat_uuid, |
|
|
'CustomerUuid' => $customerChatInfo->chat_uuid, |
|
|
]; |
|
|
]; |
|
|
|
|
|
Log::info("邮箱注册 - 请求聊天夫加好友=".$tagCustomerId); |
|
|
$chatFriendsUrl = env('CHAT_SERVER.BASE_URL') . '/api/eachOtherFriends'; |
|
|
$chatFriendsUrl = env('CHAT_SERVER.BASE_URL') . '/api/eachOtherFriends'; |
|
|
$chatFriendsRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatFriendsUrl, $chatFriendsData); |
|
|
$chatFriendsRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatFriendsUrl, $chatFriendsData); |
|
|
Log::info("邮箱注册 - chat服务加好友结果:".json_encode($chatFriendsRes)); |
|
|
Log::info("邮箱注册 - chat服务加好友结果:".json_encode($chatFriendsRes)); |
|
@ -475,7 +481,7 @@ class LoginService extends BaseHomeService |
|
|
'Username' => $userNo, |
|
|
'Username' => $userNo, |
|
|
'Password' => '123456', |
|
|
'Password' => '123456', |
|
|
]; |
|
|
]; |
|
|
$chatUrl = env('CHAT_SERVER.BASE_URL') . '/user/register'; |
|
|
$chatUrl = env('CHAT_SERVER.BASE_URL') . '/api/user/register'; |
|
|
$chatRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatUrl, $chatData); |
|
|
$chatRes = (new \app\utility\RequestChatServer())->ReqChatServer($chatUrl, $chatData); |
|
|
if (!isset($chatRes['data']['uuid'])) { |
|
|
if (!isset($chatRes['data']['uuid'])) { |
|
|
return $this->toData('100400', 'Failed to register a chat account.', []); |
|
|
return $this->toData('100400', 'Failed to register a chat account.', []); |
|
@ -513,7 +519,7 @@ class LoginService extends BaseHomeService |
|
|
} |
|
|
} |
|
|
// 将注册账号的chat_id与绑定客服的chat_id加为好友 |
|
|
// 将注册账号的chat_id与绑定客服的chat_id加为好友 |
|
|
$customerChatInfo = UserChatLinkModel::where('user_id', $tagCustomerId)->find(); //查询客服的聊天账号uuid |
|
|
$customerChatInfo = UserChatLinkModel::where('user_id', $tagCustomerId)->find(); //查询客服的聊天账号uuid |
|
|
if (empty($customerChatInfo) || !$customerChatInfo->chat_uuid) { |
|
|
if (empty($customerChatInfo)) { |
|
|
return $this->toData('100400', 'The customer uuid is error.', []); |
|
|
return $this->toData('100400', 'The customer uuid is error.', []); |
|
|
} |
|
|
} |
|
|
$chatFriendsData = [ |
|
|
$chatFriendsData = [ |
|
|