记得上下班打卡 | 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
eb8e42d9
Commit
eb8e42d9
authored
May 21, 2022
by
jiangxiulong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
3d13fbc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
1 deletion
+102
-1
GoblinNftJobServiceImpl.java
...ce/goblin/service/impl/inner/GoblinNftJobServiceImpl.java
+102
-1
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/inner/GoblinNftJobServiceImpl.java
View file @
eb8e42d9
...
...
@@ -42,7 +42,14 @@ public class GoblinNftJobServiceImpl {
@Autowired
IGoblinGoodsAnticipateMgService
goblinGoodsAnticipateMgService
;
public
ResponseDto
<
Boolean
>
goodsList
()
{
/**
* 在售的 已开售时间倒序
* 预约的 正序
* 售罄的 正序
*
* @return
*/
public
ResponseDto
<
Boolean
>
goodsListBack
()
{
// mongo初始条件
Query
query1
=
Query
.
query
(
Criteria
.
where
(
"skuType"
).
is
(
1
).
and
(
"delFlg"
).
is
(
"0"
)
...
...
@@ -139,6 +146,100 @@ public class GoblinNftJobServiceImpl {
return
ResponseDto
.
success
();
}
public
ResponseDto
<
Boolean
>
goodsList
()
{
// mongo初始条件
Query
query1
=
Query
.
query
(
Criteria
.
where
(
"skuType"
).
is
(
1
).
and
(
"delFlg"
).
is
(
"0"
)
.
and
(
"status"
).
is
(
"3"
).
and
(
"shelvesStatus"
).
is
(
"3"
)
.
and
(
"skuAppear"
).
is
(
"0"
)
.
orOperator
(
Criteria
.
where
(
"unbox"
).
is
(
"0"
).
and
(
"upchain"
).
is
(
1
),
Criteria
.
where
(
"unbox"
).
is
(
"1"
))
);
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
// 未开始的正序20个
query1
.
addCriteria
(
Criteria
.
where
(
"saleStartTime"
).
gt
(
nowTime
));
// 分页 排序:按照开售时间
Pageable
pageable
=
PageRequest
.
of
(
0
,
20
,
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"saleStartTime"
));
query1
.
with
(
pageable
);
// 查询
List
<
GoblinNftGoodsSkuListJobVo
>
notStartSkuInfoVos
=
mongoTemplate
.
find
(
query1
,
GoblinNftGoodsSkuListJobVo
.
class
,
GoblinGoodsSkuInfoVo
.
class
.
getSimpleName
());
// mongo初始条件
Query
query2
=
Query
.
query
(
Criteria
.
where
(
"skuType"
).
is
(
1
).
and
(
"delFlg"
).
is
(
"0"
)
.
and
(
"status"
).
is
(
"3"
).
and
(
"shelvesStatus"
).
is
(
"3"
)
.
and
(
"skuAppear"
).
is
(
"0"
)
.
orOperator
(
Criteria
.
where
(
"unbox"
).
is
(
"0"
).
and
(
"upchain"
).
is
(
1
),
Criteria
.
where
(
"unbox"
).
is
(
"1"
))
);
// 已开始的倒序80个
query2
.
addCriteria
(
Criteria
.
where
(
"saleStartTime"
).
lte
(
nowTime
));
// 分页 排序:按照开售时间
Pageable
pageable2
=
PageRequest
.
of
(
0
,
80
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"saleStartTime"
));
query2
.
with
(
pageable2
);
// 查询
List
<
GoblinNftGoodsSkuListJobVo
>
startSkuInfoVos
=
mongoTemplate
.
find
(
query2
,
GoblinNftGoodsSkuListJobVo
.
class
,
GoblinGoodsSkuInfoVo
.
class
.
getSimpleName
());
// 获取分段购真实的时间 并根据开售时间判断写入不同的vos
List
<
GoblinNftGoodsSkuListJobVo
>
notStartSkuInfoVosNew
=
ObjectUtil
.
getGoblinNftGoodsSkuListJobVoArrayList
();
List
<
GoblinNftGoodsSkuListJobVo
>
startSkuInfoVosNew
=
ObjectUtil
.
getGoblinNftGoodsSkuListJobVoArrayList
();
for
(
GoblinNftGoodsSkuListJobVo
info
:
startSkuInfoVos
)
{
HashMap
<
String
,
Object
>
mapData
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
nowTime
,
info
.
getSkuId
());
GoblinGoodsSkuInfoVo
skuInfoVo
=
(
GoblinGoodsSkuInfoVo
)
mapData
.
get
(
"vo"
);
String
listId
=
(
String
)
mapData
.
get
(
"listId"
);
info
.
setSaleStartTime
(
skuInfoVo
.
getSaleStartTime
());
info
.
setListId
(
listId
);
if
(
nowTime
.
isBefore
(
skuInfoVo
.
getSaleStartTime
()))
{
// 未开始的
notStartSkuInfoVosNew
.
add
(
info
);
}
else
{
// 已开始的
startSkuInfoVosNew
.
add
(
info
);
}
}
for
(
GoblinNftGoodsSkuListJobVo
info
:
notStartSkuInfoVos
)
{
HashMap
<
String
,
Object
>
mapData
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
nowTime
,
info
.
getSkuId
());
GoblinGoodsSkuInfoVo
skuInfoVo
=
(
GoblinGoodsSkuInfoVo
)
mapData
.
get
(
"vo"
);
String
listId
=
(
String
)
mapData
.
get
(
"listId"
);
info
.
setSaleStartTime
(
skuInfoVo
.
getSaleStartTime
());
info
.
setListId
(
listId
);
if
(
nowTime
.
isBefore
(
skuInfoVo
.
getSaleStartTime
()))
{
// 未开始的
notStartSkuInfoVosNew
.
add
(
info
);
}
else
{
// 已开始的
startSkuInfoVosNew
.
add
(
info
);
}
}
// 根据新的vos排序 未开卖 时间正序
notStartSkuInfoVosNew
=
notStartSkuInfoVosNew
.
stream
().
sorted
(
Comparator
.
comparing
(
GoblinNftGoodsSkuListJobVo:
:
getSaleStartTime
)).
collect
(
Collectors
.
toList
());
startSkuInfoVosNew
=
startSkuInfoVosNew
.
stream
().
sorted
(
Comparator
.
comparing
(
GoblinNftGoodsSkuListJobVo:
:
getSaleStartTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
// 排好序以后把id写入到不同的list
List
<
String
>
startSkuIdList
=
CollectionUtil
.
arrayListString
();
List
<
String
>
notStartSkuIdList
=
CollectionUtil
.
arrayListString
();
List
<
String
>
soldOutSkuIdList
=
CollectionUtil
.
arrayListString
();
for
(
GoblinNftGoodsSkuListJobVo
info
:
notStartSkuInfoVosNew
)
{
notStartSkuIdList
.
add
(
info
.
getSkuId
());
}
for
(
GoblinNftGoodsSkuListJobVo
info
:
startSkuInfoVosNew
)
{
List
<
String
>
skuIdList
=
CollectionUtil
.
arrayListString
();
if
(
info
.
getUnbox
().
equals
(
"1"
))
{
// 是盲盒,非盲盒少查一次spu
skuIdList
=
goblinRedisUtils
.
getGoodsInfoVo
(
info
.
getSpuId
()).
getSkuIdList
();
}
HashMap
<
String
,
Integer
>
stockHashMap
=
goblinOrderUtils
.
getIsStock
(
info
.
getListId
(),
info
.
getSkuId
(),
info
.
getUnbox
(),
info
.
getSoldoutStatus
(),
skuIdList
);
if
(
stockHashMap
.
get
(
"isStock"
)
==
1
)
{
// 已开卖-未售罄
startSkuIdList
.
add
(
info
.
getSkuId
());
}
else
{
// 已开卖-已售罄 时间正序
soldOutSkuIdList
.
add
(
info
.
getSkuId
());
}
}
// 已开卖 时间倒序
Collections
.
reverse
(
soldOutSkuIdList
);
// 写入缓存
goblinRedisUtils
.
setGoblinNftGoodsInfoListVo
(
startSkuIdList
,
"1"
);
goblinRedisUtils
.
setGoblinNftGoodsInfoListVo
(
notStartSkuIdList
,
"2"
);
goblinRedisUtils
.
setGoblinNftGoodsInfoListVo
(
soldOutSkuIdList
,
"3"
);
return
ResponseDto
.
success
();
}
/**
* 处理[未开售/开售]五分钟内的nft[优先购/分批购]库存job
*
...
...
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