记得上下班打卡 | 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
4395a16b
Commit
4395a16b
authored
Apr 30, 2022
by
wanglele
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
时间判断修改
parent
7e15cb7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
10 deletions
+48
-10
GoblinNftExSkuServiceImpl.java
...atform/service/impl/goblin/GoblinNftExSkuServiceImpl.java
+48
-10
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 @
4395a16b
...
@@ -99,15 +99,22 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
...
@@ -99,15 +99,22 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
if
(
bol
)
{
if
(
bol
)
{
// 获取spu下所有sku
// 获取spu下所有sku
List
<
GoblinGoodsSku
>
goblinGoodsSkus
=
goblinGoodsSkuMapper
.
selectBySpuIds
(
spuIds
.
toString
());
List
<
GoblinGoodsSku
>
goblinGoodsSkus
=
goblinGoodsSkuMapper
.
selectBySpuIds
(
spuIds
.
toString
());
int
countStockNumber
=
0
;
for
(
GoblinGoodsSku
goblinGoodsSku
:
goblinGoodsSkus
)
{
for
(
GoblinGoodsSku
goblinGoodsSku
:
goblinGoodsSkus
)
{
if
(
goblinGoodsSku
.
getUnbox
().
equals
(
"1"
))
{
if
(
goblinGoodsSku
.
getUnbox
().
equals
(
"1"
))
{
continue
;
continue
;
}
}
// 不能购买的 没库存的 概率是0的 过滤
// 不能购买的 没库存的 概率是0的 过滤
if
(
getSkuAllStatusShow
(
goblinGoodsSku
)
&&
goblinRedisUtils
.
getSkuAllStatusStock
(
goblinGoodsSku
)
>
0
&&
goblinGoodsSku
.
getHitRatio
()
!=
null
)
{
if
(
getSkuAllStatusShow
(
goblinGoodsSku
)
&&
goblinRedisUtils
.
getSkuAllStatusStock
(
goblinGoodsSku
)
>
0
&&
goblinGoodsSku
.
getHitRatio
()
!=
null
)
{
countStockNumber
+=
goblinRedisUtils
.
getSkuStock
(
goblinGoodsSku
.
getSkuId
());
map
.
put
(
goblinGoodsSku
.
getSkuId
(),
goblinGoodsSku
.
getHitRatio
());
map
.
put
(
goblinGoodsSku
.
getSkuId
(),
goblinGoodsSku
.
getHitRatio
());
}
}
}
}
if
(
countStockNumber
<
stockNumber
)
{
ResponseDto
.
failure
(
"配置库存大于sku总库存!"
);
}
}
}
...
@@ -359,7 +366,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
...
@@ -359,7 +366,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
*
*
* @return
* @return
*/
*/
private
Map
<
String
,
Integer
>
getSkuHitRatio
(
Integer
exStock
,
Map
<
String
,
BigDecimal
>
map
)
{
private
Map
<
String
,
Integer
>
getSkuHitRatio
(
Integer
exStock
,
Map
<
String
,
BigDecimal
>
map
)
{
// 获取sku总概率
// 获取sku总概率
BigDecimal
hitRatioCount
=
new
BigDecimal
(
0
);
BigDecimal
hitRatioCount
=
new
BigDecimal
(
0
);
...
@@ -367,7 +374,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
...
@@ -367,7 +374,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
// sku --> 概率/库存
// sku --> 概率/库存
Map
<
String
,
Map
<
String
,
Object
>>
mapMap
=
new
HashMap
<>();
Map
<
String
,
Map
<
String
,
Object
>>
mapMap
=
new
HashMap
<>();
int
j
=
0
;
int
countNumber
=
0
;
for
(
String
key
:
map
.
keySet
())
{
for
(
String
key
:
map
.
keySet
())
{
BigDecimal
skuHitRatio
=
map
.
get
(
key
);
BigDecimal
skuHitRatio
=
map
.
get
(
key
);
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
...
@@ -378,15 +385,36 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
...
@@ -378,15 +385,36 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
objectMap
.
put
(
"hitRatio"
,
skuHitRatio
);
objectMap
.
put
(
"hitRatio"
,
skuHitRatio
);
objectMap
.
put
(
"stock"
,
goblinRedisUtils
.
getSkuStock
(
key
));
objectMap
.
put
(
"stock"
,
goblinRedisUtils
.
getSkuStock
(
key
));
mapMap
.
put
(
key
,
objectMap
);
mapMap
.
put
(
key
,
objectMap
);
j
+=
100
;
}
}
// sku ---> 库存
// sku ---> 库存
Map
<
String
,
Integer
>
stockMap
=
new
HashMap
<>();
Map
<
String
,
Integer
>
stockMap
=
new
HashMap
<>();
getStock
(
exStock
,
hitRatioCount
,
mapMap
,
stockMap
);
getStock
(
exStock
,
hitRatioCount
,
mapMap
,
stockMap
);
return
stockMap
;
return
stockMap
;
}
}
public
static
void
main
(
String
[]
args
)
{
Map
<
String
,
Map
<
String
,
Object
>>
mapMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<>();
objectMap
.
put
(
"hitRatio"
,
10
);
objectMap
.
put
(
"stock"
,
5
);
mapMap
.
put
(
"1"
,
objectMap
);
Map
<
String
,
Object
>
objectMap1
=
new
HashMap
<>();
objectMap1
.
put
(
"hitRatio"
,
20
);
objectMap1
.
put
(
"stock"
,
100
);
mapMap
.
put
(
"2"
,
objectMap1
);
Map
<
String
,
Object
>
objectMap2
=
new
HashMap
<>();
objectMap2
.
put
(
"hitRatio"
,
30
);
objectMap2
.
put
(
"stock"
,
100
);
mapMap
.
put
(
"3"
,
objectMap2
);
Map
<
String
,
Integer
>
stockMap
=
new
HashMap
<>();
getStock
(
10
,
new
BigDecimal
(
60
),
mapMap
,
stockMap
);
System
.
out
.
println
(
"kkk"
);
}
/**
/**
* 获取单个sku库存
* 获取单个sku库存
*
*
...
@@ -395,17 +423,26 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
...
@@ -395,17 +423,26 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
* @param mapMap
* @param mapMap
* @return
* @return
*/
*/
private
void
getStock
(
Integer
exStock
,
BigDecimal
hitRatioCount
,
Map
<
String
,
Map
<
String
,
Object
>>
mapMap
,
Map
<
String
,
Integer
>
stockMap
)
{
private
static
void
getStock
(
Integer
exStock
,
BigDecimal
hitRatioCount
,
Map
<
String
,
Map
<
String
,
Object
>>
mapMap
,
Map
<
String
,
Integer
>
stockMap
)
{
if
(
exStock
<
0
)
{
if
(
exStock
<
=
0
)
{
return
;
return
;
}
}
int
subNumber
=
0
;
for
(
String
key
:
mapMap
.
keySet
())
{
for
(
String
key
:
mapMap
.
keySet
())
{
Object
stock
=
mapMap
.
get
(
key
).
get
(
"stock"
);
Object
stock
=
mapMap
.
get
(
key
).
get
(
"stock"
);
Object
hitRatio
=
mapMap
.
get
(
key
).
get
(
"hitRatio"
);
Object
hitRatio
=
mapMap
.
get
(
key
).
get
(
"hitRatio"
);
if
(
Integer
.
valueOf
(
stock
.
toString
())
<
0
)
{
continue
;
}
BigDecimal
bigDecimal
=
BigDecimal
.
valueOf
(
exStock
).
multiply
((
new
BigDecimal
(
hitRatio
.
toString
()).
divide
(
hitRatioCount
,
2
,
BigDecimal
.
ROUND_HALF_UP
))).
setScale
(
0
,
BigDecimal
.
ROUND_HALF_UP
);
// 要减去的库存
// 要减去的库存
int
subStock
=
BigDecimal
.
valueOf
(
exStock
).
multiply
((
new
BigDecimal
(
hitRatio
.
toString
()).
divide
(
hitRatioCount
,
2
,
BigDecimal
.
ROUND_HALF_UP
))).
setScale
(
0
,
BigDecimal
.
ROUND_HALF_UP
).
intValue
();
int
subStock
=
BigDecimal
.
valueOf
(
exStock
).
multiply
((
new
BigDecimal
(
hitRatio
.
toString
()).
divide
(
hitRatioCount
,
2
,
BigDecimal
.
ROUND_HALF_UP
))).
setScale
(
0
,
BigDecimal
.
ROUND_HALF_UP
).
intValue
();
if
(
subStock
>
Integer
.
valueOf
(
stock
.
toString
()))
{
if
(
subStock
>
Integer
.
valueOf
(
stock
.
toString
()))
{
exStock
=
exStock
-
Integer
.
valueOf
(
stock
.
toString
());
subNumber
+=
Integer
.
valueOf
(
stock
.
toString
());
mapMap
.
get
(
key
).
put
(
"stock"
,
0
);
mapMap
.
get
(
key
).
put
(
"stock"
,
0
);
if
(
stockMap
.
get
(
key
)
==
null
)
{
if
(
stockMap
.
get
(
key
)
==
null
)
{
stockMap
.
put
(
key
,
Integer
.
valueOf
(
stock
.
toString
()));
stockMap
.
put
(
key
,
Integer
.
valueOf
(
stock
.
toString
()));
...
@@ -414,7 +451,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
...
@@ -414,7 +451,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
}
}
}
else
{
}
else
{
exStock
=
exStock
-
subStock
;
subNumber
+=
subStock
;
if
(
stockMap
.
get
(
key
)
==
null
)
{
if
(
stockMap
.
get
(
key
)
==
null
)
{
stockMap
.
put
(
key
,
subStock
);
stockMap
.
put
(
key
,
subStock
);
}
else
{
}
else
{
...
@@ -422,14 +459,15 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
...
@@ -422,14 +459,15 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
}
}
}
}
}
}
exStock
-=
subNumber
;
if
(
exStock
>
0
)
{
if
(
exStock
>
0
)
{
for
(
String
key
:
mapMap
.
keySet
())
{
for
(
String
key
:
mapMap
.
keySet
())
{
Object
hitRatio
=
mapMap
.
get
(
key
).
get
(
"hitRatio"
);
Object
hitRatio
=
mapMap
.
get
(
key
).
get
(
"hitRatio"
);
Object
stock
=
mapMap
.
get
(
key
).
get
(
"stock"
);
Object
stock
=
mapMap
.
get
(
key
).
get
(
"stock"
);
if
(
Integer
.
valueOf
(
stock
.
toString
())
<
0
)
{
if
(
Integer
.
valueOf
(
stock
.
toString
())
<
=
0
)
{
hitRatioCount
=
hitRatioCount
.
subtract
(
new
BigDecimal
(
hitRatio
.
toString
()));
}
}
hitRatioCount
.
subtract
(
new
BigDecimal
(
hitRatio
.
toString
()));
}
}
getStock
(
exStock
,
hitRatioCount
,
mapMap
,
stockMap
);
getStock
(
exStock
,
hitRatioCount
,
mapMap
,
stockMap
);
}
}
...
...
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