Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yanxuan-wx-store-sharer
Overview
Overview
Details
Activity
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
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
wx
yanxuan-wx-store-sharer
Commits
f6eae4e2
Commit
f6eae4e2
authored
May 14, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新加入实名认证相关代码
parent
39032de4
Pipeline
#75478
passed with stages
in 1 minute 8 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
55 deletions
+63
-55
ProductServiceImpl.java
.../wx/store/sharer/biz/service/impl/ProductServiceImpl.java
+3
-3
CoreConstant.java
...yanxuan/wx/store/sharer/common/constant/CoreConstant.java
+0
-45
WeChatConstant.java
.../wx/store/sharer/integration/constant/WeChatConstant.java
+53
-0
WeChatContextHolder.java
...wx/store/sharer/integration/core/WeChatContextHolder.java
+5
-5
WeChatRestTemplateHandler.java
...sharer/integration/handler/WeChatRestTemplateHandler.java
+2
-2
No files found.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/service/impl/ProductServiceImpl.java
View file @
f6eae4e2
...
...
@@ -9,11 +9,11 @@ import com.netease.yanxuan.wx.store.sharer.biz.meta.model.vo.ProductPromotionLin
import
com.netease.yanxuan.wx.store.sharer.biz.meta.page.PageQuery
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.page.PageVO
;
import
com.netease.yanxuan.wx.store.sharer.biz.service.IProductService
;
import
com.netease.yanxuan.wx.store.sharer.common.constant.CoreConstant
;
import
com.netease.yanxuan.wx.store.sharer.common.exception.NoBindSharerException
;
import
com.netease.yanxuan.wx.store.sharer.common.handler.RedisClient
;
import
com.netease.yanxuan.wx.store.sharer.common.util.AsyncUtils
;
import
com.netease.yanxuan.wx.store.sharer.integration.constant.WeChatApi
;
import
com.netease.yanxuan.wx.store.sharer.integration.constant.WeChatConstant
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.*
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.*
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -160,12 +160,12 @@ public class ProductServiceImpl implements IProductService {
*/
private
WeChatPromoteProductDetailVO
getProductDetailCache
(
String
shopAppid
,
String
productId
)
{
WeChatPromoteProductDetailVO
detailVO
;
String
productDetailKey
=
Core
Constant
.
REDIS_PRODUCT_DETAIL_KEY
+
shopAppid
+
":"
+
productId
;
String
productDetailKey
=
WeChat
Constant
.
REDIS_PRODUCT_DETAIL_KEY
+
shopAppid
+
":"
+
productId
;
String
productDetailJson
=
redisClient
.
getStr
(
productDetailKey
);
if
(
StringUtils
.
isBlank
(
productDetailJson
))
{
detailVO
=
weChatShopPromoteProductDetailRequest
.
handle
(
shopAppid
,
Long
.
valueOf
(
productId
));
if
(
null
!=
detailVO
)
{
redisClient
.
setStr
(
productDetailKey
,
JSON
.
toJSONString
(
detailVO
),
Core
Constant
.
REDIS_PRODUCT_DETAIL_EXPIRE_SECONDS
);
redisClient
.
setStr
(
productDetailKey
,
JSON
.
toJSONString
(
detailVO
),
WeChat
Constant
.
REDIS_PRODUCT_DETAIL_EXPIRE_SECONDS
);
}
}
else
{
detailVO
=
JSON
.
parseObject
(
productDetailJson
,
WeChatPromoteProductDetailVO
.
class
);
...
...
yanxuan-wx-store-sharer-common/src/main/java/com/netease/yanxuan/wx/store/sharer/common/constant/CoreConstant.java
View file @
f6eae4e2
...
...
@@ -19,49 +19,4 @@ public interface CoreConstant {
* Redis认证Token失效时间,秒
*/
int
REDIS_TOKEN_EXPIRE_SECONDS
=
30
*
24
*
60
*
60
;
/**
* Redis微信认证Token
*/
String
REDIS_TOKEN_WECHAT_KEY
=
"TOKEN:WECHAT"
;
/**
* Redis微信认证Token锁
*/
String
REDIS_TOKEN_WECHAT_LOCK_KEY
=
"TOKEN:WECHAT:LOCK"
;
/**
* Redis微信认证Token锁时间,秒
*/
String
REDIS_TOKEN_WECHAT_LOCK_VALUE
=
"wechat:lock"
;
/**
* Redis微信认证Token锁时间,秒
*/
int
REDIS_TOKEN_WECHAT_LOCK_TIME
=
5
;
/**
* Redis微信小店认证Token
*/
String
REDIS_TOKEN_WECHAT_SHOP_KEY
=
"TOKEN:WECHAT:SHOP"
;
/**
* Redis微信小店认证Token锁
*/
String
REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY
=
"TOKEN:WECHAT:SHOP:LOCK"
;
/**
* Redis微信小店认证Token锁时间,秒
*/
String
REDIS_TOKEN_WECHAT_SHOP_LOCK_VALUE
=
"wechat:shop:lock"
;
/**
* Redis微信小店认证Token锁时间,秒
*/
int
REDIS_TOKEN_WECHAT_SHOP_LOCK_TIME
=
5
;
/**
* Redis商品详情缓存KEY
*/
String
REDIS_PRODUCT_DETAIL_KEY
=
"PRODUCT:DETAIL:"
;
/**
* Redis商品详情过期时间,秒
*/
int
REDIS_PRODUCT_DETAIL_EXPIRE_SECONDS
=
6
*
60
*
60
;
}
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/constant/WeChatConstant.java
0 → 100644
View file @
f6eae4e2
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
integration
.
constant
;
/**
* @Description 微信常量信息
* @Author fanjiaxin
* @Date 2025/3/9 13:15
*/
public
interface
WeChatConstant
{
/**
* Redis微信认证Token
*/
String
REDIS_TOKEN_WECHAT_KEY
=
"TOKEN:WECHAT"
;
/**
* Redis微信认证Token锁
*/
String
REDIS_TOKEN_WECHAT_LOCK_KEY
=
"TOKEN:WECHAT:LOCK"
;
/**
* Redis微信认证Token锁时间,秒
*/
String
REDIS_TOKEN_WECHAT_LOCK_VALUE
=
"wechat:lock"
;
/**
* Redis微信认证Token锁时间,秒
*/
int
REDIS_TOKEN_WECHAT_LOCK_TIME
=
5
;
/**
* Redis微信小店认证Token
*/
String
REDIS_TOKEN_WECHAT_SHOP_KEY
=
"TOKEN:WECHAT:SHOP"
;
/**
* Redis微信小店认证Token锁
*/
String
REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY
=
"TOKEN:WECHAT:SHOP:LOCK"
;
/**
* Redis微信小店认证Token锁时间,秒
*/
String
REDIS_TOKEN_WECHAT_SHOP_LOCK_VALUE
=
"wechat:shop:lock"
;
/**
* Redis微信小店认证Token锁时间,秒
*/
int
REDIS_TOKEN_WECHAT_SHOP_LOCK_TIME
=
5
;
/**
* Redis商品详情缓存KEY
*/
String
REDIS_PRODUCT_DETAIL_KEY
=
"PRODUCT:DETAIL:"
;
/**
* Redis商品详情过期时间,秒
*/
int
REDIS_PRODUCT_DETAIL_EXPIRE_SECONDS
=
6
*
60
*
60
;
}
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/core/WeChatContextHolder.java
View file @
f6eae4e2
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
integration
.
core
;
import
com.netease.yanxuan.wx.store.sharer.common.constant.CoreConstant
;
import
com.netease.yanxuan.wx.store.sharer.common.exception.WeChatException
;
import
com.netease.yanxuan.wx.store.sharer.common.handler.RedisClient
;
import
com.netease.yanxuan.wx.store.sharer.integration.constant.WeChatConstant
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatShopAccessTokenRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatAccessTokenVO
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -33,7 +33,7 @@ public class WeChatContextHolder {
*/
public
String
getShopAccessToken
()
{
// 检查锁定
String
accessToken
=
redisClient
.
getStr
(
Core
Constant
.
REDIS_TOKEN_WECHAT_SHOP_KEY
);
String
accessToken
=
redisClient
.
getStr
(
WeChat
Constant
.
REDIS_TOKEN_WECHAT_SHOP_KEY
);
if
(
StringUtils
.
isNotBlank
(
accessToken
))
{
return
accessToken
;
}
...
...
@@ -46,15 +46,15 @@ public class WeChatContextHolder {
public
String
createShopAccessToken
()
{
try
{
// 设置10秒的锁
boolean
locked
=
redisClient
.
setIfAbsent
(
Core
Constant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY
,
CoreConstant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_VALUE
,
Core
Constant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_TIME
);
boolean
locked
=
redisClient
.
setIfAbsent
(
WeChat
Constant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY
,
WeChatConstant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_VALUE
,
WeChat
Constant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_TIME
);
if
(!
locked
)
{
// 未获取到锁,等待一段时间后重试
TimeUnit
.
MILLISECONDS
.
sleep
(
RETRY_DELAY_MS
);
return
getShopAccessToken
();
}
WeChatAccessTokenVO
handle
=
weChatShopAccessTokenRequest
.
handle
();
redisClient
.
setStr
(
Core
Constant
.
REDIS_TOKEN_WECHAT_SHOP_KEY
,
handle
.
getAccess_token
(),
redisClient
.
setStr
(
WeChat
Constant
.
REDIS_TOKEN_WECHAT_SHOP_KEY
,
handle
.
getAccess_token
(),
handle
.
getExpires_in
()
-
EXPIRE_SECONDS
);
return
handle
.
getAccess_token
();
}
catch
(
InterruptedException
e
)
{
...
...
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/handler/WeChatRestTemplateHandler.java
View file @
f6eae4e2
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
integration
.
handler
;
import
com.alibaba.fastjson.JSON
;
import
com.netease.yanxuan.wx.store.sharer.common.constant.CoreConstant
;
import
com.netease.yanxuan.wx.store.sharer.common.exception.WeChatException
;
import
com.netease.yanxuan.wx.store.sharer.common.handler.RedisClient
;
import
com.netease.yanxuan.wx.store.sharer.common.handler.RestTemplateClient
;
import
com.netease.yanxuan.wx.store.sharer.integration.constant.WeChatApi
;
import
com.netease.yanxuan.wx.store.sharer.integration.constant.WeChatConstant
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.enums.WeChatErrorCodeEnum
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatCoreVO
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -39,7 +39,7 @@ public class WeChatRestTemplateHandler {
&&
!
WeChatApi
.
WECHAT_REQUEST_SUCCESS_CODE
.
equals
(
result
.
getErrcode
()))
{
if
(
WeChatErrorCodeEnum
.
INVALID_CREDENTIAL
.
getCode
().
equals
(
result
.
getErrcode
())){
// token过期,清除微信小店认证信息
redisClient
.
delete
(
Core
Constant
.
REDIS_TOKEN_WECHAT_SHOP_KEY
);
redisClient
.
delete
(
WeChat
Constant
.
REDIS_TOKEN_WECHAT_SHOP_KEY
);
}
throw
new
WeChatException
(
String
.
join
(
","
,
"调用微信接口失败"
+
result
.
getErrmsg
()));
}
...
...
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