Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
order-group-application
order-group
Commits
c5ebf3d4
Commit
c5ebf3d4
authored
Oct 10, 2020
by
刘鹏飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redis操作改为RedisCache进行操作
parent
366cde99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/impl/CollageCartBaseServiceImpl.java
+30
-6
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartCollageServiceImpl.java
+0
-1
No files found.
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/impl/CollageCartBaseServiceImpl.java
View file @
c5ebf3d4
...
@@ -3,7 +3,9 @@ package com.freemud.sdk.api.assortment.shoppingcart.service.impl;
...
@@ -3,7 +3,9 @@ package com.freemud.sdk.api.assortment.shoppingcart.service.impl;
import
ch.qos.logback.classic.Level
;
import
ch.qos.logback.classic.Level
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.redis.RedisCache
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.application.sdk.api.couponcenter.online.service.FMActiveSdkService
;
import
com.freemud.application.sdk.api.couponcenter.online.service.FMActiveSdkService
;
import
com.freemud.application.sdk.api.log.ApiLog
;
import
com.freemud.application.sdk.api.log.ErrorLog
;
import
com.freemud.application.sdk.api.log.ErrorLog
;
import
com.freemud.sdk.api.assortment.shoppingcart.adapter.CollageOrderSdkAdapter
;
import
com.freemud.sdk.api.assortment.shoppingcart.adapter.CollageOrderSdkAdapter
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CartResponseConstant
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CartResponseConstant
;
...
@@ -53,8 +55,8 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -53,8 +55,8 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
@Autowired
@Autowired
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
@Autowired
/*
@Autowired
private
RedisTemplate
redisTemplate
;
private RedisTemplate redisTemplate;
*/
@Override
@Override
public
BaseResponse
<
List
<
CartAddItem
>>
detailCart
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
public
BaseResponse
<
List
<
CartAddItem
>>
detailCart
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
...
@@ -68,7 +70,7 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -68,7 +70,7 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
doCheck
(
cartParamDto
);
doCheck
(
cartParamDto
);
// 构建缓存key
// 构建缓存key
String
collageCartHashKey
=
genCollageCarHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
());
String
collageCartHashKey
=
genCollageCarHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
());
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redis
Template
.
boundHashOps
(
collageCartHashKey
);
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redis
Cache
.
getRedisTemplate
()
.
boundHashOps
(
collageCartHashKey
);
List
<
CartGoods
>
cartGoodsList
=
operations
.
values
();
List
<
CartGoods
>
cartGoodsList
=
operations
.
values
();
return
CartResponseUtil
.
success
(
cartGoodsList
);
return
CartResponseUtil
.
success
(
cartGoodsList
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -99,13 +101,24 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -99,13 +101,24 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
@Override
@Override
public
BaseResponse
<
List
<
CartGoods
>>
setCartGoodsList
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
public
BaseResponse
<
List
<
CartGoods
>>
setCartGoodsList
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
try
{
RedisTemplate
redisTemplate
=
redisCache
.
getRedisTemplate
();
String
redisKey
=
genCollageCarHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
());
String
redisKey
=
genCollageCarHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
());
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
// 获取拼单购物车的有效期
// 获取拼单购物车的有效期
// 如果购物车已经存在则获取剩余的时间,如果不存在,则设置有效期为1小时(拼单的有效期为1小时)
// 如果购物车已经存在则获取剩余的时间,如果不存在,则判断拼单是否失效
Long
expire
=
3600L
;
// 获取拼单的剩余时间作为有效期
Long
expire
=
0L
;
if
(
redisTemplate
.
hasKey
(
redisKey
)){
if
(
redisTemplate
.
hasKey
(
redisKey
)){
expire
=
operations
.
getExpire
();
expire
=
operations
.
getExpire
();
}
else
{
// 如果不存在则使用拼单基础信息的剩余时间作为有效期
// 如果拼单基础信息也过期了,直接返回不做操作
expire
=
redisTemplate
.
boundHashOps
(
genCollageBaseHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
())).
getExpire
();
if
(
expire
<
-
1
){
ApiLog
.
info
(
"设置拼单购物车,拼单已经失效,param:"
+
JSONObject
.
toJSONString
(
cartParamDto
));
return
null
;
}
}
}
this
.
clear
(
cartParamDto
,
trackingNo
);
this
.
clear
(
cartParamDto
,
trackingNo
);
...
@@ -148,6 +161,9 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -148,6 +161,9 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
@Override
@Override
public
BaseResponse
<
CartGoods
>
getCartGoods
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
public
BaseResponse
<
CartGoods
>
getCartGoods
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
try
{
RedisTemplate
redisTemplate
=
redisCache
.
getRedisTemplate
();
String
redisKey
=
genCollageCarHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
());
String
redisKey
=
genCollageCarHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
());
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
CartGoods
cartGoods
=
operations
.
get
(
cartParamDto
.
getCartGoodsUid
());
CartGoods
cartGoods
=
operations
.
get
(
cartParamDto
.
getCartGoodsUid
());
...
@@ -161,6 +177,9 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -161,6 +177,9 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
@Override
@Override
public
BaseResponse
<
List
<
CartGoods
>>
updateGoodsQty
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
public
BaseResponse
<
List
<
CartGoods
>>
updateGoodsQty
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
try
{
RedisTemplate
redisTemplate
=
redisCache
.
getRedisTemplate
();
String
redisKey
=
genCollageCarHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
());
String
redisKey
=
genCollageCarHashKey
(
cartParamDto
.
getPartnerId
(),
cartParamDto
.
getStoreId
(),
cartParamDto
.
getUserId
());
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
CartGoods
cartGoods
=
operations
.
get
(
cartParamDto
.
getCartGoodsUid
());
CartGoods
cartGoods
=
operations
.
get
(
cartParamDto
.
getCartGoodsUid
());
...
@@ -374,6 +393,9 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -374,6 +393,9 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
*/
*/
public
List
<
String
>
getCollageCartGoodsUids
(
String
partnerId
,
String
storeId
,
String
crateUserId
,
String
userId
){
public
List
<
String
>
getCollageCartGoodsUids
(
String
partnerId
,
String
storeId
,
String
crateUserId
,
String
userId
){
try
{
try
{
RedisTemplate
redisTemplate
=
redisCache
.
getRedisTemplate
();
String
collageMemberKey
=
genCollageMemberHashKey
(
partnerId
,
storeId
,
crateUserId
);
String
collageMemberKey
=
genCollageMemberHashKey
(
partnerId
,
storeId
,
crateUserId
);
BoundHashOperations
<
String
,
String
,
List
<
String
>>
operations
=
redisTemplate
.
boundHashOps
(
collageMemberKey
);
BoundHashOperations
<
String
,
String
,
List
<
String
>>
operations
=
redisTemplate
.
boundHashOps
(
collageMemberKey
);
List
<
String
>
goodsUids
=
operations
.
get
(
userId
);
List
<
String
>
goodsUids
=
operations
.
get
(
userId
);
...
@@ -415,6 +437,8 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -415,6 +437,8 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
public
List
<
CartGoods
>
removeGoodsUids
(
String
partnerId
,
String
storeId
,
String
userId
,
List
<
String
>
goodsUids
)
{
public
List
<
CartGoods
>
removeGoodsUids
(
String
partnerId
,
String
storeId
,
String
userId
,
List
<
String
>
goodsUids
)
{
RedisTemplate
redisTemplate
=
redisCache
.
getRedisTemplate
();
String
redisKey
=
genCollageCarHashKey
(
partnerId
,
storeId
,
userId
);
String
redisKey
=
genCollageCarHashKey
(
partnerId
,
storeId
,
userId
);
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
if
(
null
!=
goodsUids
&&
!
goodsUids
.
isEmpty
()){
if
(
null
!=
goodsUids
&&
!
goodsUids
.
isEmpty
()){
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartCollageServiceImpl.java
View file @
c5ebf3d4
...
@@ -119,7 +119,6 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
...
@@ -119,7 +119,6 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
UserLoginInfoDto
userLoginInfoDto
=
convert2UserLoginInfoDto
(
currentUserInfoVo
);
UserLoginInfoDto
userLoginInfoDto
=
convert2UserLoginInfoDto
(
currentUserInfoVo
);
String
currentUserId
=
currentUserInfoVo
.
getMemberId
();
String
currentUserId
=
currentUserInfoVo
.
getMemberId
();
//String currentSessionId = addShoppingCartGoodsRequestVo.getSessionId();
String
partnerId
=
addShoppingCartGoodsRequestVo
.
getPartnerId
();
String
partnerId
=
addShoppingCartGoodsRequestVo
.
getPartnerId
();
String
storeId
=
addShoppingCartGoodsRequestVo
.
getShopId
();
String
storeId
=
addShoppingCartGoodsRequestVo
.
getShopId
();
String
appId
=
addShoppingCartGoodsRequestVo
.
getAppId
();
String
appId
=
addShoppingCartGoodsRequestVo
.
getAppId
();
...
...
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