Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
598b36e4
Commit
598b36e4
authored
Apr 15, 2025
by
xuepeng.chang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
限制微信绑定
parent
f29df899
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
CommonProperties.java
...in/java/cn/quantgroup/xyqb/constant/CommonProperties.java
+3
-0
AppletServiceImpl.java
...b/service/middleoffice/applet/impl/AppletServiceImpl.java
+22
-15
No files found.
src/main/java/cn/quantgroup/xyqb/constant/CommonProperties.java
View file @
598b36e4
...
...
@@ -14,4 +14,7 @@ public class CommonProperties {
/** 限制用户小程序登陆*/
@Value
(
"${wechat.black.userIds:}"
)
private
String
wechatBlackUserIds
;
@Value
(
"${wechat.limit.bind:}"
)
private
String
wechatLimitBinding
;
}
src/main/java/cn/quantgroup/xyqb/service/middleoffice/applet/impl/AppletServiceImpl.java
View file @
598b36e4
package
cn
.
quantgroup
.
xyqb
.
service
.
middleoffice
.
applet
.
impl
;
import
cn.quantgroup.xyqb.config.data.WechatConfiguration
;
import
cn.quantgroup.xyqb.constant.CommonProperties
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.ILoginModule
;
import
cn.quantgroup.xyqb.controller.middleoffice.login.LoginVo
;
...
...
@@ -60,13 +61,16 @@ public class AppletServiceImpl implements IAppletService {
private
final
ISessionService
sessionService
;
private
final
CommonProperties
commonProperties
;
@Autowired
public
AppletServiceImpl
(
IWeChatUserRepository
iWeChatUserRepository
,
IUserRegisterService
iUserRegisterService
,
IUserService
userService
,
ILoginModule
loginModule
,
WechatConfiguration
wechatConfiguration
,
IWechatBindLogRepository
wechatBindLogRepository
,
ISessionService
sessionService
)
{
IWechatBindLogRepository
wechatBindLogRepository
,
ISessionService
sessionService
,
CommonProperties
commonProperties
)
{
this
.
iWeChatUserRepository
=
iWeChatUserRepository
;
this
.
iUserRegisterService
=
iUserRegisterService
;
this
.
userService
=
userService
;
...
...
@@ -74,6 +78,7 @@ public class AppletServiceImpl implements IAppletService {
this
.
wechatConfiguration
=
wechatConfiguration
;
this
.
wechatBindLogRepository
=
wechatBindLogRepository
;
this
.
sessionService
=
sessionService
;
this
.
commonProperties
=
commonProperties
;
}
@Override
...
...
@@ -85,25 +90,27 @@ public class AppletServiceImpl implements IAppletService {
throw
new
BizException
(
BizExceptionEnum
.
ERROR_MATCHING_WECHAT_APP_ID
);
}
appletParamEntry
.
setAppId
(
appId
);
// 校验当前用户的手机号有没有绑定过openId
List
<
WechatUserInfo
>
wechatUserInfos
=
iWeChatUserRepository
.
findByPhoneNoAndAppNameAndAppIdAndTenantId
(
appletParamEntry
.
getMobile
(),
appletParamEntry
.
getAppName
(),
appletParamEntry
.
getAppId
(),
appletParamEntry
.
getTenantId
());
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotEmpty
(
commonProperties
.
getWechatLimitBinding
())
&&
"limit"
.
equals
(
commonProperties
.
getWechatLimitBinding
())){
// 校验当前用户的手机号有没有绑定过openId
List
<
WechatUserInfo
>
wechatUserInfos
=
iWeChatUserRepository
.
findByPhoneNoAndAppNameAndAppIdAndTenantId
(
appletParamEntry
.
getMobile
(),
appletParamEntry
.
getAppName
(),
appletParamEntry
.
getAppId
(),
appletParamEntry
.
getTenantId
());
if
(
wechatUserInfos
.
size
()>
1
){
log
.
info
(
"微信关联失败[service]:phoneNo:{},openId:{},appName:{}"
,
appletParamEntry
.
getMobile
(),
appletParamEntry
.
getOpenId
(),
appletParamEntry
.
getAppName
());
throw
new
AppletException
(
BizExceptionEnum
.
USER_WECHAT_BIND_ERROR
.
getMsg
(),
BizExceptionEnum
.
USER_WECHAT_BIND_ERROR
.
getBusinessCode
());
}
if
(
wechatUserInfos
.
size
()
==
1
){
WechatUserInfo
wechatUserInfoOne
=
wechatUserInfos
.
get
(
0
);
if
(
Objects
.
equals
(
wechatUserInfoOne
.
getOpenId
(),
appletParamEntry
.
getOpenId
())){
log
.
info
(
"微信关联成功:重复关联:跳过:[service]:userId:{},phoneNo:{},openId:{}"
,
wechatUserInfoOne
.
getUserId
(),
wechatUserInfoOne
.
getPhoneNo
(),
wechatUserInfoOne
.
getOpenId
());
return
wechatUserInfoOne
.
getUserId
();
}
else
{
if
(
wechatUserInfos
.
size
()>
1
){
log
.
info
(
"微信关联失败[service]:phoneNo:{},openId:{},appName:{}"
,
appletParamEntry
.
getMobile
(),
appletParamEntry
.
getOpenId
(),
appletParamEntry
.
getAppName
());
throw
new
AppletException
(
BizExceptionEnum
.
USER_WECHAT_BIND_ERROR
.
getMsg
(),
BizExceptionEnum
.
USER_WECHAT_BIND_ERROR
.
getBusinessCode
());
}
if
(
wechatUserInfos
.
size
()
==
1
){
WechatUserInfo
wechatUserInfoOne
=
wechatUserInfos
.
get
(
0
);
if
(
Objects
.
equals
(
wechatUserInfoOne
.
getOpenId
(),
appletParamEntry
.
getOpenId
())){
log
.
info
(
"微信关联成功:重复关联:跳过:[service]:userId:{},phoneNo:{},openId:{}"
,
wechatUserInfoOne
.
getUserId
(),
wechatUserInfoOne
.
getPhoneNo
(),
wechatUserInfoOne
.
getOpenId
());
return
wechatUserInfoOne
.
getUserId
();
}
else
{
log
.
info
(
"微信关联失败[service]:phoneNo:{},openId:{},appName:{}"
,
appletParamEntry
.
getMobile
(),
appletParamEntry
.
getOpenId
(),
appletParamEntry
.
getAppName
());
throw
new
AppletException
(
BizExceptionEnum
.
USER_WECHAT_BIND_ERROR
.
getMsg
(),
BizExceptionEnum
.
USER_WECHAT_BIND_ERROR
.
getBusinessCode
());
}
}
}
WechatUserInfo
wechatUserInfo
=
iWeChatUserRepository
.
findByOpenIdAndAppNameAndAppIdAndTenantId
(
appletParamEntry
.
getOpenId
(),
appletParamEntry
.
getAppName
(),
appletParamEntry
.
getAppId
(),
appletParamEntry
.
getTenantId
());
//这个接口先不考虑更换手机号的情况
if
(
appletParamEntry
.
getTenantId
()
==
null
)
{
...
...
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