fix: 修复IP归属地为空报错
This commit is contained in:
@@ -57,13 +57,13 @@ class UserService
|
|||||||
$qqWry = new IpLocation();
|
$qqWry = new IpLocation();
|
||||||
foreach ($list as $key => $value) {
|
foreach ($list as $key => $value) {
|
||||||
$value->hidden(['pwd', 'salt']);
|
$value->hidden(['pwd', 'salt']);
|
||||||
try {
|
$loginIp = $value['login_ip'];
|
||||||
$region = $qqWry->getLocation($value['login_ip']);
|
if (!empty($loginIp)) {
|
||||||
$region = $region['country'] . ' ' . $region['area'];
|
$region = $qqWry->getLocation($loginIp);
|
||||||
} catch (\Exception $e) {
|
$list[$key]['region'] = $region['country'] . ' ' . $region['area'];
|
||||||
$region = 'unKnown';
|
} else {
|
||||||
|
$list[$key]['region'] = 'unKnown';
|
||||||
}
|
}
|
||||||
$list[$key]['region'] = $region;
|
|
||||||
$result = list_search($userGroup,['id'=> $value['group_id']]);
|
$result = list_search($userGroup,['id'=> $value['group_id']]);
|
||||||
if (!empty($result)) {
|
if (!empty($result)) {
|
||||||
$list[$key]['group'] = $result['title'];
|
$list[$key]['group'] = $result['title'];
|
||||||
@@ -91,6 +91,7 @@ class UserService
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$model->create($params);
|
$model->create($params);
|
||||||
|
Db::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
throw new OperateException('添加失败!');
|
throw new OperateException('添加失败!');
|
||||||
@@ -136,6 +137,7 @@ class UserService
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$model->update($params);
|
$model->update($params);
|
||||||
|
Db::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
throw new OperateException('添加失败!');
|
throw new OperateException('添加失败!');
|
||||||
|
|||||||
Reference in New Issue
Block a user