Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
pseer
gxpt_ht
Commits
e78bcefa
Commit
e78bcefa
authored
Nov 13, 2023
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改Reds存储的数据格式
parent
e2bb6b23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
16 deletions
+22
-16
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+7
-4
QPServiceImpl.java
...rc/main/java/share/system/service/impl/QPServiceImpl.java
+15
-12
No files found.
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
e78bcefa
...
@@ -18,7 +18,8 @@ public class RedisTask {
...
@@ -18,7 +18,8 @@ public class RedisTask {
private
ISConsumerCouponService
isConsumerCouponService
;
private
ISConsumerCouponService
isConsumerCouponService
;
@Autowired
@Autowired
private
QPService
qpService
;
private
QPService
qpService
;
RedisTemplate
redisTemplate
=
new
RedisTemplate
();
@Autowired
private
RedisTemplate
redisTemplate
;
public
void
AuToReceiptCode
()
{
public
void
AuToReceiptCode
()
{
//获取redis中所有以tuangou.receipt.prepare开头的key
//获取redis中所有以tuangou.receipt.prepare开头的key
...
@@ -45,11 +46,13 @@ public class RedisTask {
...
@@ -45,11 +46,13 @@ public class RedisTask {
public
void
AutomaticMtSessionKey
()
{
public
void
AutomaticMtSessionKey
()
{
Boolean
b
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
());
Boolean
b
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
());
if
(!
b
)
{
if
(!
b
)
{
JSONObject
o
=
(
JSONObject
)
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
(
));
JSONObject
o
=
new
JSONObject
(
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
()
));
String
refreshToken
=
(
String
)
o
.
get
(
"refresh_token"
);
String
refreshToken
=
(
String
)
o
.
get
(
"refresh_token"
);
CustomerRefreshTokenResponse
customerRefreshTokenResponse
=
qpService
.
refreshToken
(
refreshToken
);
CustomerRefreshTokenResponse
customerRefreshTokenResponse
=
qpService
.
refreshToken
(
refreshToken
);
redisTemplate
.
opsForValue
().
set
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
(),
new
JSONObject
(
customerRefreshTokenResponse
));
JSONObject
jsonObject
=
new
JSONObject
(
customerRefreshTokenResponse
);
redisTemplate
.
opsForValue
().
set
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(),
new
JSONObject
(
customerRefreshTokenResponse
),
customerRefreshTokenResponse
.
getExpires_in
()
-
60
*
30
);
redisTemplate
.
opsForValue
().
set
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
(),
jsonObject
.
toString
());
redisTemplate
.
opsForValue
().
set
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(),
jsonObject
.
toString
());
redisTemplate
.
expire
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(),
customerRefreshTokenResponse
.
getExpires_in
()
-
60
*
30
,
java
.
util
.
concurrent
.
TimeUnit
.
SECONDS
);
}
}
}
}
}
}
share-system/src/main/java/share/system/service/impl/QPServiceImpl.java
View file @
e78bcefa
...
@@ -23,6 +23,7 @@ import org.springframework.beans.BeanUtils;
...
@@ -23,6 +23,7 @@ import org.springframework.beans.BeanUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
share.common.enums.*
;
import
share.common.enums.*
;
import
share.common.utils.DateUtils
;
import
share.common.utils.DateUtils
;
...
@@ -52,9 +53,8 @@ public class QPServiceImpl implements QPService {
...
@@ -52,9 +53,8 @@ public class QPServiceImpl implements QPService {
@Autowired
@Autowired
private
ISConsumerCouponService
isConsumerCouponService
;
private
ISConsumerCouponService
isConsumerCouponService
;
@Autowired
private
RedisTemplate
redisTemplate
;
RedisTemplate
redisTemplate
=
new
RedisTemplate
();
/**
/**
* 用户验卷接口
* 用户验卷接口
*/
*/
...
@@ -172,7 +172,7 @@ public class QPServiceImpl implements QPService {
...
@@ -172,7 +172,7 @@ public class QPServiceImpl implements QPService {
*/
*/
@Override
@Override
public
TuangouReceiptPrepareResponseEntity
prepare
(
String
code
,
String
openShopUuid
)
{
public
TuangouReceiptPrepareResponseEntity
prepare
(
String
code
,
String
openShopUuid
)
{
JSONObject
sessionKey
=
(
JSONObject
)
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(
));
JSONObject
sessionKey
=
new
JSONObject
(
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
()
));
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
TuangouReceiptPrepareRequest
request
=
new
TuangouReceiptPrepareRequest
(
APP_KEY
,
APP_SECRET
,
session
,
code
,
""
,
openShopUuid
);
TuangouReceiptPrepareRequest
request
=
new
TuangouReceiptPrepareRequest
(
APP_KEY
,
APP_SECRET
,
session
,
code
,
""
,
openShopUuid
);
TuangouReceiptPrepare
tuangouReceiptPrepare
=
new
TuangouReceiptPrepare
(
request
);
TuangouReceiptPrepare
tuangouReceiptPrepare
=
new
TuangouReceiptPrepare
(
request
);
...
@@ -190,7 +190,7 @@ public class QPServiceImpl implements QPService {
...
@@ -190,7 +190,7 @@ public class QPServiceImpl implements QPService {
*/
*/
@Override
@Override
public
List
<
TuangouReceiptConsumeResponseEntity
>
consume
(
String
code
,
int
count
,
String
openShopUuid
)
{
public
List
<
TuangouReceiptConsumeResponseEntity
>
consume
(
String
code
,
int
count
,
String
openShopUuid
)
{
JSONObject
sessionKey
=
(
JSONObject
)
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(
));
JSONObject
sessionKey
=
new
JSONObject
(
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
()
));
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
String
requestid
=
UUID
.
randomUUID
().
toString
();
String
requestid
=
UUID
.
randomUUID
().
toString
();
...
@@ -212,7 +212,7 @@ public class QPServiceImpl implements QPService {
...
@@ -212,7 +212,7 @@ public class QPServiceImpl implements QPService {
*/
*/
@Override
@Override
public
List
<
TuangouReceiptReverseConsumeResponseEntity
>
reverseconsume
(
String
code
,
Long
appDealId
,
String
openShopUuid
)
{
public
List
<
TuangouReceiptReverseConsumeResponseEntity
>
reverseconsume
(
String
code
,
Long
appDealId
,
String
openShopUuid
)
{
JSONObject
sessionKey
=
(
JSONObject
)
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(
));
JSONObject
sessionKey
=
new
JSONObject
(
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
()
));
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
TuangouReceiptReverseConsumeRequest
tuangouReceiptReverseConsumeRequest
=
new
TuangouReceiptReverseConsumeRequest
(
APP_KEY
,
APP_SECRET
,
session
,
TuangouReceiptReverseConsumeRequest
tuangouReceiptReverseConsumeRequest
=
new
TuangouReceiptReverseConsumeRequest
(
APP_KEY
,
APP_SECRET
,
session
,
...
@@ -233,7 +233,7 @@ public class QPServiceImpl implements QPService {
...
@@ -233,7 +233,7 @@ public class QPServiceImpl implements QPService {
*/
*/
@Override
@Override
public
TuangouReceiptGetConsumedReponseEntity
getconsumed
(
String
code
,
String
openShopUuid
)
{
public
TuangouReceiptGetConsumedReponseEntity
getconsumed
(
String
code
,
String
openShopUuid
)
{
JSONObject
sessionKey
=
(
JSONObject
)
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(
));
JSONObject
sessionKey
=
new
JSONObject
(
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
()
));
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
TuangouReceiptGetConsumedRequest
request
=
new
TuangouReceiptGetConsumedRequest
(
APP_KEY
,
APP_SECRET
,
TuangouReceiptGetConsumedRequest
request
=
new
TuangouReceiptGetConsumedRequest
(
APP_KEY
,
APP_SECRET
,
...
@@ -253,8 +253,11 @@ public class QPServiceImpl implements QPService {
...
@@ -253,8 +253,11 @@ public class QPServiceImpl implements QPService {
APP_SECRET
,
GrantType
.
AUTHORIZATION_CODE
.
getValue
(),
authCode
);
APP_SECRET
,
GrantType
.
AUTHORIZATION_CODE
.
getValue
(),
authCode
);
DynamicToken
dynamicToken
=
new
DynamicToken
(
request
);
DynamicToken
dynamicToken
=
new
DynamicToken
(
request
);
DynamicTokenResponse
response
=
openAPIClient
.
invoke
(
dynamicToken
);
DynamicTokenResponse
response
=
openAPIClient
.
invoke
(
dynamicToken
);
redisTemplate
.
opsForValue
().
set
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
(),
new
JSONObject
(
response
));
//response转JSON
redisTemplate
.
opsForValue
().
set
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(),
new
JSONObject
(
response
),
response
.
getExpires_in
()
-
60
*
30
);
JSONObject
jsonObject
=
new
JSONObject
(
response
);
redisTemplate
.
opsForValue
().
set
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
(),
jsonObject
.
toString
());
redisTemplate
.
opsForValue
().
set
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(),
jsonObject
.
toString
());
redisTemplate
.
expire
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(),
response
.
getExpires_in
()
-
60
*
30
,
java
.
util
.
concurrent
.
TimeUnit
.
SECONDS
);
return
response
.
getAccess_token
();
return
response
.
getAccess_token
();
}
}
...
@@ -267,7 +270,7 @@ public class QPServiceImpl implements QPService {
...
@@ -267,7 +270,7 @@ public class QPServiceImpl implements QPService {
* @param app_shop_id
* @param app_shop_id
*/
*/
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
JSONObject
sessionKey
=
(
JSONObject
)
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(
));
JSONObject
sessionKey
=
new
JSONObject
(
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
()
));
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
TuangouDealQueryShopDealRequest
request
=
new
TuangouDealQueryShopDealRequest
(
APP_KEY
,
APP_SECRET
,
session
,
""
,
1
,
100
,
openShopUuid
);
TuangouDealQueryShopDealRequest
request
=
new
TuangouDealQueryShopDealRequest
(
APP_KEY
,
APP_SECRET
,
session
,
""
,
1
,
100
,
openShopUuid
);
TuangouDealQueryShopDeal
tuangouDealQueryShopDeal
=
new
TuangouDealQueryShopDeal
(
request
);
TuangouDealQueryShopDeal
tuangouDealQueryShopDeal
=
new
TuangouDealQueryShopDeal
(
request
);
...
@@ -288,7 +291,7 @@ public class QPServiceImpl implements QPService {
...
@@ -288,7 +291,7 @@ public class QPServiceImpl implements QPService {
@Override
@Override
public
SessionVo
queryKey
()
{
public
SessionVo
queryKey
()
{
JSONObject
o
=
(
JSONObject
)
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
(
));
JSONObject
o
=
new
JSONObject
(
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_OBJECT_KEY
.
getValue
()
));
Long
expiresIn
=
(
Long
)
o
.
get
(
"expires_in"
);
Long
expiresIn
=
(
Long
)
o
.
get
(
"expires_in"
);
Integer
remainRefreshCount
=
(
Integer
)
o
.
get
(
"remain_refresh_count"
);
Integer
remainRefreshCount
=
(
Integer
)
o
.
get
(
"remain_refresh_count"
);
SessionVo
sessionVo
=
new
SessionVo
();
SessionVo
sessionVo
=
new
SessionVo
();
...
@@ -306,7 +309,7 @@ public class QPServiceImpl implements QPService {
...
@@ -306,7 +309,7 @@ public class QPServiceImpl implements QPService {
@Override
@Override
public
List
<
CustomerKeyShopScopeResponseEntity
>
scope
()
{
public
List
<
CustomerKeyShopScopeResponseEntity
>
scope
()
{
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
DefaultOpenAPIClient
openAPIClient
=
new
DefaultOpenAPIClient
();
JSONObject
sessionKey
=
(
JSONObject
)
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
(
));
JSONObject
sessionKey
=
new
JSONObject
(
redisTemplate
.
opsForValue
().
get
(
ReceiptRdeisEnum
.
MT_SESSION_KEY
.
getValue
()
));
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
String
session
=
(
String
)
sessionKey
.
get
(
"access_token"
);
String
bid
=
(
String
)
sessionKey
.
get
(
"bid"
);
String
bid
=
(
String
)
sessionKey
.
get
(
"bid"
);
// CustomerKeyShopScopeRequest request = new CustomerKeyShopScopeRequest(APP_KEY, APP_SECRET, "13ff8a38219075fafbbdeea6839450ed6bea1b9b","f1fd23c1c413862137b895bdcfc10ef8");
// CustomerKeyShopScopeRequest request = new CustomerKeyShopScopeRequest(APP_KEY, APP_SECRET, "13ff8a38219075fafbbdeea6839450ed6bea1b9b","f1fd23c1c413862137b895bdcfc10ef8");
...
...
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