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
3e4070e3
Commit
3e4070e3
authored
Mar 16, 2017
by
lee_mingzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change something
parent
d6590c44
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
192 additions
and
151 deletions
+192
-151
WeChatController.java
...group/xyqb/controller/external/user/WeChatController.java
+192
-151
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/WeChatController.java
View file @
3e4070e3
...
...
@@ -16,7 +16,9 @@ import cn.quantgroup.xyqb.service.wechat.IWechatService;
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
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -203,7 +205,7 @@ public class WeChatController implements IBaseController {
// welcome 首次登录
if
(
userInfoInDb
==
null
)
{
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if
(
StringUtils
.
isNotBlank
(
userInfo
.
getNickName
()))
{
if
(
StringUtils
.
isNotBlank
(
userInfo
.
getNickName
()))
{
String
nickName
=
EmojiUtil
.
filter
(
userInfo
.
getNickName
());
userInfo
.
setNickName
(
nickName
);
}
...
...
@@ -229,7 +231,6 @@ public class WeChatController implements IBaseController {
}
/**
* 前端微信跳转页面,通过extdata
*
...
...
@@ -268,10 +269,50 @@ public class WeChatController implements IBaseController {
}
}
/**
* 前端微信跳转页面,通过extdata
*
* @param response
* @return
*/
@RequestMapping
(
"/receiveCode/forward/{key}/{extdata}"
)
public
void
receiveCodeWithForward
(
String
code
,
@PathVariable
(
value
=
"key"
)
String
systemKey
,
@PathVariable
(
value
=
"extdata"
)
String
extData
,
HttpServletResponse
response
)
{
try
{
String
schema
=
getProtocol
();
extData
=
getExtData
(
extData
);
LOGGER
.
info
(
"从微信extdata版本接口进入:{}, extData:{}"
,
schema
,
extData
);
if
(
StringUtils
.
isEmpty
(
extData
))
{
normalLogin
(
code
,
systemKey
,
response
,
schema
);
}
else
{
HashMap
<
String
,
Object
>
extDataObj
;
try
{
extDataObj
=
JSON
.
parseObject
(
extData
,
new
TypeReference
<
HashMap
<
String
,
Object
>>()
{
});
}
catch
(
Exception
ex
)
{
LOGGER
.
error
(
"解析extData发生错误"
,
ex
);
// 从code获取token
normalLogin
(
code
,
systemKey
,
response
,
schema
);
return
;
}
selfDefinedLogin
(
code
,
systemKey
,
response
,
schema
,
extDataObj
);
}
}
catch
(
Exception
ex
)
{
LOGGER
.
error
(
"发生异常"
,
ex
);
throw
ex
;
}
}
private
String
getExtData
(
@PathVariable
(
value
=
"extdata"
)
String
extData
)
{
private
String
getExtData
(
String
extData
)
{
try
{
extData
=
new
String
(
Base64
.
decodeBase64
(
extData
),
"UTF-8"
);
}
catch
(
Exception
ex
)
{
...
...
@@ -400,14 +441,14 @@ public class WeChatController implements IBaseController {
private
String
createUserSession
(
User
user
,
Merchant
merchant
,
String
redirect
,
String
schema
,
Long
registerFrom
)
{
//TODO 临时紧急上线修改的.下次上线的时候修复一下,不能这样写.
String
url
=
schema
+
"//passport.xyqb.com"
;
if
(
StringUtils
.
isEmpty
(
redirect
)
||
"redirect"
.
equals
(
redirect
))
{
if
(
StringUtils
.
isEmpty
(
redirect
)
||
"redirect"
.
equals
(
redirect
))
{
LOGGER
.
info
(
"微信登录:redirect为null,走正常流程."
);
if
(
"baitiao"
.
equals
(
merchant
.
getName
()))
{
return
loginInWechatWithSessionCreated
(
user
,
merchant
,
"cashTarget5"
,
Constants
.
Channel
.
BAITIAO
,
url
,
Constants
.
Channel
.
WECHAT
);
}
else
{
return
loginInWechatWithSessionCreated
(
user
,
merchant
,
"cashTarget4"
,
1L
,
url
,
registerFrom
);
}
}
else
if
(
"local"
.
equals
(
redirect
))
{
}
else
if
(
"local"
.
equals
(
redirect
))
{
LOGGER
.
info
(
"微信登录:redirect不为null,创建session跳到指定前端页面."
);
AuthBean
authBean
=
sessionService
.
createSession
(
Constants
.
Channel
.
WECHAT
,
Constants
.
Channel
.
WECHAT
,
""
,
user
,
merchant
);
LOGGER
.
info
(
"微信登录:跳转地址{}"
,
url
+
"/weixin/callback?phoneNo="
+
user
.
getPhoneNo
()
+
"&token="
+
authBean
.
getToken
());
...
...
@@ -418,7 +459,7 @@ public class WeChatController implements IBaseController {
private
String
loginInWechatWithSessionCreated
(
User
user
,
Merchant
merchant
,
String
target
,
Long
channelId
,
String
url
,
Long
registerFrom
)
{
AuthBean
authBean
=
sessionService
.
createSession
(
channelId
,
registerFrom
,
""
,
user
,
merchant
);
return
url
+
"/landing?token="
+
authBean
.
getToken
()
+
"®isterFrom="
+
registerFrom
+
"&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
,
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