From 70679398f704ec5e4e45db01a9aaf711ff05f98d Mon Sep 17 00:00:00 2001 From: Ying Date: Fri, 4 Aug 2023 11:11:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DIP=E5=BD=92=E5=B1=9E?= =?UTF-8?q?=E5=9C=B0=E4=B8=BA=E7=A9=BA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/UserService.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/admin/service/UserService.php b/app/admin/service/UserService.php index 528efa5..7783c52 100644 --- a/app/admin/service/UserService.php +++ b/app/admin/service/UserService.php @@ -57,13 +57,13 @@ class UserService $qqWry = new IpLocation(); foreach ($list as $key => $value) { $value->hidden(['pwd', 'salt']); - try { - $region = $qqWry->getLocation($value['login_ip']); - $region = $region['country'] . ' ' . $region['area']; - } catch (\Exception $e) { - $region = 'unKnown'; + $loginIp = $value['login_ip']; + if (!empty($loginIp)) { + $region = $qqWry->getLocation($loginIp); + $list[$key]['region'] = $region['country'] . ' ' . $region['area']; + } else { + $list[$key]['region'] = 'unKnown'; } - $list[$key]['region'] = $region; $result = list_search($userGroup,['id'=> $value['group_id']]); if (!empty($result)) { $list[$key]['group'] = $result['title']; @@ -91,6 +91,7 @@ class UserService Db::startTrans(); try { $model->create($params); + Db::commit(); } catch (\Exception $e) { Db::rollback(); throw new OperateException('添加失败!'); @@ -136,6 +137,7 @@ class UserService Db::startTrans(); try { $model->update($params); + Db::commit(); } catch (\Exception $e) { Db::rollback(); throw new OperateException('添加失败!');