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
83876013
Commit
83876013
authored
Mar 14, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
联调问题处理
parent
b126101a
Pipeline
#71590
passed with stages
in 1 minute 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
CoreConstant.java
...yanxuan/wx/store/sharer/common/constant/CoreConstant.java
+16
-0
WeChatContextHolder.java
...wx/store/sharer/integration/core/WeChatContextHolder.java
+5
-3
No files found.
yanxuan-wx-store-sharer-common/src/main/java/com/netease/yanxuan/wx/store/sharer/common/constant/CoreConstant.java
View file @
83876013
...
@@ -29,6 +29,14 @@ public interface CoreConstant {
...
@@ -29,6 +29,14 @@ public interface CoreConstant {
* Redis微信认证Token锁
* Redis微信认证Token锁
*/
*/
String
REDIS_TOKEN_WECHAT_LOCK_KEY
=
"TOKEN:WECHAT:LOCK"
;
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
=
10
;
/**
/**
* Redis微信小店认证Token
* Redis微信小店认证Token
...
@@ -38,4 +46,12 @@ public interface CoreConstant {
...
@@ -38,4 +46,12 @@ public interface CoreConstant {
* Redis微信小店认证Token锁
* Redis微信小店认证Token锁
*/
*/
String
REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY
=
"TOKEN:WECHAT:SHOP:LOCK"
;
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
=
10
;
}
}
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/core/WeChatContextHolder.java
View file @
83876013
...
@@ -25,7 +25,7 @@ public class WeChatContextHolder {
...
@@ -25,7 +25,7 @@ public class WeChatContextHolder {
private
final
WeChatShopAccessTokenRequest
weChatShopAccessTokenRequest
;
private
final
WeChatShopAccessTokenRequest
weChatShopAccessTokenRequest
;
private
static
final
long
RETRY_DELAY_MS
=
200
;
private
static
final
long
RETRY_DELAY_MS
=
200
;
private
static
final
int
EXPIRE_SECONDS
=
5
*
60
;
private
static
final
int
EXPIRE_SECONDS
=
30
*
60
;
/**
/**
* 获取微信认证信息
* 获取微信认证信息
...
@@ -48,7 +48,8 @@ public class WeChatContextHolder {
...
@@ -48,7 +48,8 @@ public class WeChatContextHolder {
*/
*/
public
String
createAccessToken
()
throws
InterruptedException
{
public
String
createAccessToken
()
throws
InterruptedException
{
// 设置10秒的锁
// 设置10秒的锁
boolean
locked
=
redisClient
.
setIfAbsent
(
CoreConstant
.
REDIS_TOKEN_WECHAT_LOCK_KEY
,
"locked"
,
10
);
boolean
locked
=
redisClient
.
setIfAbsent
(
CoreConstant
.
REDIS_TOKEN_WECHAT_LOCK_KEY
,
CoreConstant
.
REDIS_TOKEN_WECHAT_LOCK_VALUE
,
CoreConstant
.
REDIS_TOKEN_WECHAT_LOCK_TIME
);
if
(!
locked
)
{
if
(!
locked
)
{
// 未获取到锁,等待一段时间后重试
// 未获取到锁,等待一段时间后重试
TimeUnit
.
MILLISECONDS
.
sleep
(
RETRY_DELAY_MS
);
TimeUnit
.
MILLISECONDS
.
sleep
(
RETRY_DELAY_MS
);
...
@@ -81,7 +82,8 @@ public class WeChatContextHolder {
...
@@ -81,7 +82,8 @@ public class WeChatContextHolder {
*/
*/
public
String
createShopAccessToken
()
throws
InterruptedException
{
public
String
createShopAccessToken
()
throws
InterruptedException
{
// 设置10秒的锁
// 设置10秒的锁
boolean
locked
=
redisClient
.
setIfAbsent
(
CoreConstant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY
,
"locked"
,
10
);
boolean
locked
=
redisClient
.
setIfAbsent
(
CoreConstant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_KEY
,
CoreConstant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_VALUE
,
CoreConstant
.
REDIS_TOKEN_WECHAT_SHOP_LOCK_TIME
);
if
(!
locked
)
{
if
(!
locked
)
{
// 未获取到锁,等待一段时间后重试
// 未获取到锁,等待一段时间后重试
TimeUnit
.
MILLISECONDS
.
sleep
(
RETRY_DELAY_MS
);
TimeUnit
.
MILLISECONDS
.
sleep
(
RETRY_DELAY_MS
);
...
...
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