Browse Source

fix: 短信去掉前面0

master
liyang 1 week ago
parent
commit
597ac79c9c
  1. 123
      app/home/service/LoginService.php

123
app/home/service/LoginService.php

@ -66,7 +66,6 @@ class LoginService extends BaseHomeService
// 返回结果 // 返回结果
return $this->toData('0', lang('email_send_successfully')); return $this->toData('0', lang('email_send_successfully'));
} catch (ValidateException $validateException) { } catch (ValidateException $validateException) {
// 参数校验失败 异常类 // 参数校验失败 异常类
$message = $validateException->getError(); $message = $validateException->getError();
@ -75,7 +74,6 @@ class LoginService extends BaseHomeService
// 异常情况 // 异常情况
return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); return $this->toData('500', lang('system_busy'), [$exception->getMessage()]);
} }
} }
/** /**
@ -166,10 +164,10 @@ class LoginService extends BaseHomeService
// 查询父级用户 // 查询父级用户
$parentIds = ''; $parentIds = '';
$originUserId = 0; $originUserId = 0;
if($parentUserId > 0){ if ($parentUserId > 0) {
$parentUser = UserModel::where('user_id', $parentUserId)->findOrEmpty(); $parentUser = UserModel::where('user_id', $parentUserId)->findOrEmpty();
if($parentUser){ if ($parentUser) {
$parentIds = $parentUser['parent_ids']? $parentUser['parent_ids'].','.$parentUserId : $parentUserId; $parentIds = $parentUser['parent_ids'] ? $parentUser['parent_ids'] . ',' . $parentUserId : $parentUserId;
// 如果祖先id = 0 说明这个父级就是祖先id // 如果祖先id = 0 说明这个父级就是祖先id
$originUserId = $parentUser['origin_user_id'] == 0 ? $parentUserId : $parentUser['origin_user_id']; $originUserId = $parentUser['origin_user_id'] == 0 ? $parentUserId : $parentUser['origin_user_id'];
} }
@ -217,13 +215,13 @@ class LoginService extends BaseHomeService
'chat_name' => $chatRes['data']['username'] 'chat_name' => $chatRes['data']['username']
]); ]);
// 如果有代理,绑定到代理下一个客服(轮询客服绑定) // 如果有代理,绑定到代理下一个客服(轮询客服绑定)
if ($agentId > 0 ) { if ($agentId > 0) {
$customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID $customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID
Log::info("邮箱注册 - 客服列表:".json_encode($customerIds)); Log::info("邮箱注册 - 客服列表:" . json_encode($customerIds));
if (empty($customerIds)) { if (empty($customerIds)) {
return $this->toData('500', lang('account_registration_failed')); return $this->toData('500', lang('account_registration_failed'));
} }
$counterKey = 'counter_of_bind_customer:'.$agentId; $counterKey = 'counter_of_bind_customer:' . $agentId;
$counterIndex = Cache::store('redis')->get($counterKey); //客服绑定计数器索引 $counterIndex = Cache::store('redis')->get($counterKey); //客服绑定计数器索引
if (empty($counterIndex)) { if (empty($counterIndex)) {
Cache::store('redis')->set($counterKey, 1); Cache::store('redis')->set($counterKey, 1);
@ -233,13 +231,13 @@ class LoginService extends BaseHomeService
$tagIndex = $counterIndex % count($customerIds); $tagIndex = $counterIndex % count($customerIds);
$tagCustomerId = $customerIds[$tagIndex]; $tagCustomerId = $customerIds[$tagIndex];
} }
Log::info("邮箱注册 - 当前绑定客服ID:".$tagCustomerId); Log::info("邮箱注册 - 当前绑定客服ID:" . $tagCustomerId);
if ($tagCustomerId > 0) { if ($tagCustomerId > 0) {
$regUser->customer_id = $tagCustomerId; $regUser->customer_id = $tagCustomerId;
$regUser->save(); $regUser->save();
} }
// 将注册账号的chat_id与绑定客服的chat_id加为好友 // 将注册账号的chat_id与绑定客服的chat_id加为好友
$customerChatInfo = UserChatLinkModel::where(['user_id'=>$tagCustomerId, 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); //查询客服的聊天账号uuid $customerChatInfo = UserChatLinkModel::where(['user_id' => $tagCustomerId, 'user_type' => UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); //查询客服的聊天账号uuid
if (empty($customerChatInfo)) { if (empty($customerChatInfo)) {
return $this->toData('500', lang('account_registration_failed')); return $this->toData('500', lang('account_registration_failed'));
} }
@ -249,15 +247,15 @@ class LoginService extends BaseHomeService
]; ];
$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("邮箱注册 - 用户与客服加好友结果:".json_encode($chatFriendsRes)); Log::info("邮箱注册 - 用户与客服加好友结果:" . json_encode($chatFriendsRes));
// 将当前用户加入到代理创建的群聊中 【需要查出当前用户的代理创建的群聊信息】 // 将当前用户加入到代理创建的群聊中 【需要查出当前用户的代理创建的群聊信息】
$agentGroup = UserChatGroupModel::where(['user_id'=>$agentId,'remark'=>UserChatGroupModel::USER_CHAT_GROUP_REMARK_ADMIN_INIT])->find(); $agentGroup = UserChatGroupModel::where(['user_id' => $agentId, 'remark' => UserChatGroupModel::USER_CHAT_GROUP_REMARK_ADMIN_INIT])->find();
if (empty($agentGroup)) { if (empty($agentGroup)) {
return $this->toData('500', lang('account_registration_failed')); return $this->toData('500', lang('account_registration_failed'));
} }
$joinChatGroupUrl = env('CHAT_SERVER.BASE_URL') . '/api/group/join/'.$chatRes['data']['uuid'].'/'.$agentGroup->group_uuid; $joinChatGroupUrl = env('CHAT_SERVER.BASE_URL') . '/api/group/join/' . $chatRes['data']['uuid'] . '/' . $agentGroup->group_uuid;
$joinChatGroupRes = (new \app\utility\RequestChatServer())->ReqChatServer($joinChatGroupUrl, []); $joinChatGroupRes = (new \app\utility\RequestChatServer())->ReqChatServer($joinChatGroupUrl, []);
Log::info("邮箱注册 - 用户与客服加好友结果:".json_encode($joinChatGroupRes)); Log::info("邮箱注册 - 用户与客服加好友结果:" . json_encode($joinChatGroupRes));
} }
}); });
// 删除缓存 // 删除缓存
@ -271,8 +269,8 @@ class LoginService extends BaseHomeService
$message = $validateException->getError(); $message = $validateException->getError();
return $this->toData('500', $message); return $this->toData('500', $message);
} catch (\Exception $exception) { } catch (\Exception $exception) {
trace('【注册错误】提交数据:'.json_encode($param), 'error'); trace('【注册错误】提交数据:' . json_encode($param), 'error');
trace('【注册错误】'.$exception->getMessage(), 'error'); trace('【注册错误】' . $exception->getMessage(), 'error');
return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]); return $this->toData('500', lang('system_busy'), [$exception->getMessage(), $exception->getTrace()]);
} }
} }
@ -314,7 +312,8 @@ class LoginService extends BaseHomeService
} }
// 用户登陆之后需要进行的操作 异步完成 // 用户登陆之后需要进行的操作 异步完成
Queue::push('app\home\job\LoginDone', ['userId' => $userId, Queue::push('app\home\job\LoginDone', [
'userId' => $userId,
'fields' => [ 'fields' => [
'last_login_time' => date('Y-m-d H:i:s'), 'last_login_time' => date('Y-m-d H:i:s'),
'ip' => $this->getClientRealIp(), 'ip' => $this->getClientRealIp(),
@ -367,6 +366,8 @@ class LoginService extends BaseHomeService
$param['nation'] = trim($param['nation']); $param['nation'] = trim($param['nation']);
$param['phone'] = trim($param['phone']); $param['phone'] = trim($param['phone']);
//去掉前面0
$param['phone'] = ltrim($param['phone'], '0');
// 去除国内手机号 // 去除国内手机号
if ($this->checkForbidNation($param['nation'])) { if ($this->checkForbidNation($param['nation'])) {
return $this->toData('500', lang('unsupported_country_or_region')); return $this->toData('500', lang('unsupported_country_or_region'));
@ -379,7 +380,7 @@ class LoginService extends BaseHomeService
} }
// 发送次数校验 - 号码 // 发送次数校验 - 号码
$phoneSendCodeKey = 'USER:PHONE_SEND_CODE_NUM:' . $param['nation'].':'.$param['phone']; $phoneSendCodeKey = 'USER:PHONE_SEND_CODE_NUM:' . $param['nation'] . ':' . $param['phone'];
if ($this->checkGetNoTradeCodeNumPhone($phoneSendCodeKey)) { if ($this->checkGetNoTradeCodeNumPhone($phoneSendCodeKey)) {
return $this->toData('100300', 'No worries. Please feel free to reach out again tomorrow.', []); return $this->toData('100300', 'No worries. Please feel free to reach out again tomorrow.', []);
} }
@ -414,8 +415,8 @@ class LoginService extends BaseHomeService
$message = $validateException->getError(); $message = $validateException->getError();
return $this->toData('100400', $message); return $this->toData('100400', $message);
} catch (\Exception $exception) { } catch (\Exception $exception) {
trace('【注册错误】提交数据:'.json_encode($param), 'error'); trace('【注册错误】提交数据:' . json_encode($param), 'error');
trace('【注册错误】'.$exception->getMessage(), 'error'); trace('【注册错误】' . $exception->getMessage(), 'error');
return $this->toData('500', lang('system_busy'), [$exception->getMessage()]); return $this->toData('500', lang('system_busy'), [$exception->getMessage()]);
} }
} }
@ -455,10 +456,10 @@ class LoginService extends BaseHomeService
if (!$this->checkCode($smsKey, $param['sms_code'])) { if (!$this->checkCode($smsKey, $param['sms_code'])) {
return $this->toData('500', lang('incorrect_verification_code')); return $this->toData('500', lang('incorrect_verification_code'));
//注册验证码 //注册验证码
// $reg_key = "USER:REG:CODE"; // $reg_key = "USER:REG:CODE";
// if (!$this->checkCode($reg_key, $param['sms_code'])) { // if (!$this->checkCode($reg_key, $param['sms_code'])) {
// return $this->toData('100300', 'The verification code is incorrect.', []); // return $this->toData('100300', 'The verification code is incorrect.', []);
// } // }
} }
} }
@ -503,10 +504,10 @@ class LoginService extends BaseHomeService
// 生成用户数据 // 生成用户数据
$parentIds = ''; $parentIds = '';
$originUserId = 0; $originUserId = 0;
if($parentUserId > 0){ if ($parentUserId > 0) {
$parentUser = UserModel::where('user_id', $parentUserId)->findOrEmpty(); $parentUser = UserModel::where('user_id', $parentUserId)->findOrEmpty();
if($parentUser){ if ($parentUser) {
$parentIds = $parentUser['parent_ids']? $parentUser['parent_ids'].','.$parentUserId : $parentUserId; $parentIds = $parentUser['parent_ids'] ? $parentUser['parent_ids'] . ',' . $parentUserId : $parentUserId;
// 如果祖先id = 0 说明这个父级就是祖先id // 如果祖先id = 0 说明这个父级就是祖先id
$originUserId = $parentUser['origin_user_id'] == 0 ? $parentUserId : $parentUser['origin_user_id']; $originUserId = $parentUser['origin_user_id'] == 0 ? $parentUserId : $parentUser['origin_user_id'];
} }
@ -524,7 +525,7 @@ class LoginService extends BaseHomeService
'salt' => $salt, 'salt' => $salt,
'reg_ip' => $ip, 'reg_ip' => $ip,
'is_test_user' => UserModel::IS_TEST_USER_NO, 'is_test_user' => UserModel::IS_TEST_USER_NO,
'nick_name' => 'user_'.substr($param['phone'], -4), 'nick_name' => 'user_' . substr($param['phone'], -4),
'origin_user_id' => $originUserId, 'origin_user_id' => $originUserId,
'parent_ids' => $parentIds, 'parent_ids' => $parentIds,
'ch_code' => $chCode, 'ch_code' => $chCode,
@ -546,8 +547,8 @@ class LoginService extends BaseHomeService
'country' => $param['verify_country'] ?? 0, 'country' => $param['verify_country'] ?? 0,
'birth_day' => $param['verify_birth_day'], 'birth_day' => $param['verify_birth_day'],
'gender' => $param['verify_gender'], 'gender' => $param['verify_gender'],
// 'addr' => $param['verify_addr'], // 'addr' => $param['verify_addr'],
// 'zip_code' => $param['verify_zip_code'], // 'zip_code' => $param['verify_zip_code'],
'email' => $param['verify_email'] ?? '', 'email' => $param['verify_email'] ?? '',
'create_time' => date('Y-m-d H:i:s'), 'create_time' => date('Y-m-d H:i:s'),
'update_time' => date('Y-m-d H:i:s'), 'update_time' => date('Y-m-d H:i:s'),
@ -555,7 +556,7 @@ class LoginService extends BaseHomeService
} }
// 生成钱包地址 // 生成钱包地址
// (new UserService())->doRegInitUserInfo($userId, $parentUserId); // (new UserService())->doRegInitUserInfo($userId, $parentUserId);
// 注册聊天账号 // 注册聊天账号
$chatData = [ $chatData = [
'Username' => $userNo, 'Username' => $userNo,
@ -576,14 +577,14 @@ class LoginService extends BaseHomeService
'chat_name' => $chatRes['data']['username'] 'chat_name' => $chatRes['data']['username']
]); ]);
// 如果有代理,绑定到代理下一个客服(轮询客服绑定) // 如果有代理,绑定到代理下一个客服(轮询客服绑定)
if ($agentId > 0 ) { if ($agentId > 0) {
Log::info("手机号注册 - 开始获取客服列表..."); Log::info("手机号注册 - 开始获取客服列表...");
$customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID $customerIds = AdminModel::getCustomerIdsByAgentId($agentId); // 获取代理下的所有客服ID
Log::info("手机号注册 - 获取客服列表结果==".json_encode($customerIds)); Log::info("手机号注册 - 获取客服列表结果==" . json_encode($customerIds));
if (empty($customerIds)) { if (empty($customerIds)) {
return $this->toData('500', lang('account_registration_failed')); return $this->toData('500', lang('account_registration_failed'));
} }
$counterKey = 'counter_of_bind_customer:'.$agentId; $counterKey = 'counter_of_bind_customer:' . $agentId;
$counterIndex = Cache::store('redis')->get($counterKey); //客服绑定计数器索引 $counterIndex = Cache::store('redis')->get($counterKey); //客服绑定计数器索引
if (empty($counterIndex)) { if (empty($counterIndex)) {
Cache::store('redis')->set($counterKey, 1); Cache::store('redis')->set($counterKey, 1);
@ -593,13 +594,13 @@ class LoginService extends BaseHomeService
$tagIndex = $counterIndex % count($customerIds); $tagIndex = $counterIndex % count($customerIds);
$tagCustomerId = $customerIds[$tagIndex]; $tagCustomerId = $customerIds[$tagIndex];
} }
Log::info("手机号注册 - 或者最终绑定客服ID==".$tagCustomerId); Log::info("手机号注册 - 或者最终绑定客服ID==" . $tagCustomerId);
if ($tagCustomerId > 0) { if ($tagCustomerId > 0) {
$regUser->customer_id = $tagCustomerId; $regUser->customer_id = $tagCustomerId;
$regUser->save(); $regUser->save();
} }
// 将注册账号的chat_id与绑定客服的chat_id加为好友 // 将注册账号的chat_id与绑定客服的chat_id加为好友
$customerChatInfo = UserChatLinkModel::where(['user_id'=>$tagCustomerId,'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); //查询客服的聊天账号uuid $customerChatInfo = UserChatLinkModel::where(['user_id' => $tagCustomerId, 'user_type' => UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); //查询客服的聊天账号uuid
if (empty($customerChatInfo)) { if (empty($customerChatInfo)) {
return $this->toData('100400', 'The customer uuid is error.', []); return $this->toData('100400', 'The customer uuid is error.', []);
} }
@ -609,15 +610,15 @@ class LoginService extends BaseHomeService
]; ];
$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));
// 将当前用户加入到代理创建的群聊中 【需要查出当前用户的代理创建的群聊信息】 // 将当前用户加入到代理创建的群聊中 【需要查出当前用户的代理创建的群聊信息】
$agentGroup = UserChatGroupModel::where(['user_id'=>$agentId,'remark'=>UserChatGroupModel::USER_CHAT_GROUP_REMARK_ADMIN_INIT])->find(); $agentGroup = UserChatGroupModel::where(['user_id' => $agentId, 'remark' => UserChatGroupModel::USER_CHAT_GROUP_REMARK_ADMIN_INIT])->find();
if (empty($agentGroup)) { if (empty($agentGroup)) {
return $this->toData('500', lang('account_registration_failed')); return $this->toData('500', lang('account_registration_failed'));
} }
$joinChatGroupUrl = env('CHAT_SERVER.BASE_URL') . '/api/group/join/'.$chatRes['data']['uuid'].'/'.$agentGroup->group_uuid; $joinChatGroupUrl = env('CHAT_SERVER.BASE_URL') . '/api/group/join/' . $chatRes['data']['uuid'] . '/' . $agentGroup->group_uuid;
$joinChatGroupRes = (new \app\utility\RequestChatServer())->ReqChatServer($joinChatGroupUrl, []); $joinChatGroupRes = (new \app\utility\RequestChatServer())->ReqChatServer($joinChatGroupUrl, []);
Log::info("手机号注册 - 用户与客服加好友结果:".json_encode($joinChatGroupRes)); Log::info("手机号注册 - 用户与客服加好友结果:" . json_encode($joinChatGroupRes));
} }
}); });
@ -680,7 +681,8 @@ class LoginService extends BaseHomeService
} }
// 用户登陆之后需要进行的操作 异步完成 // 用户登陆之后需要进行的操作 异步完成
Queue::push('app\home\job\LoginDone', ['userId' => $userId, Queue::push('app\home\job\LoginDone', [
'userId' => $userId,
'fields' => [ 'fields' => [
'last_login_time' => date('Y-m-d H:i:s'), 'last_login_time' => date('Y-m-d H:i:s'),
'ip' => $this->getClientRealIp(), 'ip' => $this->getClientRealIp(),
@ -834,7 +836,8 @@ class LoginService extends BaseHomeService
} }
// 用户登陆之后需要进行的操作 异步完成 // 用户登陆之后需要进行的操作 异步完成
Queue::push('app\home\job\LoginDone', ['userId' => $userId, Queue::push('app\home\job\LoginDone', [
'userId' => $userId,
'fields' => [ 'fields' => [
'last_login_time' => date('Y-m-d H:i:s'), 'last_login_time' => date('Y-m-d H:i:s'),
'ip' => $this->getClientRealIp(), 'ip' => $this->getClientRealIp(),
@ -876,7 +879,7 @@ class LoginService extends BaseHomeService
return $this->toData('500', lang('Missing parameters')); return $this->toData('500', lang('Missing parameters'));
} }
// 检测用户是否存在 // 检测用户是否存在
$info = UserModel::where(['user_id'=>$param['user_id']])->find(); $info = UserModel::where(['user_id' => $param['user_id']])->find();
if (empty($info)) { if (empty($info)) {
return $this->toData('500', lang('user_does_not_exist')); return $this->toData('500', lang('user_does_not_exist'));
} }
@ -894,17 +897,17 @@ class LoginService extends BaseHomeService
public function autoLogin($param): array public function autoLogin($param): array
{ {
try { try {
$login_token=$param['login_token']; $login_token = $param['login_token'];
$tokenUserKey = 'AUTO:TOKEN:'.$login_token; $tokenUserKey = 'AUTO:TOKEN:' . $login_token;
$userId = Cache::store('redis')->get($tokenUserKey); $userId = Cache::store('redis')->get($tokenUserKey);
if(empty($userId) || $userId <= 0){ if (empty($userId) || $userId <= 0) {
return $this->toData('500', 'Incorrect token', []); return $this->toData('500', 'Incorrect token', []);
} }
$info = UserModel::getFieldsByUserId('invite_code,is_real,nick_name,user_no,user_id,login_password,salt', $userId); $info = UserModel::getFieldsByUserId('invite_code,is_real,nick_name,user_no,user_id,login_password,salt', $userId);
if (empty($info)) { if (empty($info)) {
return $this->toData('500', lang('user_does_not_exist')); return $this->toData('500', lang('user_does_not_exist'));
} }
// 生成token // 生成token
$token = (new Jwt())->getToken($userId, env('ENCRYPT.SALT')); $token = (new Jwt())->getToken($userId, env('ENCRYPT.SALT'));
if (empty($token)) { if (empty($token)) {
return $this->toData('500', lang('system_busy'), []); return $this->toData('500', lang('system_busy'), []);
@ -933,15 +936,14 @@ class LoginService extends BaseHomeService
} catch (\Exception $exception) { } catch (\Exception $exception) {
return $this->toData('500', lang('system_busy')); return $this->toData('500', lang('system_busy'));
} }
} }
public function testLogin($param): array public function testLogin($param): array
{ {
try { try {
$login_token=$param['login_token']; $login_token = $param['login_token'];
$tokenUserKey = 'AUTO:TOKEN:'.$login_token; $tokenUserKey = 'AUTO:TOKEN:' . $login_token;
$userId = Cache::store('redis')->get($tokenUserKey); $userId = Cache::store('redis')->get($tokenUserKey);
if(empty($userId) || $userId <= 0){ if (empty($userId) || $userId <= 0) {
return $this->toData('100300', 'Incorrect token', []); return $this->toData('100300', 'Incorrect token', []);
} }
$info = UserModel::getFieldsByUserId('invite_code,is_real,nick_name,user_no,user_id,login_password,salt', $userId); $info = UserModel::getFieldsByUserId('invite_code,is_real,nick_name,user_no,user_id,login_password,salt', $userId);
@ -977,29 +979,28 @@ class LoginService extends BaseHomeService
} catch (\Exception $exception) { } catch (\Exception $exception) {
return $this->toData('500', lang('system_busy'), []); return $this->toData('500', lang('system_busy'), []);
} }
} }
public function getIP(): array public function getIP(): array
{ {
$ip=$this->getClientRealIp(); $ip = $this->getClientRealIp();
$countryDb = base_path().'GeoLite2-Country.mmdb'; $countryDb = base_path() . 'GeoLite2-Country.mmdb';
$cityDb = base_path().'GeoLite2-City.mmdb'; $cityDb = base_path() . 'GeoLite2-City.mmdb';
$countryReader = new Reader($countryDb); $countryReader = new Reader($countryDb);
$cityReader = new Reader($cityDb); $cityReader = new Reader($cityDb);
try{ try {
$countryNames = $countryReader->country($ip)->country->names; $countryNames = $countryReader->country($ip)->country->names;
$cityNames = $cityReader->city($ip)->city->names; $cityNames = $cityReader->city($ip)->city->names;
return $this->toData('0', 'Request successful.', [ return $this->toData('0', 'Request successful.', [
'country' => $countryNames['zh-CN'], 'country' => $countryNames['zh-CN'],
'city' => $cityNames['zh-CN'], 'city' => $cityNames['zh-CN'],
'ip'=>$ip 'ip' => $ip
]); ]);
}catch (\Exception $exception){ } catch (\Exception $exception) {
return $this->toData('0', 'Request successful.', [ return $this->toData('0', 'Request successful.', [
'country' => '未知', 'country' => '未知',
'city' =>'未知', 'city' => '未知',
'ip'=>$ip 'ip' => $ip
]); ]);
} }
} }
} }

Loading…
Cancel
Save