记得上下班打卡 | 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
6d60dba7
Commit
6d60dba7
authored
May 25, 2022
by
wanglele
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改生成兑换码 概率精确
parent
9386c779
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
4 deletions
+71
-4
GoblinNftExSkuServiceImpl.java
...atform/service/impl/goblin/GoblinNftExSkuServiceImpl.java
+71
-4
No files found.
liquidnet-bus-service/liquidnet-service-platform/liquidnet-service-platform-impl/src/main/java/com/liquidnet/service/platform/service/impl/goblin/GoblinNftExSkuServiceImpl.java
View file @
6d60dba7
...
...
@@ -106,10 +106,18 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
List
<
GoblinGoodsSku
>
goblinGoodsSkus
=
goblinGoodsSkuMapper
.
selectBySpuIds
(
spuIds
.
toString
());
int
countStockNumber
=
0
;
int
checkNumberSku
=
0
;
// 是否存在概率为空
boolean
isHit
=
false
;
// 概率相加
BigDecimal
hitRatioCount
=
new
BigDecimal
(
0
);
for
(
GoblinGoodsSku
goblinGoodsSku
:
goblinGoodsSkus
)
{
if
(
goblinGoodsSku
.
getUnbox
().
equals
(
"1"
))
{
continue
;
}
// 判断开售、停售时间
LocalDateTime
saleStartTime
=
goblinGoodsSku
.
getSaleStartTime
();
LocalDateTime
saleStopTime
=
goblinGoodsSku
.
getSaleStopTime
();
...
...
@@ -124,8 +132,16 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
if
(!
goblinGoodsSku
.
getSkuCanbuy
().
equals
(
"1"
))
{
continue
;
}
// 不能购买的 没库存的 概率是0的 过滤
if
(
getSkuAllStatusShow
(
goblinGoodsSku
)
&&
goblinRedisUtils
.
getSkuAllStatusStock
(
goblinGoodsSku
)
>
0
&&
goblinGoodsSku
.
getHitRatio
()
!=
null
)
{
if
(
getSkuAllStatusShow
(
goblinGoodsSku
)
&&
goblinRedisUtils
.
getSkuAllStatusStock
(
goblinGoodsSku
)
>
0
)
{
log
.
debug
(
"skuId:"
+
goblinGoodsSku
.
getSkuId
()+
"----hitRatio:"
+
goblinGoodsSku
.
getHitRatio
());
if
(
goblinGoodsSku
.
getHitRatio
()
==
null
)
{
isHit
=
true
;
}
else
{
hitRatioCount
.
add
(
goblinGoodsSku
.
getHitRatio
());
}
countStockNumber
+=
goblinRedisUtils
.
getSkuStock
(
goblinGoodsSku
.
getSkuId
());
map
.
put
(
goblinGoodsSku
.
getSkuId
(),
goblinGoodsSku
.
getHitRatio
());
checkNumberSku
++;
...
...
@@ -140,6 +156,12 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
ResponseDto
.
failure
(
"配置库存大于sku总库存!"
);
}
if
(
isHit
&&
hitRatioCount
.
doubleValue
()
<
100.00
&&
map
.
size
()
>
0
)
{
arrangeHitRatioMap
(
map
,
hitRatioCount
);
}
}
...
...
@@ -220,6 +242,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
return
ResponseDto
.
success
(
true
);
}
/**
* 获取每个sku的兑换码生成数量
* <p>
...
...
@@ -321,12 +344,56 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
Map
<
String
,
Integer
>
stockMap
=
new
HashMap
<>();
ArrayList
<
String
>
eliminateSkuIdList
=
CollectionUtil
.
arrayListString
();
getStock
(
594
,
new
BigDecimal
(
100
),
mapMap
,
stockMap
,
2993
,
eliminateSkuIdList
);
//
getStock(594, new BigDecimal(100), mapMap, stockMap, 2993, eliminateSkuIdList);
for
(
String
key
:
stockMap
.
keySet
())
{
System
.
out
.
println
(
"skuId"
+
key
+
"***********数量
"
+
stockMap
.
get
(
key
));
// System.out.println("skuId:" + key + "***********数量:
" + stockMap.get(key));
}
System
.
out
.
println
(
"kkk"
);
// System.out.println("kkk");
Map
<
String
,
BigDecimal
>
hmap
=
new
HashMap
<>();
hmap
.
put
(
"1"
,
new
BigDecimal
(
40
));
hmap
.
put
(
"2"
,
new
BigDecimal
(
49
));
hmap
.
put
(
"3"
,
null
);
hmap
.
put
(
"4"
,
null
);
hmap
.
put
(
"5"
,
null
);
arrangeHitRatioMap
(
hmap
,
new
BigDecimal
(
89
));
for
(
String
key
:
hmap
.
keySet
())
{
}
}
/**
* 整理map集合中存在空概率的值
*
* @param map,hitRatioCount
*/
private
static
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
);
}
}
}
/**
* 获取单个sku库存
...
...
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