记得上下班打卡 | 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
bead4326
Commit
bead4326
authored
Jun 01, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改生成盲盒库存逻辑
parent
297552b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
4 deletions
+96
-4
GoblinListServiceImpl.java
...ice/goblin/service/impl/manage/GoblinListServiceImpl.java
+32
-4
GoblinNftBoxUtils.java
.../com/liquidnet/service/goblin/util/GoblinNftBoxUtils.java
+64
-0
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/manage/GoblinListServiceImpl.java
View file @
bead4326
...
...
@@ -80,7 +80,7 @@ public class GoblinListServiceImpl implements IGoblinListService {
item
.
setSkuName
(
skuVo
.
getName
());
if
(
skuVo
.
getUnbox
().
equals
(
"1"
))
{
int
stock
=
0
;
ArrayList
<
String
>
skuIdList
=
redisUtils
.
getGoblinListRelationBox
(
skuVo
.
getSkuId
(),
vo
.
getListId
());
ArrayList
<
String
>
skuIdList
=
redisUtils
.
getGoblinListRelationBox
(
skuVo
.
getSkuId
(),
vo
.
getListId
());
for
(
String
relationSkuId
:
skuIdList
)
{
stock
+=
redisUtils
.
getSkuStock
(
listId
,
relationSkuId
);
}
...
...
@@ -212,10 +212,38 @@ public class GoblinListServiceImpl implements IGoblinListService {
//计算盲盒对应sku数量
HashMap
<
String
,
BigDecimal
>
map
=
CollectionUtil
.
mapStringBigDecimal
();
GoblinGoodsInfoVo
spuInfoVo
=
redisUtils
.
getGoodsInfoVo
(
item
.
getSpuId
());
// int countStockNumber = 0;
// int checkNumberSku = 0;
// 是否存在概率为空
boolean
isHit
=
false
;
// 概率相加
BigDecimal
hitRatioCount
=
new
BigDecimal
(
0
);
for
(
String
itemSkuId
:
spuInfoVo
.
getSkuIdList
())
{
GoblinGoodsSkuInfoVo
skuItemVo
=
redisUtils
.
getGoodsSkuInfoVo
(
itemSkuId
);
if
(
skuItemVo
.
getUnbox
().
equals
(
"0"
))
{
// if (skuItemVo.getUnbox().equals("0")) {
// map.put(skuItemVo.getSkuId(), skuItemVo.getHitRatio());
// }
log
.
info
(
"step1:"
+
nftBoxUtils
.
getSkuAllStatusShow
(
skuItemVo
));
log
.
info
(
"step2:"
+
nftBoxUtils
.
getSkuAllStatusStock
(
skuItemVo
));
if
(
nftBoxUtils
.
getSkuAllStatusShow
(
skuItemVo
)
&&
nftBoxUtils
.
getSkuAllStatusStock
(
skuItemVo
)
>
0
)
{
if
(
skuItemVo
.
getHitRatio
()
==
null
)
{
isHit
=
true
;
}
else
{
hitRatioCount
=
hitRatioCount
.
add
(
skuItemVo
.
getHitRatio
());
}
// countStockNumber += goblinRedisUtils.getSkuStock(goblinGoodsSku.getSkuId());
map
.
put
(
skuItemVo
.
getSkuId
(),
skuItemVo
.
getHitRatio
());
// checkNumberSku++;
}
// if (checkNumberSku <= 0) {
// return ResponseDto.failure("盲盒下没有可生成兑换码的sku!");
// }
//
// if (countStockNumber < stockNumber) {
// ResponseDto.failure("配置库存大于sku总库存!");
// }
if
(
isHit
&&
hitRatioCount
.
doubleValue
()
<
100.00
&&
map
.
size
()
>
0
)
{
nftBoxUtils
.
arrangeHitRatioMap
(
map
,
hitRatioCount
);
}
}
Map
<
String
,
Integer
>
skuMap
=
nftBoxUtils
.
getSkuHitRatio
(
item
.
getSkuStock
(),
map
);
...
...
@@ -229,7 +257,7 @@ public class GoblinListServiceImpl implements IGoblinListService {
return
ResponseDto
.
failure
(
"库存不足"
);
}
else
{
redisUtils
.
setSkuStock
(
vo
.
getListId
(),
key
,
stockNum
);
redisUtils
.
addGoblinListRelationBox
(
itemVo
.
getSkuId
()
,
vo
.
getListId
(),
key
);
redisUtils
.
addGoblinListRelationBox
(
itemVo
.
getSkuId
()
,
vo
.
getListId
(),
key
);
}
}
...
...
@@ -346,7 +374,7 @@ public class GoblinListServiceImpl implements IGoblinListService {
//获取skuVo
GoblinGoodsSkuInfoVo
skuVo
=
redisUtils
.
getGoodsSkuInfoVo
(
vo
.
getItemVo
().
get
(
0
).
getSkuId
());
if
(
skuVo
.
getUnbox
().
equals
(
"1"
))
{
ArrayList
<
String
>
skuIdList
=
redisUtils
.
getGoblinListRelationBox
(
skuVo
.
getSkuId
(),
vo
.
getListId
());
ArrayList
<
String
>
skuIdList
=
redisUtils
.
getGoblinListRelationBox
(
skuVo
.
getSkuId
(),
vo
.
getListId
());
for
(
String
relationSkuId
:
skuIdList
)
{
int
restStock
=
redisUtils
.
getSkuStock
(
vo
.
getListId
(),
relationSkuId
);
if
(
restStock
>
0
)
{
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinNftBoxUtils.java
View file @
bead4326
package
com
.
liquidnet
.
service
.
goblin
.
util
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
import
com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo
;
import
com.liquidnet.service.goblin.entity.GoblinGoodsSku
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -163,4 +166,65 @@ public class GoblinNftBoxUtils {
}
}
// 各种状态下判断藏品是否可以展示
public
boolean
getSkuAllStatusShow
(
GoblinGoodsSkuInfoVo
info
)
{
if
(
info
!=
null
&&
info
.
getSkuType
()
==
1
&&
info
.
getStatus
().
equals
(
"3"
)
&&
info
.
getShelvesStatus
().
equals
(
"3"
)
// && (info.getSkuAppear() == null || info.getSkuAppear().equals("0"))
&&
info
.
getDelFlg
().
equals
(
"0"
)
)
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 整理map集合中存在空概率的值
*
* @param map,hitRatioCount
*/
public
void
arrangeHitRatioMap
(
Map
<
String
,
BigDecimal
>
map
,
BigDecimal
hitRatioCount
)
{
// 定义最大概率
BigDecimal
maxHitRatio
=
new
BigDecimal
(
100
);
// 剩余概率
BigDecimal
remainHitRatio
=
maxHitRatio
.
subtract
(
hitRatioCount
);
// 获取值为空的数量
int
number
=
0
;
for
(
String
key
:
map
.
keySet
())
{
if
(
map
.
get
(
key
)
==
null
)
{
number
++;
}
}
// 平均值
BigDecimal
averageNumber
=
remainHitRatio
.
divide
(
BigDecimal
.
valueOf
(
number
),
2
,
BigDecimal
.
ROUND_DOWN
);
for
(
String
key
:
map
.
keySet
())
{
if
(
map
.
get
(
key
)
==
null
)
{
map
.
put
(
key
,
averageNumber
);
}
}
}
// 获取盲盒下藏品的库存 各种状态下不能算库存的排除掉
public
int
getSkuAllStatusStock
(
GoblinGoodsSkuInfoVo
info
)
{
if
(
info
!=
null
// && LocalDateTime.now().isAfter(info.getSaleStartTime())
&&
(
null
==
info
.
getSoldoutStatus
()
||
info
.
getSoldoutStatus
().
equals
(
"0"
))
&&
(
null
==
info
.
getHitRatio
()
||
info
.
getHitRatio
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
)
{
// 可以返回库存
return
(
int
)
redisUtils
.
getSkuStock
(
null
,
info
.
getSkuId
());
}
else
{
// 不计入库存
return
0
;
}
}
}
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