Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jd-activity
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
曾水平
jd-activity
Commits
49d71cad
Commit
49d71cad
authored
Nov 08, 2021
by
郝增润
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兼容微信端
parent
d56cb3d4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
56 deletions
+10
-56
Open2DuibaController.java
...com/duiba/jdactivity/controller/Open2DuibaController.java
+1
-55
autologin.html
src/main/resources/templates/autologin.html
+8
-0
autologin3.html
src/main/resources/templates/autologin3.html
+1
-1
No files found.
src/main/java/cn/com/duiba/jdactivity/controller/Open2DuibaController.java
View file @
49d71cad
...
...
@@ -180,61 +180,7 @@ public class Open2DuibaController {
try
{
LOGGER
.
info
(
"autologin,autologinParam={}"
,
JSON
.
toJSONString
(
autologinParam
));
String
token
=
autologinParam
.
getToken
();
String
source
=
JdTokenSourceEnum
.
JD
.
getSource
();
String
redirectUrl
=
autologinParam
.
getRedirectUrl
();
String
env
=
autologinParam
.
getEnv
();
Long
venderId
=
autologinParam
.
getVenderId
();
Long
shopId
=
autologinParam
.
getShopId
();
if
(
venderId
==
null
&&
shopId
==
null
)
{
//最开始波司登无这两个参数
venderId
=
JdShopEnum
.
BOSIDENG
.
getVenderId
();
shopId
=
JdShopEnum
.
BOSIDENG
.
getShopId
();
}
// 兑吧应用
DuibaAppEnum
duibaApp
=
Optional
.
ofNullable
(
DuibaAppEnum
.
getDuibaApp
(
autologinParam
.
getAppKey
()))
.
orElse
(
DuibaAppEnum
.
BOSIDENG_PROD
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
venderId
,
shopId
);
LOGGER
.
info
(
"获取accessToken,结果={}"
,
JSON
.
toJSONString
(
accessToken
));
JdAppEnum
appByAppKey
=
JdAppEnum
.
getAppByAppKey
(
accessToken
.
getAppKey
());
Result
<
String
>
pinByToken
=
jdApiUtil
.
getPinByToken
(
appByAppKey
,
accessToken
.
getAccessToken
(),
source
,
token
);
LOGGER
.
info
(
"获取pin,结果={}"
,
JSON
.
toJSONString
(
pinByToken
));
Result
<
String
>
openIdByToken
=
jdApiUtil
.
getOpenIdByToken
(
appByAppKey
,
source
,
token
);
LOGGER
.
info
(
"获取openId,结果={}"
,
JSON
.
toJSONString
(
openIdByToken
));
Result
<
OAuthUserInfo
>
userInfoByOpenId
=
jdApiUtil
.
getUserInfoByOpenId
(
appByAppKey
,
accessToken
.
getAccessToken
(),
openIdByToken
.
getData
());
LOGGER
.
info
(
"获取userInfo,结果={}"
,
JSON
.
toJSONString
(
userInfoByOpenId
));
String
uid
=
convert2Uid
(
appByAppKey
,
accessToken
.
getAccessToken
(),
pinByToken
.
getData
());
LOGGER
.
info
(
"加密pin,pin={},uid={}"
,
pinByToken
.
getData
(),
uid
);
String
nickName
=
userInfoByOpenId
.
getData
().
getNickName
();
String
avatar
=
userInfoByOpenId
.
getData
().
getImageUrl
();
String
credits
=
null
;
if
(
StringUtils
.
equals
(
autologinParam
.
getNeedCredits
(),
"1"
))
{
Result
<
Long
>
customerPoints
=
jdApiUtil
.
getCustomerPoints
(
appByAppKey
,
pinByToken
.
getData
(),
accessToken
.
getAccessToken
());
credits
=
String
.
valueOf
(
customerPoints
.
getData
());
}
String
autoLogin
=
autologin
(
duibaApp
,
uid
,
nickName
,
avatar
,
redirectUrl
,
env
,
credits
);
LOGGER
.
info
(
"autoLogin={}"
,
autoLogin
);
return
ResultBuilder
.
success
(
autoLogin
);
}
catch
(
BizException
e
)
{
return
ResultBuilder
.
fail
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"跳转异常"
,
e
);
return
ResultBuilder
.
fail
(
"跳转异常"
);
}
}
@PostMapping
(
"/autologin2"
)
public
Result
<
String
>
autologin2
(
@RequestBody
AutologinParam
autologinParam
)
{
try
{
LOGGER
.
info
(
"autologin,autologinParam={}"
,
JSON
.
toJSONString
(
autologinParam
));
String
token
=
autologinParam
.
getToken
();
// String source = JdTokenSourceEnum.JD.getSource();
String
source
=
Optional
.
ofNullable
(
autologinParam
.
getSource
()).
orElse
(
JdTokenSourceEnum
.
JD
.
getSource
());
LOGGER
.
info
(
"source,source={}"
,
source
);
String
redirectUrl
=
autologinParam
.
getRedirectUrl
();
...
...
src/main/resources/templates/autologin.html
View file @
49d71cad
...
...
@@ -51,6 +51,14 @@
function
openLoginPanel
()
{
console
.
log
(
"登录面板"
)
var
isWechat
=
JSSDK
.
Client
.
isWeixin
();
var
isQQ
=
JSSDK
.
Client
.
isQQ
();
if
(
isWechat
||
isQQ
)
{
var
redirectUrlPrimary
=
window
.
location
.
href
.
replace
(
'autologin'
,
'autologin3'
)
+
'&source=02'
var
url
=
'https://wq.jd.com/pinbind/pintokenredirect?biz=jm-business-center&url='
+
encodeURIComponent
(
redirectUrlPrimary
)
window
.
location
.
href
=
url
;
return
;
}
JSSDK
.
Isv
.
requestLogin
(
isLogin
);
}
...
...
src/main/resources/templates/autologin3.html
View file @
49d71cad
...
...
@@ -94,7 +94,7 @@
$
.
ajax
({
type
:
'post'
,
url
:
`/open2Duiba/autologin
2
`
,
url
:
`/open2Duiba/autologin`
,
data
:
JSON
.
stringify
({
token
:
token
,
redirectUrl
:
redirect
,
...
...
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