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
e7ef97eb
Commit
e7ef97eb
authored
Sep 24, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-deliver210913' into develop
parents
75b1b7d9
76c680a6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
UserService.php
application/services/user/UserService.php
+11
-6
No files found.
application/services/user/UserService.php
View file @
e7ef97eb
...
@@ -37,11 +37,10 @@ class UserService
...
@@ -37,11 +37,10 @@ class UserService
public
static
function
wechatLogin
(
$params
)
public
static
function
wechatLogin
(
$params
)
{
{
self
::
$code
=
!
empty
(
$params
[
'code'
])
?
$params
[
'code'
]
:
''
;
//小程序授权code
self
::
$code
=
!
empty
(
$params
[
'code'
])
?
$params
[
'code'
]
:
''
;
//小程序授权code
$openid
=
!
empty
(
$params
[
'openid'
])
?
$params
[
'openid'
]
:
''
;
//小程序授权code
$appid
=
!
empty
(
$params
[
'appid'
])
?
$params
[
'appid'
]
:
1
;
//登陆来源
$wechatFrom
=
!
empty
(
$params
[
'wechat_from'
])
?
$params
[
'wechat_from'
]
:
1
;
//登陆来源
$inviteUserId
=
!
empty
(
$params
[
'invite_user_id'
])
?
intval
(
$params
[
'invite_user_id'
])
:
0
;
//邀请用户id
$inviteUserId
=
!
empty
(
$params
[
'invite_user_id'
])
?
intval
(
$params
[
'invite_user_id'
])
:
0
;
//邀请用户id
$activityType
=
!
empty
(
$params
[
'activity_type'
])
?
intval
(
$params
[
'activity_type'
])
:
0
;
//活动类型
$activityType
=
!
empty
(
$params
[
'activity_type'
])
?
intval
(
$params
[
'activity_type'
])
:
0
;
//活动类型
if
(
empty
(
self
::
$code
)
&&
empty
(
$openid
)
)
{
if
(
empty
(
self
::
$code
))
{
FileLog
::
error
(
"wechatLogin:获取参数为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"wechatLogin:获取参数为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
0
]);
throw
new
UserException
([
'cus'
=>
0
]);
}
}
...
@@ -52,7 +51,7 @@ class UserService
...
@@ -52,7 +51,7 @@ class UserService
}
}
//设置小程序配置
//设置小程序配置
self
::
setWechatConfig
(
$
wechatFrom
);
self
::
setWechatConfig
(
$
appid
);
//获取小程序用户信息
//获取小程序用户信息
$response
=
self
::
getJscode2session
();
$response
=
self
::
getJscode2session
();
//检查系统是已注册
//检查系统是已注册
...
@@ -66,7 +65,9 @@ class UserService
...
@@ -66,7 +65,9 @@ class UserService
'session_key'
=>
!
empty
(
$response
[
'session_key'
])
?
$response
[
'session_key'
]
:
''
,
//默认7200有效期
'session_key'
=>
!
empty
(
$response
[
'session_key'
])
?
$response
[
'session_key'
]
:
''
,
//默认7200有效期
'invite_user_id'
=>
$inviteUserId
,
'invite_user_id'
=>
$inviteUserId
,
'activity_type'
=>
$activityType
,
'activity_type'
=>
$activityType
,
'create_time'
=>
date
(
"Y-m-d H:i:s"
)
'create_time'
=>
date
(
"Y-m-d H:i:s"
),
'appid'
=>
$appid
,
'wechat_app_id'
=>
self
::
$appid
,
];
];
$sessionKey
=
!
empty
(
$response
[
'session_key'
])
?
$response
[
'session_key'
]
:
''
;
$sessionKey
=
!
empty
(
$response
[
'session_key'
])
?
$response
[
'session_key'
]
:
''
;
...
@@ -109,7 +110,7 @@ class UserService
...
@@ -109,7 +110,7 @@ class UserService
public
static
function
setWechatConfig
(
$wechatFrom
)
public
static
function
setWechatConfig
(
$wechatFrom
)
{
{
//需要授权微信
//需要授权微信
if
(
$wechatFrom
==
2
)
{
if
(
$wechatFrom
==
'merchant-pub-deliverer'
)
{
self
::
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
deliverer
->
wechat
->
appid
;
self
::
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
deliverer
->
wechat
->
appid
;
self
::
$secret
=
\Yaf\Registry
::
get
(
'config'
)
->
deliverer
->
wechat
->
secret
;
self
::
$secret
=
\Yaf\Registry
::
get
(
'config'
)
->
deliverer
->
wechat
->
secret
;
}
else
{
}
else
{
...
@@ -365,6 +366,10 @@ class UserService
...
@@ -365,6 +366,10 @@ class UserService
$data
[
'phone'
]
=
$params
[
'phone'
];
$data
[
'phone'
]
=
$params
[
'phone'
];
}
}
if
(
!
empty
(
$params
[
'wechat_app_id'
]))
{
$data
[
'wechat_app_id'
]
=
$params
[
'wechat_app_id'
];
}
$userList
=
UserWechatBind
::
getRecords
(
$data
);
$userList
=
UserWechatBind
::
getRecords
(
$data
);
return
$userList
;
return
$userList
;
}
}
...
...
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