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
d595ca6e
Commit
d595ca6e
authored
Mar 16, 2017
by
zhouqian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get protocol
parent
02b06672
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
174 additions
and
68 deletions
+174
-68
WeChatController.java
...group/xyqb/controller/external/user/WeChatController.java
+174
-68
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/WeChatController.java
View file @
d595ca6e
...
@@ -15,6 +15,9 @@ import cn.quantgroup.xyqb.service.session.ISessionService;
...
@@ -15,6 +15,9 @@ import cn.quantgroup.xyqb.service.session.ISessionService;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.util.EmojiUtil
;
import
cn.quantgroup.xyqb.util.EmojiUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
java.util.HashMap
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -176,7 +179,9 @@ public class WeChatController implements IBaseController {
...
@@ -176,7 +179,9 @@ public class WeChatController implements IBaseController {
* @return
* @return
*/
*/
@RequestMapping
(
"/receiveCode/{key}/{redirect}"
)
@RequestMapping
(
"/receiveCode/{key}/{redirect}"
)
public
void
receiveCode
(
String
code
,
@PathVariable
(
value
=
"key"
)
String
systemKey
,
@PathVariable
String
redirect
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
receiveCode
(
String
code
,
@PathVariable
(
value
=
"key"
)
String
systemKey
,
@PathVariable
String
redirect
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
String
schema
=
request
.
getScheme
();
String
schema
=
request
.
getScheme
();
LOGGER
.
info
(
"HTTP协议:"
+
schema
);
LOGGER
.
info
(
"HTTP协议:"
+
schema
);
// 从code获取token
// 从code获取token
...
@@ -185,13 +190,13 @@ public class WeChatController implements IBaseController {
...
@@ -185,13 +190,13 @@ public class WeChatController implements IBaseController {
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
if
(
token
==
null
)
{
if
(
token
==
null
)
{
// 让用户登录,不关联微信, 构造不关联微信的url
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
);
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
// 让用户登录,不关联微信, 构造不关联微信的url
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
);
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
WechatUserInfo
userInfoInDb
=
wechatService
.
findWechatUserInfoFromDb
(
userInfo
.
getOpenId
());
WechatUserInfo
userInfoInDb
=
wechatService
.
findWechatUserInfoFromDb
(
userInfo
.
getOpenId
());
...
@@ -203,22 +208,22 @@ public class WeChatController implements IBaseController {
...
@@ -203,22 +208,22 @@ public class WeChatController implements IBaseController {
userInfo
.
setNickName
(
nickName
);
userInfo
.
setNickName
(
nickName
);
}
}
userInfo
=
wechatService
.
saveWechatUserInfo
(
userInfo
);
userInfo
=
wechatService
.
saveWechatUserInfo
(
userInfo
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfo
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfo
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
if
(
user
==
null
)
{
if
(
user
==
null
)
{
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
// 已经关联了用户
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
// create session, 登进去,该怎么玩怎么玩。
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
redirect
,
schema
);
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
redirect
,
schema
,
Constants
.
Channel
.
WECHAT
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
response
.
setStatus
(
301
);
}
}
...
@@ -238,48 +243,149 @@ public class WeChatController implements IBaseController {
...
@@ -238,48 +243,149 @@ public class WeChatController implements IBaseController {
)
{
)
{
String
schema
=
getProtocol
();
String
schema
=
getProtocol
();
LOGGER
.
info
(
"从微信extdata版本接口进入:{}, extData:{}"
,
schema
,
extData
);
LOGGER
.
info
(
"从微信extdata版本接口进入:{}, extData:{}"
,
schema
,
extData
);
// 从code获取token
if
(
StringUtils
.
isEmpty
(
extData
))
{
Merchant
merchant
=
merchantService
.
findMerchantByName
(
systemKey
);
// 从code获取token
Merchant
merchant
=
merchantService
.
findMerchantByName
(
systemKey
);
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
if
(
token
==
null
)
{
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
// 让用户登录,不关联微信, 构造不关联微信的url
if
(
token
==
null
)
{
redirectNormalUrl
(
response
,
merchant
);
// 让用户登录,不关联微信, 构造不关联微信的url
return
;
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
);
}
return
;
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
);
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
);
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfo
);
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
return
;
// 让用户登录,不关联微信, 构造不关联微信的url
}
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
);
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
return
;
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
}
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
);
WechatUserInfo
userInfoInDb
=
wechatService
.
findWechatUserInfoFromDb
(
userInfo
.
getOpenId
());
return
;
// welcome 首次登录
}
if
(
userInfoInDb
==
null
)
{
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if
(
user
==
null
)
{
if
(
StringUtils
.
isNotBlank
(
userInfo
.
getNickName
()))
{
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
);
String
nickName
=
EmojiUtil
.
filter
(
userInfo
.
getNickName
());
return
;
userInfo
.
setNickName
(
nickName
);
}
userInfo
=
wechatService
.
saveWechatUserInfo
(
userInfo
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfo
,
Constants
.
Channel
.
WECHAT
);
return
;
}
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
);
return
;
}
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
if
(
user
==
null
)
{
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
);
return
;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
""
,
schema
,
Constants
.
Channel
.
WECHAT
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
}
else
{
HashMap
<
String
,
Object
>
extDataObj
;
try
{
extDataObj
=
JSON
.
parseObject
(
extData
,
new
TypeReference
<
HashMap
<
String
,
Object
>>()
{
});
}
catch
(
Exception
ex
)
{
LOGGER
.
info
(
"HTTP协议no redirect:"
+
schema
);
// 从code获取token
Merchant
merchant
=
merchantService
.
findMerchantByName
(
systemKey
);
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
if
(
token
==
null
)
{
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
);
return
;
}
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
);
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
);
return
;
}
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
);
return
;
}
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
if
(
user
==
null
)
{
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
);
return
;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
""
,
schema
,
Constants
.
Channel
.
WECHAT
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
return
;
}
Long
registerFrom
=
(
Long
)
extDataObj
.
getOrDefault
(
"registerFrom"
,
1L
);
String
redirect
=
(
String
)
extDataObj
.
getOrDefault
(
"redirect"
,
"redirect"
);
Merchant
merchant
=
merchantService
.
findMerchantByName
(
systemKey
);
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
if
(
token
==
null
)
{
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
,
registerFrom
);
return
;
}
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
,
registerFrom
);
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
,
registerFrom
);
return
;
}
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
registerFrom
);
return
;
}
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
if
(
user
==
null
)
{
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
registerFrom
);
return
;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
redirect
,
schema
,
registerFrom
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
}
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
""
,
schema
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
}
}
...
@@ -299,13 +405,13 @@ public class WeChatController implements IBaseController {
...
@@ -299,13 +405,13 @@ public class WeChatController implements IBaseController {
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
AccessTokenResponse
token
=
wechatService
.
getToken
(
code
);
if
(
token
==
null
)
{
if
(
token
==
null
)
{
// 让用户登录,不关联微信, 构造不关联微信的url
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
);
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
WechatUserInfo
userInfo
=
wechatService
.
getWechatUserInfoFromWechatServer
(
token
.
getAccessToken
(),
token
.
getOpenId
());
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
if
(
userInfo
==
null
||
StringUtils
.
isEmpty
(
userInfo
.
getOpenId
()))
{
// 让用户登录,不关联微信, 构造不关联微信的url
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl
(
response
,
merchant
);
redirectNormalUrl
(
response
,
merchant
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
WechatUserInfo
userInfoInDb
=
wechatService
.
findWechatUserInfoFromDb
(
userInfo
.
getOpenId
());
WechatUserInfo
userInfoInDb
=
wechatService
.
findWechatUserInfoFromDb
(
userInfo
.
getOpenId
());
...
@@ -317,27 +423,27 @@ public class WeChatController implements IBaseController {
...
@@ -317,27 +423,27 @@ public class WeChatController implements IBaseController {
userInfo
.
setNickName
(
nickName
);
userInfo
.
setNickName
(
nickName
);
}
}
userInfo
=
wechatService
.
saveWechatUserInfo
(
userInfo
);
userInfo
=
wechatService
.
saveWechatUserInfo
(
userInfo
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfo
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfo
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
if
(
userInfoInDb
.
getUserId
()
==
null
)
{
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
User
user
=
userService
.
findById
(
userInfoInDb
.
getUserId
());
if
(
user
==
null
)
{
if
(
user
==
null
)
{
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
);
redirectWechatLoginUrlWithoutLogin
(
response
,
merchant
,
userInfoInDb
,
Constants
.
Channel
.
WECHAT
);
return
;
return
;
}
}
// 已经关联了用户
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
// create session, 登进去,该怎么玩怎么玩。
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
""
,
schema
);
String
redirectUrl
=
createUserSession
(
user
,
merchant
,
""
,
schema
,
Constants
.
Channel
.
WECHAT
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
response
.
setStatus
(
301
);
}
}
private
String
createUserSession
(
User
user
,
Merchant
merchant
,
String
redirect
,
String
schema
)
{
private
String
createUserSession
(
User
user
,
Merchant
merchant
,
String
redirect
,
String
schema
,
Long
registerFrom
)
{
//TODO 临时紧急上线修改的.下次上线的时候修复一下,不能这样写.
//TODO 临时紧急上线修改的.下次上线的时候修复一下,不能这样写.
String
url
=
"http://passport.xyqb.com"
;
String
url
=
"http://passport.xyqb.com"
;
if
(
"https"
.
equals
(
schema
))
{
if
(
"https"
.
equals
(
schema
))
{
...
@@ -346,9 +452,9 @@ public class WeChatController implements IBaseController {
...
@@ -346,9 +452,9 @@ public class WeChatController implements IBaseController {
if
(
StringUtils
.
isEmpty
(
redirect
)
||
"redirect"
.
equals
(
redirect
))
{
if
(
StringUtils
.
isEmpty
(
redirect
)
||
"redirect"
.
equals
(
redirect
))
{
LOGGER
.
info
(
"微信登录:redirect为null,走正常流程."
);
LOGGER
.
info
(
"微信登录:redirect为null,走正常流程."
);
if
(
"baitiao"
.
equals
(
merchant
.
getName
()))
{
if
(
"baitiao"
.
equals
(
merchant
.
getName
()))
{
return
loginInWechatWithSessionCreated
(
user
,
merchant
,
"cashTarget5"
,
Constants
.
Channel
.
BAITIAO
,
url
);
return
loginInWechatWithSessionCreated
(
user
,
merchant
,
"cashTarget5"
,
Constants
.
Channel
.
BAITIAO
,
url
,
Constants
.
Channel
.
WECHAT
);
}
else
{
}
else
{
return
loginInWechatWithSessionCreated
(
user
,
merchant
,
"cashTarget4"
,
1L
,
url
);
return
loginInWechatWithSessionCreated
(
user
,
merchant
,
"cashTarget4"
,
1L
,
url
,
registerFrom
);
}
}
}
else
if
(
"local"
.
equals
(
redirect
)){
}
else
if
(
"local"
.
equals
(
redirect
)){
LOGGER
.
info
(
"微信登录:redirect不为null,创建session跳到指定前端页面."
);
LOGGER
.
info
(
"微信登录:redirect不为null,创建session跳到指定前端页面."
);
...
@@ -359,36 +465,36 @@ public class WeChatController implements IBaseController {
...
@@ -359,36 +465,36 @@ public class WeChatController implements IBaseController {
return
null
;
return
null
;
}
}
private
String
loginInWechatWithSessionCreated
(
User
user
,
Merchant
merchant
,
String
target
,
Long
channelId
,
String
url
)
{
private
String
loginInWechatWithSessionCreated
(
User
user
,
Merchant
merchant
,
String
target
,
Long
channelId
,
String
url
,
Long
registerFrom
)
{
AuthBean
authBean
=
sessionService
.
createSession
(
channelId
,
Constants
.
Channel
.
WECHAT
,
""
,
user
,
merchant
);
AuthBean
authBean
=
sessionService
.
createSession
(
channelId
,
registerFrom
,
""
,
user
,
merchant
);
return
url
+
"/landing?token="
+
authBean
.
getToken
()
+
"®isterFrom=
198
&channelId="
+
channelId
+
"&key="
+
merchant
.
getName
()
+
"&target="
+
target
;
return
url
+
"/landing?token="
+
authBean
.
getToken
()
+
"®isterFrom=
"
+
registerFrom
+
"
&channelId="
+
channelId
+
"&key="
+
merchant
.
getName
()
+
"&target="
+
target
;
}
}
private
void
redirectWechatLoginUrlWithoutLogin
(
HttpServletResponse
response
,
Merchant
merchant
,
WechatUserInfo
userInfo
)
{
private
void
redirectWechatLoginUrlWithoutLogin
(
HttpServletResponse
response
,
Merchant
merchant
,
WechatUserInfo
userInfo
,
Long
registerFrom
)
{
String
redirectUrl
=
assembleWechatRedirectUrl
(
merchant
,
userInfo
);
String
redirectUrl
=
assembleWechatRedirectUrl
(
merchant
,
userInfo
,
registerFrom
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
response
.
setStatus
(
301
);
}
}
private
void
redirectNormalUrl
(
HttpServletResponse
response
,
Merchant
merchant
)
{
private
void
redirectNormalUrl
(
HttpServletResponse
response
,
Merchant
merchant
,
Long
registerFrom
)
{
String
redirectUrl
=
assembleNormalRedirectUrl
(
merchant
);
String
redirectUrl
=
assembleNormalRedirectUrl
(
merchant
,
registerFrom
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setHeader
(
"Location"
,
redirectUrl
);
response
.
setStatus
(
301
);
response
.
setStatus
(
301
);
}
}
private
String
assembleNormalRedirectUrl
(
Merchant
merchant
)
{
private
String
assembleNormalRedirectUrl
(
Merchant
merchant
,
Long
registerFrom
)
{
if
(
"baitiao"
.
equals
(
merchant
.
getName
()))
{
if
(
"baitiao"
.
equals
(
merchant
.
getName
()))
{
return
userUIAddr
+
"/landing?key=baitiao&target=cashTarget5&
registerFrom=198&channelId=222
"
;
return
userUIAddr
+
"/landing?key=baitiao&target=cashTarget5&
channelId=222®isterFrom=198
"
;
}
else
{
}
else
{
return
userUIAddr
+
"/landing?key=xyqb&target=cashTarget4&
registerFrom=198&channelId=1"
;
return
userUIAddr
+
"/landing?key=xyqb&target=cashTarget4&
channelId=1®isterFrom="
+
registerFrom
;
}
}
}
}
private
String
assembleWechatRedirectUrl
(
Merchant
merchant
,
WechatUserInfo
userInfo
)
{
private
String
assembleWechatRedirectUrl
(
Merchant
merchant
,
WechatUserInfo
userInfo
,
Long
registerFrom
)
{
if
(
"baitiao"
.
equals
(
merchant
.
getName
()))
{
if
(
"baitiao"
.
equals
(
merchant
.
getName
()))
{
return
userUIAddr
+
"/landing?key=baitiao&target=cashTarget5®isterFrom=198&channelId=222&isWechat=true&openId="
+
userInfo
.
getOpenId
();
return
userUIAddr
+
"/landing?key=baitiao&target=cashTarget5®isterFrom=198&channelId=222&isWechat=true&openId="
+
userInfo
.
getOpenId
();
}
else
{
}
else
{
return
userUIAddr
+
"/landing?key=xyqb&target=cashTarget4®isterFrom=
198
&channelId=1&isWechat=true&openId="
+
userInfo
.
getOpenId
();
return
userUIAddr
+
"/landing?key=xyqb&target=cashTarget4®isterFrom=
"
+
registerFrom
+
"
&channelId=1&isWechat=true&openId="
+
userInfo
.
getOpenId
();
}
}
}
}
...
...
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