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
7b4356b1
Commit
7b4356b1
authored
Sep 29, 2021
by
jianghaiming
Browse files
Options
Browse Files
Download
Plain Diff
update:修改冲突
parents
bb87474f
91132a3f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
19 deletions
+37
-19
UserException.php
application/exception/custom/UserException.php
+2
-1
UserService.php
application/services/user/UserService.php
+25
-18
application.ini
conf/application.ini
+10
-0
No files found.
application/exception/custom/UserException.php
View file @
7b4356b1
...
@@ -9,7 +9,7 @@ use App\Exception\BaseException;
...
@@ -9,7 +9,7 @@ use App\Exception\BaseException;
class
UserException
extends
BaseException
class
UserException
extends
BaseException
{
{
protected
$base_code
=
Code
::
USUR
;
protected
$base_code
=
Code
::
USUR
;
const
APP_ID_NULL
=
15
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'code 无效'
,
0
=>
'code 无效'
,
1
=>
'获取openid失败'
,
1
=>
'获取openid失败'
,
...
@@ -26,5 +26,6 @@ class UserException extends BaseException
...
@@ -26,5 +26,6 @@ class UserException extends BaseException
12
=>
'绑定手机号保存失败'
,
12
=>
'绑定手机号保存失败'
,
13
=>
'请求太频繁,稍后重试'
,
13
=>
'请求太频繁,稍后重试'
,
14
=>
'手机号格式错误'
,
14
=>
'手机号格式错误'
,
self
::
APP_ID_NULL
=>
'AppId 不能为空'
,
];
];
}
}
\ No newline at end of file
application/services/user/UserService.php
View file @
7b4356b1
...
@@ -37,19 +37,15 @@ class UserService
...
@@ -37,19 +37,15 @@ 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
$appid
=
!
empty
(
$params
[
'appid'
])
?
$params
[
'appid'
]
:
1
;
//登陆来源
$appid
=
!
empty
(
$params
[
'appid'
])
?
$params
[
'appid'
]
:
''
;
//登陆来源
$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
))
{
//验证登陆参数
FileLog
::
error
(
"wechatLogin:获取参数为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
self
::
checkWechatLoginParams
(
$params
);
throw
new
UserException
([
'cus'
=>
0
]);
}
$lock
=
self
::
getWechatLoginLock
(
$params
);
$lock
=
self
::
getWechatLoginLock
(
$params
);
if
(
!
empty
(
$lock
)){
if
(
!
empty
(
$lock
)){
return
$lock
;
return
$lock
;
}
}
//设置小程序配置
//设置小程序配置
self
::
setWechatConfig
(
$appid
);
self
::
setWechatConfig
(
$appid
);
//获取小程序用户信息
//获取小程序用户信息
...
@@ -103,6 +99,22 @@ class UserService
...
@@ -103,6 +99,22 @@ class UserService
return
$user
;
return
$user
;
}
}
/**
* 验证登陆参数
* @param $params
* @throws UserException
*/
public
static
function
checkWechatLoginParams
(
$params
)
{
if
(
empty
(
self
::
$code
))
{
FileLog
::
error
(
"wechatLogin:获取参数为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
0
]);
}
if
(
empty
(
$params
[
'appid'
]))
{
throw
new
UserException
([
'cus'
=>
UserException
::
APP_ID_NULL
]);
}
}
/**
/**
* 初始化微信配置
* 初始化微信配置
* @param $wechatFrom
* @param $wechatFrom
...
@@ -110,13 +122,8 @@ class UserService
...
@@ -110,13 +122,8 @@ class UserService
public
static
function
setWechatConfig
(
$wechatFrom
)
public
static
function
setWechatConfig
(
$wechatFrom
)
{
{
//需要授权微信
//需要授权微信
if
(
$wechatFrom
==
'merchant-pub-deliverer'
)
{
self
::
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
->
$wechatFrom
;
self
::
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
deliverer
->
wechat
->
appid
;
self
::
$secret
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
secret
->
$wechatFrom
;
self
::
$secret
=
\Yaf\Registry
::
get
(
'config'
)
->
deliverer
->
wechat
->
secret
;
}
else
{
self
::
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
self
::
$secret
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
secret
;
}
}
}
/**
/**
...
@@ -186,6 +193,8 @@ class UserService
...
@@ -186,6 +193,8 @@ class UserService
public
static
function
bindPhone
(
$params
){
public
static
function
bindPhone
(
$params
){
self
::
$openid
=
!
empty
(
$params
[
'openid'
])
?
$params
[
'openid'
]
:
''
;
self
::
$openid
=
!
empty
(
$params
[
'openid'
])
?
$params
[
'openid'
]
:
''
;
$phone
=
!
empty
(
$params
[
'mobile'
])
?
$params
[
'mobile'
]
:
''
;
$phone
=
!
empty
(
$params
[
'mobile'
])
?
$params
[
'mobile'
]
:
''
;
$wechatFrom
=
!
empty
(
$params
[
'appid'
])
?
$params
[
'appid'
]
:
''
;
self
::
setWechatConfig
(
$wechatFrom
);
if
(
!
empty
(
$phone
)){
if
(
!
empty
(
$phone
)){
$userInfo
=
self
::
delivererBindPhone
(
$params
);
$userInfo
=
self
::
delivererBindPhone
(
$params
);
}
else
{
}
else
{
...
@@ -267,9 +276,7 @@ class UserService
...
@@ -267,9 +276,7 @@ class UserService
public
static
function
pinBindPhone
(
$params
)
public
static
function
pinBindPhone
(
$params
)
{
{
$encryptedData
=
!
empty
(
$params
[
'encryptedData'
])
?
$params
[
'encryptedData'
]
:
''
;
$encryptedData
=
!
empty
(
$params
[
'encryptedData'
])
?
$params
[
'encryptedData'
]
:
''
;
$iv
=
!
empty
(
$params
[
'iv'
])
?
$params
[
'iv'
]
:
''
;
$iv
=
!
empty
(
$params
[
'iv'
])
?
$params
[
'iv'
]
:
''
;
$appid
=
\Yaf\Registry
::
get
(
'config'
)
->
wechat
->
appid
;
if
(
!
$encryptedData
)
{
if
(
!
$encryptedData
)
{
FileLog
::
error
(
"bindPhone:encryptedData 为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
FileLog
::
error
(
"bindPhone:encryptedData 为空"
,
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
''
,
'jianghaiming@yidian-inc.com'
);
throw
new
UserException
([
'cus'
=>
3
]);
throw
new
UserException
([
'cus'
=>
3
]);
...
@@ -290,7 +297,7 @@ class UserService
...
@@ -290,7 +297,7 @@ class UserService
//解密
//解密
$decryptData
=
[];
$decryptData
=
[];
$wXBizDataCrypt
=
new
WxBizDataCrypt
(
$appid
,
$sessionKey
);
$wXBizDataCrypt
=
new
WxBizDataCrypt
(
self
::
$appid
,
$sessionKey
);
$errCode
=
$wXBizDataCrypt
->
decryptData
(
$encryptedData
,
$iv
,
$decryptData
);
$errCode
=
$wXBizDataCrypt
->
decryptData
(
$encryptedData
,
$iv
,
$decryptData
);
if
(
$errCode
)
{
if
(
$errCode
)
{
...
...
conf/application.ini
View file @
7b4356b1
...
@@ -21,6 +21,16 @@ idgen.key = "5cfdb867e96374c7883b31d6928cc4cb"
...
@@ -21,6 +21,16 @@ idgen.key = "5cfdb867e96374c7883b31d6928cc4cb"
wechat.appid
=
"wx4e0d92499185fb74"
;
wechat.appid
=
"wx4e0d92499185fb74"
;
wechat.secret = "731bcf2f7ebb1ebddb677618c2008b25";
wechat.secret = "731bcf2f7ebb1ebddb677618c2008b25";
wechat.appid.merchant-pub-pin
=
"wx4e0d92499185fb74"
wechat.secret.merchant-pub-pin
=
"731bcf2f7ebb1ebddb677618c2008b25"
wechat.appid.merchant-pub-deliverer
=
"wx91042f2a75f8b994"
wechat.secret.merchant-pub-deliverer
=
"09d7ea5472d871b4b1a0f3100bdfe1c9"
wechat.appid.merchant-pub-idle
=
"wx415fe9cb54be1e09"
wechat.secret.merchant-pub-idle
=
"b1badcd547f47a456f400016af90b46f"
deliverer.wechat.appid
=
"wx91042f2a75f8b994"
;
deliverer.wechat.appid
=
"wx91042f2a75f8b994"
;
deliverer.wechat.secret = "09d7ea5472d871b4b1a0f3100bdfe1c9";
deliverer.wechat.secret = "09d7ea5472d871b4b1a0f3100bdfe1c9";
...
...
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