记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
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
董敬伟
liquidnet-bus-v1
Commits
26ab013e
Commit
26ab013e
authored
Dec 31, 2021
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
库存相关 redis
parent
dd988aa2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
6 deletions
+49
-6
GoblinRedisConst.java
...m/liquidnet/service/goblin/constant/GoblinRedisConst.java
+1
-1
GoblinRedisUtils.java
...a/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
+48
-5
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/constant/GoblinRedisConst.java
View file @
26ab013e
...
@@ -48,6 +48,6 @@ public class GoblinRedisConst {
...
@@ -48,6 +48,6 @@ public class GoblinRedisConst {
/**
/**
* SKU剩余库存
* SKU剩余库存
*/
*/
public
static
final
String
REAL
STOCK_SKU
=
PREFIX
.
concat
(
"real
stock_sku:"
);
public
static
final
String
REAL
_STOCK_SKU
=
PREFIX
.
concat
(
"real_
stock_sku:"
);
/* ----------------------------------------------------------------- */
/* ----------------------------------------------------------------- */
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
View file @
26ab013e
...
@@ -17,6 +17,49 @@ public class GoblinRedisUtils {
...
@@ -17,6 +17,49 @@ public class GoblinRedisUtils {
@Autowired
@Autowired
GoblinMongoUtils
goblinMongoUtils
;
GoblinMongoUtils
goblinMongoUtils
;
/* ---------------------------------------- sku库存相关 ---------------------------------------- */
public
void
setSkuStock
(
String
marketPre
,
String
skuId
,
Integer
stock
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
;
if
(
marketPre
!=
null
)
{
rk
=
rk
.
concat
(
marketPre
+
":"
);
}
rk
=
rk
.
concat
(
skuId
);
redisUtil
.
set
(
rk
,
stock
);
}
public
int
getSkuStock
(
String
marketPre
,
String
skuId
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
;
if
(
marketPre
!=
null
)
{
rk
=
rk
.
concat
(
marketPre
+
":"
);
}
rk
=
rk
.
concat
(
skuId
);
Object
obj
=
redisUtil
.
get
(
rk
);
if
(
obj
==
null
)
{
return
0
;
}
else
{
return
(
int
)
obj
;
}
}
public
int
incrSkuStock
(
String
marketPre
,
String
skuId
,
Integer
stock
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
;
if
(
marketPre
!=
null
)
{
rk
=
rk
.
concat
(
marketPre
+
":"
);
}
rk
=
rk
.
concat
(
skuId
);
return
(
int
)
redisUtil
.
incr
(
rk
,
stock
);
}
public
int
decrSkuStock
(
String
marketPre
,
String
skuId
,
Integer
stock
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
;
if
(
marketPre
!=
null
)
{
rk
=
rk
.
concat
(
marketPre
+
":"
);
}
rk
=
rk
.
concat
(
skuId
);
return
(
int
)
redisUtil
.
decr
(
rk
,
stock
);
}
/* ---------------------------------------- 商品数据源 ---------------------------------------- */
/* ---------------------------------------- 商品数据源 ---------------------------------------- */
public
boolean
setGoodsInfoVo
(
GoblinGoodsInfoVo
vo
)
{
public
boolean
setGoodsInfoVo
(
GoblinGoodsInfoVo
vo
)
{
...
@@ -129,7 +172,7 @@ public class GoblinRedisUtils {
...
@@ -129,7 +172,7 @@ public class GoblinRedisUtils {
}
}
}
}
public
void
addStoreMarketIsConfig
(
String
marketId
,
String
storeId
,
String
spuId
,
String
marketSpuId
)
{
public
void
addStoreMarketIsConfig
(
String
marketId
,
String
storeId
,
String
spuId
,
String
marketSpuId
)
{
String
redisKey
=
GoblinRedisConst
.
REDIS_GOBLIN_STORE_MARKET_ISCONFIG
.
concat
(
marketId
).
concat
(
":store_id:"
+
storeId
);
String
redisKey
=
GoblinRedisConst
.
REDIS_GOBLIN_STORE_MARKET_ISCONFIG
.
concat
(
marketId
).
concat
(
":store_id:"
+
storeId
);
List
<
GoblinStoreMarketIsConfigVo
>
voList
=
getStoreMarketIsConfig
(
marketId
,
storeId
);
List
<
GoblinStoreMarketIsConfigVo
>
voList
=
getStoreMarketIsConfig
(
marketId
,
storeId
);
GoblinStoreMarketIsConfigVo
vo
=
GoblinStoreMarketIsConfigVo
.
getNew
();
GoblinStoreMarketIsConfigVo
vo
=
GoblinStoreMarketIsConfigVo
.
getNew
();
...
@@ -139,12 +182,12 @@ public class GoblinRedisUtils {
...
@@ -139,12 +182,12 @@ public class GoblinRedisUtils {
redisUtil
.
set
(
redisKey
,
voList
);
redisUtil
.
set
(
redisKey
,
voList
);
}
}
public
void
delStoreMarketIsConfig
(
String
marketId
,
String
storeId
,
String
spuId
,
String
marketSpuId
)
{
public
void
delStoreMarketIsConfig
(
String
marketId
,
String
storeId
,
String
spuId
,
String
marketSpuId
)
{
String
redisKey
=
GoblinRedisConst
.
REDIS_GOBLIN_STORE_MARKET_ISCONFIG
.
concat
(
marketId
).
concat
(
":store_id:"
+
storeId
);
String
redisKey
=
GoblinRedisConst
.
REDIS_GOBLIN_STORE_MARKET_ISCONFIG
.
concat
(
marketId
).
concat
(
":store_id:"
+
storeId
);
List
<
GoblinStoreMarketIsConfigVo
>
voList
=
getStoreMarketIsConfig
(
marketId
,
storeId
);
List
<
GoblinStoreMarketIsConfigVo
>
voList
=
getStoreMarketIsConfig
(
marketId
,
storeId
);
for
(
int
i
=
0
;
i
<
voList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
voList
.
size
();
i
++)
{
String
itemSpuId
=
voList
.
get
(
i
).
getSpuId
();
String
itemSpuId
=
voList
.
get
(
i
).
getSpuId
();
if
(
spuId
.
equals
(
itemSpuId
))
{
if
(
spuId
.
equals
(
itemSpuId
))
{
voList
.
remove
(
i
);
voList
.
remove
(
i
);
}
}
}
}
...
...
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