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
0c1e95c4
Commit
0c1e95c4
authored
Jun 22, 2021
by
曾水平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接互动加积分
parent
f57681b8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
172 additions
and
39 deletions
+172
-39
Open2DuibaController.java
...com/duiba/jdactivity/controller/Open2DuibaController.java
+67
-38
JdApiUtil.java
...cn/com/duiba/jdactivity/developer/jd/utils/JdApiUtil.java
+69
-1
DuibaSendPointsParam.java
...ava/cn/com/duiba/jdactivity/dto/DuibaSendPointsParam.java
+36
-0
No files found.
src/main/java/cn/com/duiba/jdactivity/controller/Open2DuibaController.java
View file @
0c1e95c4
...
@@ -16,6 +16,7 @@ import cn.com.duiba.jdactivity.developer.jd.utils.JdApiUtil;
...
@@ -16,6 +16,7 @@ import cn.com.duiba.jdactivity.developer.jd.utils.JdApiUtil;
import
cn.com.duiba.jdactivity.dto.AutologinParam
;
import
cn.com.duiba.jdactivity.dto.AutologinParam
;
import
cn.com.duiba.jdactivity.dto.DuibaAddCartParam
;
import
cn.com.duiba.jdactivity.dto.DuibaAddCartParam
;
import
cn.com.duiba.jdactivity.dto.DuibaSendCouponParam
;
import
cn.com.duiba.jdactivity.dto.DuibaSendCouponParam
;
import
cn.com.duiba.jdactivity.dto.DuibaSendPointsParam
;
import
cn.com.duiba.jdactivity.dto.DuibaUserParam
;
import
cn.com.duiba.jdactivity.dto.DuibaUserParam
;
import
cn.com.duiba.jdactivity.dto.TbShopAccessTokenDto
;
import
cn.com.duiba.jdactivity.dto.TbShopAccessTokenDto
;
import
cn.com.duiba.jdactivity.exception.BizException
;
import
cn.com.duiba.jdactivity.exception.BizException
;
...
@@ -315,28 +316,10 @@ public class Open2DuibaController {
...
@@ -315,28 +316,10 @@ public class Open2DuibaController {
}
}
}
}
/**
private
static
String
getUid
(
String
uid2
)
{
* 是否关注店铺
String
uid
=
uid2
;
*/
uid
=
uid
.
replaceAll
(
" "
,
"+"
);
@PostMapping
(
"/isFollowShop/v2"
)
return
uid
;
public
Result
<
Boolean
>
isFollowShopV2
(
@RequestBody
DuibaUserParam
duibaUserParam
)
{
try
{
String
uid
=
duibaUserParam
.
getUid
();
uid
=
uid
.
replaceAll
(
" "
,
"+"
);
signVerify
(
"是否关注店铺"
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
duibaUserParam
);
JdAppEnum
appEnum
=
JdAppEnum
.
getAppByAppKey
(
accessToken
.
getAppKey
());
String
pin
=
convert2Pin
(
appEnum
,
accessToken
.
getAccessToken
(),
uid
);
Result
<
Boolean
>
follow
=
jdApiUtil
.
isFollowByPinAndVid
(
appEnum
,
pin
,
duibaUserParam
.
getShopId
());
LOGGER
.
info
(
"是否关注店铺,follow={},uid={},pin={}"
,
JSON
.
toJSONString
(
follow
),
uid
,
pin
);
return
follow
;
}
catch
(
BizException
e
)
{
return
ResultBuilder
.
fail
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"isFollowShop 异常"
,
e
);
return
ResultBuilder
.
fail
(
"发生异常"
);
}
}
}
...
@@ -368,14 +351,36 @@ public class Open2DuibaController {
...
@@ -368,14 +351,36 @@ public class Open2DuibaController {
}
}
}
}
/**
* 是否关注店铺
*/
@PostMapping
(
"/isFollowShop/v2"
)
public
Result
<
Boolean
>
isFollowShopV2
(
@RequestBody
DuibaUserParam
duibaUserParam
)
{
try
{
String
uid
=
getUid
(
duibaUserParam
.
getUid
());
signVerify
(
"是否关注店铺"
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
duibaUserParam
);
JdAppEnum
appEnum
=
JdAppEnum
.
getAppByAppKey
(
accessToken
.
getAppKey
());
String
pin
=
convert2Pin
(
appEnum
,
accessToken
.
getAccessToken
(),
uid
);
Result
<
Boolean
>
follow
=
jdApiUtil
.
isFollowByPinAndVid
(
appEnum
,
pin
,
duibaUserParam
.
getShopId
());
LOGGER
.
info
(
"是否关注店铺,follow={},uid={},pin={}"
,
JSON
.
toJSONString
(
follow
),
uid
,
pin
);
return
follow
;
}
catch
(
BizException
e
)
{
return
ResultBuilder
.
fail
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"isFollowShop 异常"
,
e
);
return
ResultBuilder
.
fail
(
"发生异常"
);
}
}
/**
/**
* 关注店铺
* 关注店铺
*/
*/
@PostMapping
(
"/followShop/v2"
)
@PostMapping
(
"/followShop/v2"
)
public
Result
<
Boolean
>
followShopV2
(
@RequestBody
DuibaUserParam
duibaUserParam
)
{
public
Result
<
Boolean
>
followShopV2
(
@RequestBody
DuibaUserParam
duibaUserParam
)
{
try
{
try
{
String
uid
=
duibaUserParam
.
getUid
();
String
uid
=
getUid
(
duibaUserParam
.
getUid
());
uid
=
uid
.
replaceAll
(
" "
,
"+"
);
signVerify
(
"关注店铺"
);
signVerify
(
"关注店铺"
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
duibaUserParam
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
duibaUserParam
);
...
@@ -392,14 +397,41 @@ public class Open2DuibaController {
...
@@ -392,14 +397,41 @@ public class Open2DuibaController {
}
}
}
}
/**
* 发放优惠券
*/
@PostMapping
(
"/sendCouponId/v2"
)
public
Result
<
Boolean
>
sendCouponId
(
@RequestBody
DuibaSendCouponParam
param
)
{
try
{
String
uid
=
param
.
getUid
();
Long
couponId
=
param
.
getCouponId
();
String
uuid
=
param
.
getUuid
();
uid
=
uid
.
replaceAll
(
" "
,
"+"
);
signVerify
(
"发放优惠券"
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
param
);
JdAppEnum
appEnum
=
JdAppEnum
.
getAppByAppKey
(
accessToken
.
getAppKey
());
String
pin
=
convert2Pin
(
appEnum
,
accessToken
.
getAccessToken
(),
uid
);
Result
<
Boolean
>
sendCouponResult
=
jdApiUtil
.
pushCoupon
(
appEnum
,
accessToken
.
getAccessToken
(),
couponId
,
pin
,
uuid
);
LOGGER
.
info
(
"发放优惠券,sendCouponResult={},uid={},pin={},uuid={}"
,
JSON
.
toJSONString
(
sendCouponResult
),
uid
,
pin
,
uuid
);
return
sendCouponResult
;
}
catch
(
BizException
e
)
{
return
ResultBuilder
.
fail
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"发券异常"
,
e
);
return
ResultBuilder
.
fail
(
"发券失败"
);
}
}
/**
/**
* 是否是会员
* 是否是会员
*/
*/
@PostMapping
(
"/isMember/v2"
)
@PostMapping
(
"/isMember/v2"
)
public
Result
<
Boolean
>
isMemberV2
(
@RequestBody
DuibaUserParam
duibaUserParam
)
{
public
Result
<
Boolean
>
isMemberV2
(
@RequestBody
DuibaUserParam
duibaUserParam
)
{
try
{
try
{
String
uid
=
duibaUserParam
.
getUid
();
String
uid
=
getUid
(
duibaUserParam
.
getUid
());
uid
=
uid
.
replaceAll
(
" "
,
"+"
);
signVerify
(
"是否是会员"
);
signVerify
(
"是否是会员"
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
duibaUserParam
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
duibaUserParam
);
...
@@ -421,27 +453,24 @@ public class Open2DuibaController {
...
@@ -421,27 +453,24 @@ public class Open2DuibaController {
/**
/**
* 发放优惠券
* 发放优惠券
*/
*/
@PostMapping
(
"/send
CouponId/v2
"
)
@PostMapping
(
"/send
Points
"
)
public
Result
<
Boolean
>
send
CouponId
(
@RequestBody
DuibaSendCoupon
Param
param
)
{
public
Result
<
Boolean
>
send
Points
(
@RequestBody
DuibaSendPoints
Param
param
)
{
try
{
try
{
String
uid
=
param
.
getUid
();
String
uid
=
getUid
(
param
.
getUid
());
Long
couponId
=
param
.
getCouponId
();
signVerify
(
"互动积分发放积分"
);
String
uuid
=
param
.
getUuid
();
uid
=
uid
.
replaceAll
(
" "
,
"+"
);
signVerify
(
"发放优惠券"
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
param
);
TbShopAccessTokenDto
accessToken
=
accessTokenUtils
.
getAccessTokenWithCache
(
param
);
JdAppEnum
appEnum
=
JdAppEnum
.
getAppByAppKey
(
accessToken
.
getAppKey
());
JdAppEnum
appEnum
=
JdAppEnum
.
getAppByAppKey
(
accessToken
.
getAppKey
());
String
pin
=
convert2Pin
(
appEnum
,
accessToken
.
getAccessToken
(),
uid
);
String
pin
=
convert2Pin
(
appEnum
,
accessToken
.
getAccessToken
(),
uid
);
Result
<
Boolean
>
sendCouponResult
=
jdApiUtil
.
pushCoupon
(
appEnum
,
accessToken
.
getAccessToken
(),
couponId
,
pin
,
uuid
);
Result
<
Boolean
>
sendCouponResult
=
jdApiUtil
.
sendPoints
(
LOGGER
.
info
(
"发放优惠券,sendCouponResult={},uid={},pin={},uuid={}"
,
JSON
.
toJSONString
(
sendCouponResult
),
uid
,
pin
,
uuid
);
appEnum
,
pin
,
param
.
getBusinessId
(),
param
.
getPoints
(),
param
.
getDesc
(),
accessToken
.
getAccessToken
());
LOGGER
.
info
(
"互动积分发放积分,sendCouponResult={},uid={},pin={}"
,
JSON
.
toJSONString
(
sendCouponResult
),
uid
,
pin
);
return
sendCouponResult
;
return
sendCouponResult
;
}
catch
(
BizException
e
)
{
}
catch
(
BizException
e
)
{
return
ResultBuilder
.
fail
(
e
.
getMessage
());
return
ResultBuilder
.
fail
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"
发券
异常"
,
e
);
LOGGER
.
error
(
"
互动积分发放积分,
异常"
,
e
);
return
ResultBuilder
.
fail
(
"发券失败"
);
return
ResultBuilder
.
fail
(
"发券失败"
);
}
}
}
}
...
@@ -469,7 +498,7 @@ public class Open2DuibaController {
...
@@ -469,7 +498,7 @@ public class Open2DuibaController {
}
catch
(
BizException
e
)
{
}
catch
(
BizException
e
)
{
return
ResultBuilder
.
fail
(
e
.
getMessage
());
return
ResultBuilder
.
fail
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"
发券
异常"
,
e
);
LOGGER
.
error
(
"
通过用户pin加入购物车,
异常"
,
e
);
return
ResultBuilder
.
fail
(
"发券失败"
);
return
ResultBuilder
.
fail
(
"发券失败"
);
}
}
}
}
...
...
src/main/java/cn/com/duiba/jdactivity/developer/jd/utils/JdApiUtil.java
View file @
0c1e95c4
...
@@ -16,6 +16,7 @@ import com.jd.open.api.sdk.domain.seller.ShopSafService.response.query.ShopJosRe
...
@@ -16,6 +16,7 @@ import com.jd.open.api.sdk.domain.seller.ShopSafService.response.query.ShopJosRe
import
com.jd.open.api.sdk.domain.user.CrmCustomerService.response.getMemberInVender.CommonResult
;
import
com.jd.open.api.sdk.domain.user.CrmCustomerService.response.getMemberInVender.CommonResult
;
import
com.jd.open.api.sdk.domain.user.CrmCustomerService.response.getMemberInVender.CustomerInfoEs
;
import
com.jd.open.api.sdk.domain.user.CrmCustomerService.response.getMemberInVender.CustomerInfoEs
;
import
com.jd.open.api.sdk.domain.user.UserRelatedRpcService.response.getUserInfoByOpenId.OAuthUserInfo
;
import
com.jd.open.api.sdk.domain.user.UserRelatedRpcService.response.getUserInfoByOpenId.OAuthUserInfo
;
import
com.jd.open.api.sdk.request.crm.PointsJosSendPointsRequest
;
import
com.jd.open.api.sdk.request.crm.PopCrmCustomerGetCustomerRequest
;
import
com.jd.open.api.sdk.request.crm.PopCrmCustomerGetCustomerRequest
;
import
com.jd.open.api.sdk.request.gongzhonghao.JzoneAddCartItemByPinRequest
;
import
com.jd.open.api.sdk.request.gongzhonghao.JzoneAddCartItemByPinRequest
;
import
com.jd.open.api.sdk.request.market.GetPurchaseInfoRequest
;
import
com.jd.open.api.sdk.request.market.GetPurchaseInfoRequest
;
...
@@ -30,6 +31,7 @@ import com.jd.open.api.sdk.request.user.PopCrmGetMemberInVenderRequest;
...
@@ -30,6 +31,7 @@ import com.jd.open.api.sdk.request.user.PopCrmGetMemberInVenderRequest;
import
com.jd.open.api.sdk.request.user.PopJmCenterUserGetEncryptPinNewRequest
;
import
com.jd.open.api.sdk.request.user.PopJmCenterUserGetEncryptPinNewRequest
;
import
com.jd.open.api.sdk.request.user.PopJmCenterUserGetOpenIdRequest
;
import
com.jd.open.api.sdk.request.user.PopJmCenterUserGetOpenIdRequest
;
import
com.jd.open.api.sdk.request.user.UserGetUserInfoByOpenIdRequest
;
import
com.jd.open.api.sdk.request.user.UserGetUserInfoByOpenIdRequest
;
import
com.jd.open.api.sdk.response.crm.PointsJosSendPointsResponse
;
import
com.jd.open.api.sdk.response.crm.PopCrmCustomerGetCustomerResponse
;
import
com.jd.open.api.sdk.response.crm.PopCrmCustomerGetCustomerResponse
;
import
com.jd.open.api.sdk.response.gongzhonghao.JzoneAddCartItemByPinResponse
;
import
com.jd.open.api.sdk.response.gongzhonghao.JzoneAddCartItemByPinResponse
;
import
com.jd.open.api.sdk.response.market.GetPurchaseInfoResponse
;
import
com.jd.open.api.sdk.response.market.GetPurchaseInfoResponse
;
...
@@ -303,6 +305,46 @@ public class JdApiUtil {
...
@@ -303,6 +305,46 @@ public class JdApiUtil {
}
}
private
static
Result
<
Boolean
>
sendPoints
(
JdAppEnum
jdAppEnum
,
String
pin
,
String
businessId
,
short
sourceType
,
Integer
points
,
String
desc
,
String
accessToken
)
{
try
{
JdClient
client
=
getJdClient
(
jdAppEnum
,
accessToken
);
PointsJosSendPointsRequest
request
=
new
PointsJosSendPointsRequest
();
request
.
setPin
(
pin
);
request
.
setBusinessId
(
businessId
);
/*
发放积分:
27 - 发放积分,
29 - 店铺签到发放,
30 - 关注店铺发放,
31 - 互动积分发放,
32 - 其他渠道发放
扣减积分:
26 - 消费积分,
33 - 兑换优惠券消耗,
34 - 兑换红包消耗,
35 - 兑换京豆消耗,
36 - 兑换其他权益消耗,
37 - 互动消耗积分
*/
request
.
setSourceType
(
sourceType
);
request
.
setPoints
(
points
);
request
.
setSourceComment
(
desc
.
substring
(
0
,
10
));
PointsJosSendPointsResponse
response
=
client
.
execute
(
request
);
LOGGER
.
info
(
"积分发放接口,request={},response={}"
,
JSON
.
toJSONString
(
request
),
JSON
.
toJSONString
(
response
));
return
Optional
.
ofNullable
(
response
)
.
map
(
PointsJosSendPointsResponse:
:
getJsfResult
)
.
map
(
resultData
->
ResultBuilder
.
success
(
Objects
.
equals
(
"200"
,
resultData
.
getCode
())))
.
orElse
(
ResultBuilder
.
fail
(
JSON
.
toJSONString
(
response
)));
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"积分发放接口,exception"
,
e
);
return
ResultBuilder
.
fail
(
"发生异常"
);
}
}
/**
/**
* 通过用户pin加入购物车
* 通过用户pin加入购物车
*/
*/
...
@@ -321,11 +363,37 @@ public class JdApiUtil {
...
@@ -321,11 +363,37 @@ public class JdApiUtil {
.
map
(
resultData
->
ResultBuilder
.
success
(
Objects
.
equals
(
"0"
,
resultData
.
getCode
())))
.
map
(
resultData
->
ResultBuilder
.
success
(
Objects
.
equals
(
"0"
,
resultData
.
getCode
())))
.
orElse
(
ResultBuilder
.
fail
(
JSON
.
toJSONString
(
response
)));
.
orElse
(
ResultBuilder
.
fail
(
JSON
.
toJSONString
(
response
)));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"
followByPinAndVid
,exception"
,
e
);
LOGGER
.
warn
(
"
通过用户pin加入购物车
,exception"
,
e
);
return
ResultBuilder
.
fail
(
"发生异常"
);
return
ResultBuilder
.
fail
(
"发生异常"
);
}
}
}
}
/**
* 互动积分发放积分
*
* @param businessId 防重 ID,建议是 uuid
*/
public
Result
<
Boolean
>
sendPoints
(
JdAppEnum
jdAppEnum
,
String
pin
,
String
businessId
,
Integer
points
,
String
desc
,
String
accessToken
)
{
if
(
points
<=
0
)
{
return
ResultBuilder
.
fail
(
"发放积分须是正数"
);
}
return
sendPoints
(
jdAppEnum
,
pin
,
businessId
,
(
short
)
31
,
points
,
desc
,
accessToken
);
}
/**
* 互动消耗积分
*
* @param businessId 防重 ID,建议是 uuid
*/
public
Result
<
Boolean
>
consumePoints
(
JdAppEnum
jdAppEnum
,
String
pin
,
String
businessId
,
Integer
points
,
String
desc
,
String
accessToken
)
{
if
(
points
>=
0
)
{
return
ResultBuilder
.
fail
(
"发放积分须是负数"
);
}
return
sendPoints
(
jdAppEnum
,
pin
,
businessId
,
(
short
)
37
,
points
,
desc
,
accessToken
);
}
/**
/**
* 获取当前服务当前用户的有效订购记录
* 获取当前服务当前用户的有效订购记录
*/
*/
...
...
src/main/java/cn/com/duiba/jdactivity/dto/DuibaSendPointsParam.java
0 → 100644
View file @
0c1e95c4
package
cn
.
com
.
duiba
.
jdactivity
.
dto
;
/**
* @author zsp (zengshuiping@duiba.com.cn)
* @date 2021/6/22 20:46
*/
public
class
DuibaSendPointsParam
extends
DuibaUserParam
{
private
static
final
long
serialVersionUID
=
7880723582722931126L
;
private
String
businessId
;
private
Integer
points
;
private
String
desc
;
public
String
getBusinessId
()
{
return
businessId
;
}
public
void
setBusinessId
(
String
businessId
)
{
this
.
businessId
=
businessId
;
}
public
Integer
getPoints
()
{
return
points
;
}
public
void
setPoints
(
Integer
points
)
{
this
.
points
=
points
;
}
public
String
getDesc
()
{
return
desc
;
}
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
}
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