Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
64280648
Commit
64280648
authored
Sep 07, 2021
by
强海明
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jiang_fix_20210906' into 'master'
Jiang fix 20210906 See merge request bp/goods!32
parents
669def92
e6f20154
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
UserService.php
application/services/user/UserService.php
+16
-2
No files found.
application/services/user/UserService.php
View file @
64280648
...
...
@@ -25,7 +25,6 @@ class UserService
public
static
function
wechatLogin
(
$params
)
{
$code
=
!
empty
(
$params
[
'code'
])
?
$params
[
'code'
]
:
''
;
//小程序授权code
$openid
=
!
empty
(
$params
[
'openid'
])
?
$params
[
'openid'
]
:
''
;
//小程序授权code
if
(
empty
(
$code
)
&&
empty
(
$openid
))
{
...
...
@@ -33,6 +32,21 @@ class UserService
throw
new
UserException
([
'cus'
=>
0
]);
}
$redis
=
RedisUtil
::
getInstance
(
'cache'
);
$key
=
"wx_wechat_login_"
.
$code
;
$keyCode
=
"wx_wechat_login_code_"
.
$code
;
$lock
=
FrequencyLockUtil
::
isLocked
(
$key
,
1
,
120
);
if
(
$lock
)
{
sleep
(
1
);
$user
=
$redis
->
get
(
$keyCode
);
if
(
!
empty
(
$user
))
{
$user
=
json_decode
(
$user
,
true
);
}
FileLog
::
error
(
"wechatLogin: lock"
,
json_encode
(
$user
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"wechatLogin: lock--params"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
return
$user
;
}
//需要授权微信
//if (empty($openid)) {
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
...
...
@@ -100,8 +114,8 @@ class UserService
];
$newWechatId
=
UserWechatBind
::
save
(
$insert
,[
'openid'
=>
$openid
]);
}
$user
[
'third_session'
]
=
self
::
generate3rdSession
(
$openid
);
$redis
->
set
(
$keyCode
,
json_encode
(
$user
),
120
);
return
$user
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment