记得上下班打卡 | 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
0d4bd919
Commit
0d4bd919
authored
May 25, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加 分批购 支持盲盒配置
增加 分批购 盲盒回滚逻辑
parent
99250889
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
42 deletions
+55
-42
GoblinRedisUtils.java
...a/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
+55
-42
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
View file @
0d4bd919
...
...
@@ -884,13 +884,13 @@ public class GoblinRedisUtils {
* @param skuId
* @return
*/
public
void
goblinNftListStock
(
LocalDateTime
now
,
String
skuId
,
LocalDateTime
saleStartTime
)
{
public
void
goblinNftListStock
(
LocalDateTime
now
,
String
skuId
,
LocalDateTime
saleStartTime
)
{
GoblinListCollectVo
collectVo
=
null
;
GoblinListCollectVo
collectTemp
=
null
;
List
<
GoblinListCollectVo
>
collectVos
=
getGoblinListCollect
(
skuId
);
if
(
now
.
isAfter
(
saleStartTime
))
{
if
(
now
.
isAfter
(
saleStartTime
))
{
lastStockToLastStock
(
0
,
collectVos
,
null
,
skuId
);
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
collectVos
.
size
();
i
++)
{
GoblinListCollectVo
collectVoItem
=
collectVos
.
get
(
i
);
if
(
now
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
collectVoItem
.
getTimeEnd
()
==
null
)
{
...
...
@@ -968,19 +968,32 @@ public class GoblinRedisUtils {
public
void
lastStockToLastStock
(
Integer
type
,
List
<
GoblinListCollectVo
>
collectVos
,
GoblinListCollectVo
vo
,
String
skuId
)
{
if
(
vo
==
null
&&
type
==
0
)
{
//已开售逻辑
for
(
GoblinListCollectVo
collectVoItem
:
collectVos
)
{
int
lastStock
=
getSkuStock
(
collectVoItem
.
getListId
(),
skuId
);
log
.
debug
(
"all stock = "
+
lastStock
);
int
restStock
=
decrSkuStock
(
collectVoItem
.
getListId
(),
skuId
,
lastStock
);
if
(
restStock
<
0
)
{
incrSkuStock
(
collectVoItem
.
getListId
(),
skuId
,
lastStock
);
List
<
String
>
skuIds
=
getGoblinListRelationBox
(
skuId
,
collectVoItem
.
getListId
());
int
lastStock
;
if
(
skuIds
.
size
()
>
0
)
{
//盲盒逻辑
for
(
String
skuIdItem
:
skuIds
)
{
lastStock
=
getSkuStock
(
collectVoItem
.
getListId
(),
skuIdItem
);
log
.
debug
(
"all stock = "
+
lastStock
);
int
restStock
=
decrSkuStock
(
collectVoItem
.
getListId
(),
skuIdItem
,
lastStock
);
if
(
restStock
<
0
)
{
incrSkuStock
(
collectVoItem
.
getListId
(),
skuIdItem
,
lastStock
);
}
else
{
incrSkuStock
(
null
,
skuIdItem
,
lastStock
);
}
}
}
else
{
incrSkuStock
(
null
,
skuId
,
lastStock
);
lastStock
=
getSkuStock
(
collectVoItem
.
getListId
(),
skuId
);
log
.
debug
(
"all stock = "
+
lastStock
);
int
restStock
=
decrSkuStock
(
collectVoItem
.
getListId
(),
skuId
,
lastStock
);
if
(
restStock
<
0
)
{
incrSkuStock
(
collectVoItem
.
getListId
(),
skuId
,
lastStock
);
}
else
{
incrSkuStock
(
null
,
skuId
,
lastStock
);
}
}
}
}
else
if
(
vo
!=
null
&&
type
==
1
)
{
LocalDateTime
st
=
vo
.
getTimeStart
();
// GoblinListCollectVo collectVo = null;
// GoblinListCollectVo collectTemp = null;
//获取上个分配购的vo
List
<
GoblinListCollectVo
>
collectVosList
=
ObjectUtil
.
getGoblinListCollectVo
();
for
(
GoblinListCollectVo
collectVoItem
:
collectVos
)
{
...
...
@@ -996,32 +1009,32 @@ public class GoblinRedisUtils {
break
;
}
}
// if (collectVo == null) {
// collectVo = collectTemp;
// }
// if (collectVo != null) {
// //减少上个时间段sku库存
// int lastStock = getSkuStock(collectVo.getListId(), skuId);
// int restStock = decrSkuStock(collectVo.getListId(), skuId, lastStock);
// if (restStock < 0) {
// //库存超过销售量 操作失败回滚库存
// incrSkuStock(collectVo.getListId(), skuId, lastStock);
// } else {
// //上个时间段的库存增加到当前时间段
// incrSkuStock(vo.getListId(), skuId, lastStock);
// }
// }
for
(
GoblinListCollectVo
itemVo
:
collectVosList
)
{
//减少上个时间段sku库存
int
lastStock
=
getSkuStock
(
itemVo
.
getListId
(),
skuId
);
log
.
debug
(
"temp stock = "
+
lastStock
);
int
restStock
=
decrSkuStock
(
itemVo
.
getListId
(),
skuId
,
lastStock
);
if
(
restStock
<
0
)
{
//库存超过销售量 操作失败回滚库存
incrSkuStock
(
itemVo
.
getListId
(),
skuId
,
lastStock
);
int
lastStock
;
List
<
String
>
skuIds
=
getGoblinListRelationBox
(
skuId
,
itemVo
.
getListId
());
if
(
skuIds
.
size
()
>
0
)
{
//盲盒逻辑
for
(
String
skuIdItem
:
skuIds
)
{
lastStock
=
getSkuStock
(
itemVo
.
getListId
(),
skuIdItem
);
log
.
debug
(
"temp stock = "
+
lastStock
);
int
restStock
=
decrSkuStock
(
itemVo
.
getListId
(),
skuIdItem
,
lastStock
);
if
(
restStock
<
0
)
{
incrSkuStock
(
itemVo
.
getListId
(),
skuIdItem
,
lastStock
);
}
else
{
incrSkuStock
(
vo
.
getListId
(),
skuIdItem
,
lastStock
);
}
}
}
else
{
//上个时间段的库存增加到当前时间段
incrSkuStock
(
vo
.
getListId
(),
skuId
,
lastStock
);
//减少上个时间段sku库存
lastStock
=
getSkuStock
(
itemVo
.
getListId
(),
skuId
);
log
.
debug
(
"temp stock = "
+
lastStock
);
int
restStock
=
decrSkuStock
(
itemVo
.
getListId
(),
skuId
,
lastStock
);
if
(
restStock
<
0
)
{
//库存超过销售量 操作失败回滚库存
incrSkuStock
(
itemVo
.
getListId
(),
skuId
,
lastStock
);
}
else
{
//上个时间段的库存增加到当前时间段
incrSkuStock
(
vo
.
getListId
(),
skuId
,
lastStock
);
}
}
}
}
...
...
@@ -1048,7 +1061,7 @@ public class GoblinRedisUtils {
}
if
(
whiteType
==
-
1
)
{
return
true
;
}
else
if
(
whiteType
==
0
)
{
//会员
}
else
if
(
whiteType
==
0
)
{
//会员
return
memberStage
!=
null
;
}
else
{
//白名单
return
wResult
;
...
...
@@ -2245,9 +2258,9 @@ public class GoblinRedisUtils {
/**
* 设置 盲盒skuId 关联 的skuId
*/
public
void
addGoblinListRelationBox
(
String
skuId
,
String
listId
,
String
relationSkuId
)
{
String
rdk
=
GoblinRedisConst
.
LIST_RELATION_BOX
.
concat
(
skuId
).
concat
(
":"
+
listId
);
ArrayList
<
String
>
list
=
getGoblinListRelationBox
(
skuId
,
listId
);
public
void
addGoblinListRelationBox
(
String
skuId
,
String
listId
,
String
relationSkuId
)
{
String
rdk
=
GoblinRedisConst
.
LIST_RELATION_BOX
.
concat
(
skuId
).
concat
(
":"
+
listId
);
ArrayList
<
String
>
list
=
getGoblinListRelationBox
(
skuId
,
listId
);
list
.
add
(
relationSkuId
);
redisUtil
.
set
(
rdk
,
list
);
}
...
...
@@ -2256,11 +2269,11 @@ public class GoblinRedisUtils {
* 获取 盲盒skuId 关联 的skuId
*/
public
ArrayList
<
String
>
getGoblinListRelationBox
(
String
skuId
,
String
listId
)
{
String
rdk
=
GoblinRedisConst
.
LIST_RELATION_BOX
.
concat
(
skuId
).
concat
(
":"
+
listId
);
String
rdk
=
GoblinRedisConst
.
LIST_RELATION_BOX
.
concat
(
skuId
).
concat
(
":"
+
listId
);
Object
obj
=
redisUtil
.
get
(
rdk
);
if
(
obj
==
null
)
{
if
(
obj
==
null
)
{
return
CollectionUtil
.
arrayListString
();
}
else
{
}
else
{
return
(
ArrayList
<
String
>)
obj
;
}
}
...
...
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