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
bf78699f
Commit
bf78699f
authored
Aug 05, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jielong' of
https://git.yidian-inc.com:8021/bp/goods
into jielong
parents
f6bc854e
2b83f128
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
UserWechatBind.php
application/models/user/mysql/UserWechatBind.php
+8
-0
User.php
application/modules/User/controllers/User.php
+9
-0
UserService.php
application/services/user/UserService.php
+23
-3
No files found.
application/models/user/mysql/UserWechatBind.php
View file @
bf78699f
...
...
@@ -26,6 +26,14 @@ class UserWechatBind extends MysqlBase
return
self
::
get
(
$columns
,
$where
);
}
public
static
function
getRecords
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
$columns
=
'*'
;
}
return
self
::
select
(
$columns
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$columns
=
[])
{
if
(
empty
(
$columns
))
{
...
...
application/modules/User/controllers/User.php
View file @
bf78699f
...
...
@@ -27,4 +27,13 @@ class UserController extends Base
$this
->
success
(
$userInfo
);
}
public
function
user_wechat_bindAction
()
{
$params
=
$this
->
params
;
$user
=
UserService
::
userWechatBind
(
$params
);
$userInfo
[
'result'
]
=
$user
;
$this
->
success
(
$userInfo
);
}
}
\ No newline at end of file
application/services/user/UserService.php
View file @
bf78699f
...
...
@@ -28,9 +28,9 @@ class UserService
throw
new
UserException
([
'cus'
=>
0
]);
}
//需要授权微信
if
(
empty
(
$openid
))
{
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
$secret
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
secret
;
$grant_type
=
'authorization_code'
;
...
...
@@ -61,8 +61,10 @@ class UserService
//如果系统不存在,用户信息,则注册新用户
if
(
empty
(
$user
)
&&
!
empty
(
$response
))
{
$insert
=
[
'openid'
=>
$response
[
'openid'
],
'session_key'
=>
$response
[
'session_key'
],
//默认7200有效期
'openid'
=>
!
empty
(
$response
[
'openid'
])
?
$response
[
'openid'
]
:
''
,
'union_id'
=>
!
empty
(
$response
[
'unionid'
])
?
$response
[
'unionid'
]
:
''
,
'session_key'
=>
!
empty
(
$response
[
'session_key'
])
?
$response
[
'session_key'
]
:
''
,
//默认7200有效期
'create_time'
=>
date
(
"Y-m-d H:i:s"
)
];
$newWechatId
=
UserWechatBind
::
save
(
$insert
);
...
...
@@ -146,6 +148,24 @@ class UserService
return
$userInfo
;
}
public
static
function
userWechatBind
(
$params
)
{
$data
[
'wechat_id[>]'
]
=
0
;
if
(
!
empty
(
$params
[
'openid'
]))
{
$data
[
'openid'
]
=
$params
[
'openid'
];
}
if
(
!
empty
(
$params
[
'user_id'
]))
{
$data
[
'user_id'
]
=
$params
[
'user_id'
];
}
$userList
=
UserWechatBind
::
getRecords
(
$data
);
return
$userList
;
}
private
static
function
generate3rdSession
(
$openid
)
{
return
md5
(
mt_rand
()
.
$openid
);
}
...
...
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