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
ed0e9e6b
Commit
ed0e9e6b
authored
Jan 22, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复微信还款/代还的landing资源定位符
parent
d23e6a5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
45 deletions
+6
-45
WeChatController.java
...group/xyqb/controller/external/user/WeChatController.java
+6
-45
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/WeChatController.java
View file @
ed0e9e6b
...
@@ -270,52 +270,13 @@ public class WeChatController implements IBaseController {
...
@@ -270,52 +270,13 @@ public class WeChatController implements IBaseController {
*/
*/
@RequestMapping
(
"/receiveCode/{key}"
)
@RequestMapping
(
"/receiveCode/{key}"
)
public
void
receiveCodeNoRedirect
(
String
code
,
@PathVariable
(
value
=
"key"
)
String
systemKey
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
receiveCodeNoRedirect
(
String
code
,
@PathVariable
(
value
=
"key"
)
String
systemKey
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
String
schema
=
request
.
getScheme
();
Long
registerFrom
=
null
;
String
protocol
=
"http:"
;
String
redirect
=
null
;
LOGGER
.
info
(
"HTTP协议no redirect:"
+
schema
);
String
schema
=
"http:"
;
// 从code获取token
if
(
Objects
.
equals
(
"https:"
,
request
.
getScheme
())){
Merchant
merchant
=
merchantService
.
findMerchantByName
(
systemKey
);
schema
=
"https:"
;
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
if
(
token
==
null
)
{
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
,
protocol
);
return
;
}
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
,
protocol
);
return
;
}
WechatUserInfo
userInfoInDb
=
wechatService
.
findWechatUserInfoFromDb
(
userInfo
.
getOpenId
());
// welcome 首次登录
if
(
userInfoInDb
==
null
)
{
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if
(
StringUtils
.
isNotBlank
(
userInfo
.
getNickName
()))
{
String
nickName
=
EmojiUtil
.
filter
(
userInfo
.
getNickName
());
userInfo
.
setNickName
(
nickName
);
}
userInfo
=
wechatService
.
saveWechatUserInfo
(
userInfo
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfo
,
Constants
.
Channel
.
WECHAT
,
protocol
);
return
;
}
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
,
protocol
);
return
;
}
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
if
(
user
==
null
)
{
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
,
protocol
);
return
;
}
}
// 已经关联了用户
receiveCodeWithDefault
(
code
,
systemKey
,
schema
,
registerFrom
,
redirect
,
response
);
// create session, 登进去,该怎么玩怎么玩。
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
""
,
schema
,
Constants
.
Channel
.
WECHAT
);
LOGGER
.
info
(
"Location=[{}]"
,
redirectUrl
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
}
}
private
String
createUserSession
(
User
user
,
Merchant
merchant
,
String
redirect
,
String
domain
,
Long
registerFrom
)
{
private
String
createUserSession
(
User
user
,
Merchant
merchant
,
String
redirect
,
String
domain
,
Long
registerFrom
)
{
...
...
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