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
41b418cd
Commit
41b418cd
authored
Jun 03, 2021
by
曾水平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充日志
parent
9d8b7ed1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
10 deletions
+38
-10
JdApiUtil.java
...cn/com/duiba/jdactivity/developer/jd/utils/JdApiUtil.java
+38
-10
No files found.
src/main/java/cn/com/duiba/jdactivity/developer/jd/utils/JdApiUtil.java
View file @
41b418cd
...
...
@@ -65,24 +65,29 @@ public class JdApiUtil {
private
static
final
String
CODE_SUCCESS
=
"0"
;
private
static
final
DateTimeFormatter
formatTime
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
private
static
DefaultJdClient
getJdClient
(
JdAppEnum
jdAppEnum
,
String
accessToken
)
{
return
new
DefaultJdClient
(
JdServerUrlEnum
.
API_URL
.
getUrl
(),
accessToken
,
jdAppEnum
.
getAppKey
(),
jdAppEnum
.
getAppSecret
());
}
/**
* 查询商家基本信息
*/
public
Result
<
ShopJosResult
>
venderShopQuery
(
JdAppEnum
jdAppEnum
,
String
accessToken
)
{
try
{
JdClient
client
=
getJdClient
(
jdAppEnum
,
accessToken
);
VenderShopQueryRequest
request
=
new
VenderShopQueryRequest
();
JdClient
client
=
getJdClient
(
jdAppEnum
,
accessToken
);
VenderShopQueryResponse
response
=
client
.
execute
(
request
);
if
(!
CODE_SUCCESS
.
equals
(
response
.
getCode
()))
{
LOGGER
.
warn
(
"失败:request:{},return_code:{},return_msg:{}"
,
JSON
.
toJSONString
(
request
),
response
.
getCode
(),
response
.
getZhDesc
());
return
ResultBuilder
.
fail
(
"失败:"
+
response
.
getZhDesc
());
}
return
ResultBuilder
.
success
(
response
.
getShopJosResult
());
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"venderShopQuery,exception"
,
e
);
return
ResultBuilder
.
fail
(
"发生异常"
);
}
}
/**
* 查询用户明文PIN
*
...
...
@@ -95,9 +100,13 @@ public class JdApiUtil {
request
.
setSource
(
source
);
request
.
setToken
(
token
);
PopJmCenterUserGetOpenIdResponse
response
=
client
.
execute
(
request
);
if
(!
CODE_SUCCESS
.
equals
(
response
.
getCode
()))
{
LOGGER
.
warn
(
"失败:request:{},return_code:{},return_msg:{}"
,
JSON
.
toJSONString
(
request
),
response
.
getCode
(),
response
.
getZhDesc
());
return
ResultBuilder
.
fail
(
"失败:"
+
response
.
getZhDesc
());
}
return
ResultBuilder
.
success
(
response
.
getReturnType
().
getPin
());
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"
venderShopQuery
,exception"
,
e
);
LOGGER
.
warn
(
"
getPinByToken
,exception"
,
e
);
return
ResultBuilder
.
fail
(
"发生异常"
);
}
...
...
@@ -115,6 +124,10 @@ public class JdApiUtil {
request
.
setSource
(
source
);
request
.
setToken
(
token
);
PopJmCenterUserGetEncryptPinNewResponse
response
=
client
.
execute
(
request
);
if
(!
CODE_SUCCESS
.
equals
(
response
.
getCode
()))
{
LOGGER
.
warn
(
"失败:request:{},return_code:{},return_msg:{}"
,
JSON
.
toJSONString
(
request
),
response
.
getCode
(),
response
.
getZhDesc
());
return
ResultBuilder
.
fail
(
"失败:"
+
response
.
getZhDesc
());
}
return
ResultBuilder
.
success
(
response
.
getReturnType
().
getPin
());
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"venderShopQuery,exception"
,
e
);
...
...
@@ -135,6 +148,10 @@ public class JdApiUtil {
request
.
setSource
(
source
);
request
.
setAppKey
(
jdAppEnum
.
getAppKey
());
JosTokenSourceToOpenIdResponse
response
=
client
.
execute
(
request
);
if
(!
CODE_SUCCESS
.
equals
(
response
.
getCode
()))
{
LOGGER
.
warn
(
"失败:request:{},return_code:{},return_msg:{}"
,
JSON
.
toJSONString
(
request
),
response
.
getCode
(),
response
.
getZhDesc
());
return
ResultBuilder
.
fail
(
"失败:"
+
response
.
getZhDesc
());
}
return
ResultBuilder
.
success
(
response
.
getResult
().
getOpenId
());
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"venderShopQuery,exception"
,
e
);
...
...
@@ -152,6 +169,10 @@ public class JdApiUtil {
UserGetUserInfoByOpenIdRequest
request
=
new
UserGetUserInfoByOpenIdRequest
();
request
.
setOpenId
(
openId
);
UserGetUserInfoByOpenIdResponse
response
=
client
.
execute
(
request
);
if
(!
CODE_SUCCESS
.
equals
(
response
.
getCode
()))
{
LOGGER
.
warn
(
"失败:request:{},return_code:{},return_msg:{}"
,
JSON
.
toJSONString
(
request
),
response
.
getCode
(),
response
.
getZhDesc
());
return
ResultBuilder
.
fail
(
"失败:"
+
response
.
getZhDesc
());
}
return
ResultBuilder
.
success
(
response
.
getGetuserinfobyappidandopenidResult
().
getData
());
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"venderShopQuery,exception"
,
e
);
...
...
@@ -159,7 +180,6 @@ public class JdApiUtil {
}
}
/**
* 查询 pin 在商家下的会员信息
* 性别 (0: 男,1: 女)
...
...
@@ -172,6 +192,10 @@ public class JdApiUtil {
request
.
setOpenIdBuyer
(
pin
);
PopCrmCustomerGetCustomerResponse
response
=
client
.
execute
(
request
);
LOGGER
.
info
(
"查询 pin 在商家下的会员信息,pin={},response={}"
,
pin
,
JSON
.
toJSONString
(
response
));
if
(!
CODE_SUCCESS
.
equals
(
response
.
getCode
()))
{
LOGGER
.
warn
(
"失败:request:{},return_code:{},return_msg:{}"
,
JSON
.
toJSONString
(
request
),
response
.
getCode
(),
response
.
getZhDesc
());
return
ResultBuilder
.
fail
(
"失败:"
+
response
.
getZhDesc
());
}
return
ResultBuilder
.
success
(
response
.
getReturnResult
().
getData
());
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"venderShopQuery,exception"
,
e
);
...
...
@@ -193,6 +217,10 @@ public class JdApiUtil {
request
.
setOpenIdBuyer
(
pin
);
PopCrmGetMemberInVenderResponse
response
=
client
.
execute
(
request
);
LOGGER
.
info
(
"返回用户在某个商家下的会员信息,pin={},response={}"
,
pin
,
JSON
.
toJSONString
(
response
));
if
(!
CODE_SUCCESS
.
equals
(
response
.
getCode
()))
{
LOGGER
.
warn
(
"失败:request:{},return_code:{},return_msg:{}"
,
JSON
.
toJSONString
(
request
),
response
.
getCode
(),
response
.
getZhDesc
());
return
ResultBuilder
.
fail
(
"失败:"
+
response
.
getZhDesc
());
}
return
Optional
.
ofNullable
(
response
)
.
map
(
PopCrmGetMemberInVenderResponse:
:
getGetmemberinvenderResult
)
.
map
(
CommonResult:
:
getCustomerInfoEs
)
...
...
@@ -205,10 +233,6 @@ public class JdApiUtil {
}
}
private
DefaultJdClient
getJdClient
(
JdAppEnum
jdAppEnum
,
String
accessToken
)
{
return
new
DefaultJdClient
(
JdServerUrlEnum
.
API_URL
.
getUrl
(),
accessToken
,
jdAppEnum
.
getAppKey
(),
jdAppEnum
.
getAppSecret
());
}
/**
* 是否已关注该店铺
*/
...
...
@@ -282,6 +306,10 @@ public class JdApiUtil {
JdClient
client
=
getJdClient
(
jdAppEnum
,
accessToken
);
GetPurchaseInfoRequest
request
=
new
GetPurchaseInfoRequest
();
GetPurchaseInfoResponse
response
=
client
.
execute
(
request
);
if
(!
CODE_SUCCESS
.
equals
(
response
.
getCode
()))
{
LOGGER
.
warn
(
"失败:request:{},return_code:{},return_msg:{}"
,
JSON
.
toJSONString
(
request
),
response
.
getCode
(),
response
.
getZhDesc
());
return
ResultBuilder
.
fail
(
"失败:"
+
response
.
getZhDesc
());
}
return
Optional
.
ofNullable
(
response
)
.
map
(
GetPurchaseInfoResponse:
:
getReturnType
)
.
map
(
JmServiceResult:
:
getPurchaseInfoList
)
...
...
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