记得上下班打卡 | 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
7d7fe923
Commit
7d7fe923
authored
May 10, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交 结束时间未填写分段购 sku详情逻辑
增加 上个时间段 库存未售罄的库存
parent
706e6de9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
25 deletions
+167
-25
GoblinRedisUtils.java
...a/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
+88
-17
GoblinRedisUtils.java
...a/com/liquidnet/service/order/utils/GoblinRedisUtils.java
+79
-8
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 @
7d7fe923
...
...
@@ -713,30 +713,101 @@ public class GoblinRedisUtils {
*/
public
HashMap
<
String
,
Object
>
getGoodsSkuInfoVo
(
LocalDateTime
now
,
String
skuId
)
{
GoblinGoodsSkuInfoVo
vo
=
getGoodsSkuInfoVo
(
skuId
);
HashMap
<
String
,
Object
>
map
=
CollectionUtil
.
mapStringObject
();
if
(
now
.
isAfter
(
vo
.
getSaleStartTime
()))
{
//普通商品已开售
lastStockToLastStock
(
getGoblinListCollect
(
skuId
),
null
,
skuId
);
map
.
put
(
"vo"
,
vo
);
map
.
put
(
"tagType"
,
null
);
map
.
put
(
"listId"
,
null
);
}
else
{
//未开售
GoblinListCollectVo
collectVo
=
getCollectByNow
(
now
,
skuId
);
Integer
tagType
=
null
;
String
listId
=
null
;
if
(
collectVo
!=
null
)
{
vo
.
setPrice
(
collectVo
.
getPrice
());
vo
.
setPriceV
(
collectVo
.
getPriceV
());
vo
.
setProductId
(
collectVo
.
getProductId
());
vo
.
setSaleStartTime
(
collectVo
.
getTimeStart
());
vo
.
setSaleStopTime
(
collectVo
.
getTimeEnd
());
tagType
=
collectVo
.
getTagType
();
listId
=
collectVo
.
getListId
();
}
map
.
put
(
"vo"
,
vo
);
map
.
put
(
"tagType"
,
tagType
);
map
.
put
(
"listId"
,
listId
);
}
return
map
;
}
/**
* 根据时间获取当前分段购vo
*
* @param now
* @param skuId
* @return
*/
public
GoblinListCollectVo
getCollectByNow
(
LocalDateTime
now
,
String
skuId
)
{
GoblinListCollectVo
collectVo
=
null
;
GoblinListCollectVo
collectTemp
=
null
;
List
<
GoblinListCollectVo
>
collectVos
=
getGoblinListCollect
(
skuId
);
for
(
GoblinListCollectVo
collectVoItem
:
collectVos
)
{
if
(
now
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
collectVoItem
.
getTimeEnd
()
==
null
)
{
if
(
collectTemp
==
null
||
collectTemp
.
getTimeStart
().
isBefore
(
collectVoItem
.
getTimeStart
()))
{
collectTemp
=
collectVoItem
;
}
}
else
if
(
now
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
now
.
isBefore
(
collectVoItem
.
getTimeEnd
()))
{
collectVo
=
collectVoItem
;
break
;
}
}
if
(
collectVo
==
null
)
{
collectVo
=
collectTemp
;
}
lastStockToLastStock
(
collectVos
,
collectVo
,
skuId
);
return
collectVo
;
}
/**
* 处理上个时间段的库存
*
* @param collectVos
* @param vo
* @param skuId
*/
public
void
lastStockToLastStock
(
List
<
GoblinListCollectVo
>
collectVos
,
GoblinListCollectVo
vo
,
String
skuId
)
{
if
(
vo
==
null
){
//已开售逻辑
}
LocalDateTime
st
=
vo
.
getTimeStart
().
minusSeconds
(
1
);
GoblinListCollectVo
collectVo
=
null
;
GoblinListCollectVo
collectTemp
=
null
;
//获取上个分配购的vo
for
(
GoblinListCollectVo
collectVoItem
:
collectVos
)
{
if
(
now
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
now
.
isBefore
(
collectVoItem
.
getTimeEnd
()))
{
if
(
st
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
collectVoItem
.
getTimeEnd
()
==
null
)
{
collectTemp
=
collectVoItem
;
}
else
if
(
st
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
st
.
isBefore
(
collectVoItem
.
getTimeEnd
()))
{
collectVo
=
collectVoItem
;
break
;
}
}
HashMap
<
String
,
Object
>
map
=
CollectionUtil
.
mapStringObject
();
Integer
tagType
=
null
;
String
listId
=
null
;
if
(
collectVo
!=
null
)
{
vo
.
setPrice
(
collectVo
.
getPrice
());
vo
.
setPriceV
(
collectVo
.
getPriceV
());
vo
.
setProductId
(
collectVo
.
getProductId
());
vo
.
setSaleStartTime
(
collectVo
.
getTimeStart
());
vo
.
setSaleStopTime
(
collectVo
.
getTimeEnd
());
tagType
=
collectVo
.
getTagType
();
listId
=
collectVo
.
getListId
();
}
map
.
put
(
"vo"
,
vo
);
map
.
put
(
"tagType"
,
tagType
);
map
.
put
(
"listId"
,
listId
);
return
map
;
if
(
collectVo
==
null
)
{
collectVo
=
collectTemp
;
}
if
(
collectVo
==
null
&&
collectVos
.
size
()
!=
0
)
{
}
else
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
);
}
}
}
public
GoblinGoodsSkuInfoVo
getGoodsSkuInfoVoByUnShelves
(
String
skuId
)
{
...
...
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/utils/GoblinRedisUtils.java
View file @
7d7fe923
...
...
@@ -45,6 +45,20 @@ public class GoblinRedisUtils {
return
(
int
)
redisUtil
.
decr
(
rk
,
stock
);
}
public
int
getSkuStock
(
String
marketPre
,
String
skuId
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
;
if
(
marketPre
!=
null
&&
!
marketPre
.
equals
(
"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
getSkuStock
(
String
skuId
)
{
String
rk
=
GoblinRedisConst
.
REAL_STOCK_SKU
.
concat
(
skuId
);
Object
obj
=
redisUtil
.
get
(
rk
);
...
...
@@ -171,14 +185,7 @@ public class GoblinRedisUtils {
*/
public
HashMap
<
String
,
Object
>
getGoodsSkuInfoVo
(
LocalDateTime
now
,
String
skuId
)
{
GoblinGoodsSkuInfoVo
vo
=
getGoodsSkuInfoVo
(
skuId
);
List
<
GoblinListCollectVo
>
collectVos
=
getGoblinListCollect
(
skuId
);
GoblinListCollectVo
collectVo
=
null
;
for
(
GoblinListCollectVo
collectVoItem
:
collectVos
)
{
if
(
now
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
now
.
isBefore
(
collectVoItem
.
getTimeEnd
()))
{
collectVo
=
collectVoItem
;
break
;
}
}
GoblinListCollectVo
collectVo
=
getCollectByNow
(
now
,
skuId
);
HashMap
<
String
,
Object
>
map
=
CollectionUtil
.
mapStringObject
();
Integer
tagType
=
null
;
String
listId
=
null
;
...
...
@@ -197,6 +204,70 @@ public class GoblinRedisUtils {
return
map
;
}
/**
* 根据时间获取当前分段购vo
* @param now
* @param skuId
* @return
*/
public
GoblinListCollectVo
getCollectByNow
(
LocalDateTime
now
,
String
skuId
)
{
GoblinListCollectVo
collectVo
=
null
;
GoblinListCollectVo
collectTemp
=
null
;
List
<
GoblinListCollectVo
>
collectVos
=
getGoblinListCollect
(
skuId
);
//获取当前
for
(
GoblinListCollectVo
collectVoItem
:
collectVos
)
{
if
(
now
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
collectVoItem
.
getTimeEnd
()
==
null
)
{
if
(
collectTemp
==
null
||
collectTemp
.
getTimeStart
().
isBefore
(
collectVoItem
.
getTimeStart
()))
{
collectTemp
=
collectVoItem
;
}
}
else
if
(
now
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
now
.
isBefore
(
collectVoItem
.
getTimeEnd
()))
{
collectVo
=
collectVoItem
;
break
;
}
}
if
(
collectVo
==
null
){
collectVo
=
collectTemp
;
}
lastStockToLastStock
(
collectVos
,
collectVo
,
skuId
);
return
collectVo
;
}
/**
* 处理上个时间段的库存
* @param collectVos
* @param vo
* @param skuId
*/
public
void
lastStockToLastStock
(
List
<
GoblinListCollectVo
>
collectVos
,
GoblinListCollectVo
vo
,
String
skuId
){
LocalDateTime
st
=
vo
.
getTimeStart
().
minusSeconds
(
1
);
GoblinListCollectVo
collectVo
=
null
;
GoblinListCollectVo
collectTemp
=
null
;
//获取上个分配购的vo
for
(
GoblinListCollectVo
collectVoItem
:
collectVos
)
{
if
(
st
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
collectVoItem
.
getTimeEnd
()
==
null
)
{
collectTemp
=
collectVoItem
;
}
else
if
(
st
.
isAfter
(
collectVoItem
.
getTimeStart
())
&&
st
.
isBefore
(
collectVoItem
.
getTimeEnd
()))
{
collectVo
=
collectVoItem
;
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
);
}
}
}
/**
* 分段购获取
* @param skuId
...
...
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