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
1d98ae83
Commit
1d98ae83
authored
Nov 22, 2021
by
guangjing.gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
根据用户ID或手机号或应用名称 查询微信openId
parent
b441c085
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
29 deletions
+51
-29
WxController.java
...ntgroup/xyqb/controller/middleoffice/wx/WxController.java
+45
-23
ITenantService.java
.../java/cn/quantgroup/xyqb/service/user/ITenantService.java
+2
-2
TenantServiceImpl.java
.../quantgroup/xyqb/service/user/impl/TenantServiceImpl.java
+4
-4
No files found.
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/wx/WxController.java
View file @
1d98ae83
package
cn
.
quantgroup
.
xyqb
.
controller
.
middleoffice
.
wx
;
import
cn.quantgroup.xyqb.entity.CustomerInfoEntity
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.user.ITenantService
;
...
...
@@ -41,18 +43,23 @@ public class WxController {
if
(
tenantId
==
null
)
{
tenantId
=
TenantUtil
.
TENANT_DEFAULT
;
}
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
);
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
/* 校验租户ID */
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
wechatUserInfo
=
tenantService
.
getTenantCustomerInfo
(
wechatUserInfo
,
tenantId
);
if
(
tenantId
.
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
);
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
else
{
User
user
=
userService
.
findById
(
userId
);
if
(
user
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
CustomerInfoEntity
tenantCustomerInfo
=
tenantService
.
getTenantCustomerInfo
(
user
,
tenantId
);
if
(
tenantCustomerInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
tenantCustomerInfo
.
getSourceOpenId
());
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
/**
...
...
@@ -64,18 +71,28 @@ public class WxController {
*/
@GetMapping
(
"/userId/{userId}/{appName}"
)
public
JsonResult
openId
(
@PathVariable
Long
userId
,
@PathVariable
String
appName
,
@RequestParam
(
required
=
false
)
Integer
tenantId
)
{
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
,
appName
);
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
()
;
//默认羊小咩租户
if
(
tenantId
==
null
)
{
tenantId
=
TenantUtil
.
TENANT_DEFAULT
;
}
/* 校验租户ID */
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
wechatUserInfo
=
tenantService
.
getTenantCustomerInfo
(
wechatUserInfo
,
tenantId
);
if
(
tenantId
.
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryByUserId
(
userId
,
appName
);
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
else
{
User
user
=
userService
.
findById
(
userId
);
if
(
user
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
CustomerInfoEntity
tenantCustomerInfo
=
tenantService
.
getTenantCustomerInfo
(
user
,
tenantId
);
if
(
tenantCustomerInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
tenantCustomerInfo
.
getSourceOpenId
());
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
/**
...
...
@@ -89,18 +106,23 @@ public class WxController {
if
(
tenantId
==
null
)
{
tenantId
=
TenantUtil
.
TENANT_DEFAULT
;
}
WechatUserInfo
wechatUserInfo
=
wechatService
.
findWechatUserInfoByPhoneNo
(
phoneNo
);
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
/* 校验租户ID */
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
wechatUserInfo
=
tenantService
.
getTenantCustomerInfo
(
wechatUserInfo
,
tenantId
);
if
(
tenantId
.
equals
(
TenantUtil
.
TENANT_DEFAULT
))
{
WechatUserInfo
wechatUserInfo
=
wechatService
.
findWechatUserInfoByPhoneNo
(
phoneNo
);
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
else
{
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
);
if
(
user
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
CustomerInfoEntity
tenantCustomerInfo
=
tenantService
.
getTenantCustomerInfo
(
user
,
tenantId
);
if
(
tenantCustomerInfo
==
null
)
{
return
JsonResult
.
buildSuccessResult
();
}
return
JsonResult
.
buildSuccessResultGeneric
(
tenantCustomerInfo
.
getSourceOpenId
());
}
return
JsonResult
.
buildSuccessResultGeneric
(
wechatUserInfo
.
getOpenId
());
}
@RequestMapping
(
"/code/{key}/{extdata}"
)
...
...
src/main/java/cn/quantgroup/xyqb/service/user/ITenantService.java
View file @
1d98ae83
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.CustomerInfoEntity
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
cn.quantgroup.xyqb.model.UserBrief
;
import
java.util.List
;
...
...
@@ -18,7 +18,7 @@ public interface ITenantService {
UserBrief
getTenantCustomerInfo
(
UserDetail
userDetail
,
Integer
tenantId
);
WechatUserInfo
getTenantCustomerInfo
(
WechatUserInfo
wechatUserInfo
,
Integer
tenantId
);
CustomerInfoEntity
getTenantCustomerInfo
(
User
user
,
Integer
tenantId
);
/**
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/TenantServiceImpl.java
View file @
1d98ae83
...
...
@@ -102,12 +102,12 @@ public class TenantServiceImpl implements ITenantService {
}
@Override
public
WechatUserInfo
getTenantCustomerInfo
(
WechatUserInfo
wechatUserInfo
,
Integer
tenantId
)
{
public
CustomerInfoEntity
getTenantCustomerInfo
(
User
user
,
Integer
tenantId
)
{
OauthClientDetailsEntity
oauthClientDetails
=
oauthClientDetailsService
.
findFirstByClientId
(
tenantId
);
if
(
oauthClientDetails
!=
null
)
{
ProductLoginEntity
productLogin
=
productLoginService
.
findSlaveByPloginInfo
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
wechatUserInfo
.
getUser
Id
());
ProductLoginEntity
productLogin
=
productLoginService
.
findSlaveByPloginInfo
(
oauthClientDetails
.
getInstitutionId
(),
oauthClientDetails
.
getProductId
(),
user
.
get
Id
());
if
(
productLogin
!=
null
)
{
if
(!
wechatUserInfo
.
getPhoneNo
().
equals
(
productLogin
.
getPhoneNo
()))
{
if
(!
user
.
getPhoneNo
().
equals
(
productLogin
.
getPhoneNo
()))
{
return
null
;
}
...
...
@@ -115,7 +115,7 @@ public class TenantServiceImpl implements ITenantService {
if
(
customerInfo
==
null
)
{
return
null
;
}
return
wechatUs
erInfo
;
return
custom
erInfo
;
}
}
return
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