记得上下班打卡 | 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
dd1f7480
Commit
dd1f7480
authored
Aug 07, 2026
by
wangyifan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c端 专题相关接口
parent
50070970
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
603 additions
and
2 deletions
+603
-2
GoblinFrontArtistTopicDetailVo.java
...service/goblin/dto/vo/GoblinFrontArtistTopicDetailVo.java
+62
-0
GoblinFrontArtistTopicHomeVo.java
...t/service/goblin/dto/vo/GoblinFrontArtistTopicHomeVo.java
+45
-0
GoblinFrontArtistTopicListPageVo.java
...rvice/goblin/dto/vo/GoblinFrontArtistTopicListPageVo.java
+48
-0
GoblinFrontArtistTopicController.java
...e/goblin/controller/GoblinFrontArtistTopicController.java
+67
-0
GoblinFrontController.java
...dnet/service/goblin/controller/GoblinFrontController.java
+17
-0
GoblinFrontArtistTopicServiceImpl.java
...oblin/service/impl/GoblinFrontArtistTopicServiceImpl.java
+305
-0
GoblinFrontServiceImpl.java
...t/service/goblin/service/impl/GoblinFrontServiceImpl.java
+59
-2
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/vo/GoblinFrontArtistTopicDetailVo.java
0 → 100644
View file @
dd1f7480
package
com
.
liquidnet
.
service
.
goblin
.
dto
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
@ApiModel
(
value
=
"GoblinFrontArtistTopicDetailVo"
,
description
=
"C端艺人专题详情"
)
@Data
public
class
GoblinFrontArtistTopicDetailVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"专题ID"
)
private
String
topicId
;
@ApiModelProperty
(
"专题名称"
)
private
String
topicName
;
@ApiModelProperty
(
"关联艺人ID"
)
private
String
artistId
;
@ApiModelProperty
(
"艺人名称"
)
private
String
artistName
;
@ApiModelProperty
(
"艺人头像"
)
private
String
avatarUrl
;
@ApiModelProperty
(
"模版类型 1双列 2单列"
)
private
Integer
templateType
;
@ApiModelProperty
(
"专题banner"
)
private
String
bannerUrl
;
@ApiModelProperty
(
"banner高度px"
)
private
Integer
bannerHeight
;
@ApiModelProperty
(
"上架区间开始"
)
private
LocalDateTime
onSaleStart
;
@ApiModelProperty
(
"上架区间结束"
)
private
LocalDateTime
onSaleEnd
;
@ApiModelProperty
(
"商品列表(仅已上架可售)"
)
private
List
<
GoodsItem
>
goods
=
new
ArrayList
<>();
@Data
public
static
class
GoodsItem
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"商品SPU ID"
)
private
String
spuId
;
@ApiModelProperty
(
"商品名称"
)
private
String
name
;
@ApiModelProperty
(
"商品头图"
)
private
String
coverPic
;
@ApiModelProperty
(
"销售价"
)
private
BigDecimal
sellPrice
;
@ApiModelProperty
(
"价格区间MIN"
)
private
BigDecimal
priceGe
;
@ApiModelProperty
(
"价格区间MAX"
)
private
BigDecimal
priceLe
;
@ApiModelProperty
(
"专题内排序"
)
private
Integer
sort
;
}
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/vo/GoblinFrontArtistTopicHomeVo.java
0 → 100644
View file @
dd1f7480
package
com
.
liquidnet
.
service
.
goblin
.
dto
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
@ApiModel
(
value
=
"GoblinFrontArtistTopicHomeVo"
,
description
=
"C端艺人专题首页入口"
)
@Data
public
class
GoblinFrontArtistTopicHomeVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"推荐位专题(按推荐号位升序)"
)
private
List
<
TopicItem
>
topics
=
new
ArrayList
<>();
@ApiModelProperty
(
"可见专题总数(更多入口)"
)
private
long
total
;
@Data
public
static
class
TopicItem
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"专题ID"
)
private
String
topicId
;
@ApiModelProperty
(
"专题名称"
)
private
String
topicName
;
@ApiModelProperty
(
"专题banner"
)
private
String
bannerUrl
;
@ApiModelProperty
(
"banner高度px"
)
private
Integer
bannerHeight
;
@ApiModelProperty
(
"推荐号位1~5"
)
private
Integer
recommendPosition
;
@ApiModelProperty
(
"关联艺人ID"
)
private
String
artistId
;
@ApiModelProperty
(
"艺人名称"
)
private
String
artistName
;
@ApiModelProperty
(
"艺人头像"
)
private
String
avatarUrl
;
}
}
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/vo/GoblinFrontArtistTopicListPageVo.java
0 → 100644
View file @
dd1f7480
package
com
.
liquidnet
.
service
.
goblin
.
dto
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
@ApiModel
(
value
=
"GoblinFrontArtistTopicListPageVo"
,
description
=
"C端艺人专题列表分页"
)
@Data
public
class
GoblinFrontArtistTopicListPageVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"页码"
)
private
int
page
;
@ApiModelProperty
(
"每页条数"
)
private
int
size
;
@ApiModelProperty
(
"总数"
)
private
long
total
;
@ApiModelProperty
(
"专题列表"
)
private
List
<
TopicItem
>
list
=
new
ArrayList
<>();
@Data
public
static
class
TopicItem
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"专题ID"
)
private
String
topicId
;
@ApiModelProperty
(
"专题名称"
)
private
String
topicName
;
@ApiModelProperty
(
"专题banner"
)
private
String
bannerUrl
;
@ApiModelProperty
(
"banner高度px"
)
private
Integer
bannerHeight
;
@ApiModelProperty
(
"推荐号位1~5"
)
private
Integer
recommendPosition
;
@ApiModelProperty
(
"关联艺人ID"
)
private
String
artistId
;
@ApiModelProperty
(
"艺人名称"
)
private
String
artistName
;
@ApiModelProperty
(
"艺人头像"
)
private
String
avatarUrl
;
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/GoblinFrontArtistTopicController.java
0 → 100644
View file @
dd1f7480
package
com
.
liquidnet
.
service
.
goblin
.
controller
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.goblin.dto.vo.GoblinFrontArtistTopicDetailVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinFrontArtistTopicHomeVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinFrontArtistTopicListPageVo
;
import
com.liquidnet.service.goblin.service.impl.GoblinFrontArtistTopicServiceImpl
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
/**
* C 端-艺人专题(周边商城)
*/
@Api
(
tags
=
"C端艺人专题"
)
@Slf4j
@Validated
@RestController
@RequestMapping
(
"front/artistTopic"
)
public
class
GoblinFrontArtistTopicController
{
@Autowired
private
GoblinFrontArtistTopicServiceImpl
artistTopicService
;
@GetMapping
(
"home"
)
@ApiOperation
(
"首页入口(推荐位专题+更多)"
)
public
ResponseDto
<
GoblinFrontArtistTopicHomeVo
>
home
()
{
return
artistTopicService
.
home
();
}
@GetMapping
(
"list"
)
@ApiOperation
(
"专题列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
dataType
=
"int"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页条数"
,
dataType
=
"int"
,
required
=
true
),
})
public
ResponseDto
<
GoblinFrontArtistTopicListPageVo
>
list
(
@Min
(
1
)
@RequestParam
(
defaultValue
=
"1"
)
int
page
,
@Min
(
1
)
@RequestParam
(
defaultValue
=
"20"
)
int
size
)
{
return
artistTopicService
.
list
(
page
,
size
);
}
@GetMapping
(
"detail"
)
@ApiOperation
(
"专题详情(商品支持 default/price 排序)"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"topicId"
,
value
=
"专题ID"
,
dataType
=
"String"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"sortType"
,
value
=
"商品排序 default-默认排序 price-价格排序"
,
dataType
=
"String"
,
allowableValues
=
"default,price"
),
@ApiImplicitParam
(
name
=
"sortOrder"
,
value
=
"价格排序方向 asc-升序 desc-降序(sortType=price时生效)"
,
dataType
=
"String"
,
allowableValues
=
"asc,desc"
),
})
public
ResponseDto
<
GoblinFrontArtistTopicDetailVo
>
detail
(
@NotBlank
(
message
=
"专题ID不能为空"
)
@RequestParam
String
topicId
,
@RequestParam
(
required
=
false
,
defaultValue
=
"default"
)
String
sortType
,
@RequestParam
(
required
=
false
,
defaultValue
=
"asc"
)
String
sortOrder
)
{
return
artistTopicService
.
detail
(
topicId
,
sortType
,
sortOrder
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/GoblinFrontController.java
View file @
dd1f7480
package
com
.
liquidnet
.
service
.
goblin
.
controller
;
package
com
.
liquidnet
.
service
.
goblin
.
controller
;
import
com.github.pagehelper.PageInfo
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
...
@@ -74,6 +75,22 @@ public class GoblinFrontController {
...
@@ -74,6 +75,22 @@ public class GoblinFrontController {
return
ResponseDto
.
success
(
goblinFrontService
.
getSelectGoods
(
pageNumber
,
pageSize
));
return
ResponseDto
.
success
(
goblinFrontService
.
getSelectGoods
(
pageNumber
,
pageSize
));
}
}
@GetMapping
(
"getSelectGoodsPage"
)
@ApiOperation
(
"商城商品真分页列表(page从1开始)"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码,从1开始"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页条数"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"sortType"
,
value
=
"排序类型 default-默认排序 price-价格排序"
,
dataType
=
"String"
,
allowableValues
=
"default,price"
),
@ApiImplicitParam
(
name
=
"sortOrder"
,
value
=
"价格排序方向 asc-升序 desc-降序(sortType=price时生效)"
,
dataType
=
"String"
,
allowableValues
=
"asc,desc"
),
})
public
ResponseDto
<
PageInfo
<
GoblinGoodsInfoVo
>>
getSelectGoodsPage
(
@RequestParam
(
name
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
,
@RequestParam
(
name
=
"pageSize"
,
required
=
false
,
defaultValue
=
"20"
)
int
pageSize
,
@RequestParam
(
name
=
"sortType"
,
required
=
false
,
defaultValue
=
"default"
)
String
sortType
,
@RequestParam
(
name
=
"sortOrder"
,
required
=
false
,
defaultValue
=
"asc"
)
String
sortOrder
)
{
return
ResponseDto
.
success
(
goblinFrontService
.
getSelectGoodsPage
(
page
,
pageSize
,
sortType
,
sortOrder
));
}
@GetMapping
(
"getGoodsDetail"
)
@GetMapping
(
"getGoodsDetail"
)
@ApiOperation
(
"获得商品详情"
)
@ApiOperation
(
"获得商品详情"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinFrontArtistTopicServiceImpl.java
0 → 100644
View file @
dd1f7480
package
com
.
liquidnet
.
service
.
goblin
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.goblin.constant.GoblinArtistConst
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
import
com.liquidnet.service.goblin.dto.vo.GoblinArtistAuthApplyVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinArtistTopicVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinFrontArtistTopicDetailVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinFrontArtistTopicHomeVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinFrontArtistTopicListPageVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
import
com.liquidnet.service.kylin.entity.KylinArtist
;
import
com.liquidnet.service.kylin.mapper.KylinArtistMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
* C 端艺人专题(读路径:Redis → MongoDB)
*/
@Service
@Slf4j
public
class
GoblinFrontArtistTopicServiceImpl
{
private
static
final
long
TOPIC_TTL
=
86400L
;
private
static
final
String
SORT_PRICE
=
"price"
;
private
static
final
String
ORDER_DESC
=
"desc"
;
private
static
final
int
RECOMMEND_MIN
=
1
;
private
static
final
int
RECOMMEND_MAX
=
5
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
GoblinRedisUtils
goblinRedisUtils
;
@Autowired
private
KylinArtistMapper
kylinArtistMapper
;
// ======================== 首页入口 ========================
public
ResponseDto
<
GoblinFrontArtistTopicHomeVo
>
home
()
{
List
<
GoblinArtistTopicVo
>
visible
=
visibleTopics
();
List
<
GoblinArtistTopicVo
>
recommended
=
visible
.
stream
()
.
filter
(
t
->
t
.
getRecommendPosition
()
!=
null
&&
t
.
getRecommendPosition
()
>=
RECOMMEND_MIN
&&
t
.
getRecommendPosition
()
<=
RECOMMEND_MAX
)
.
sorted
(
Comparator
.
comparing
(
GoblinArtistTopicVo:
:
getRecommendPosition
))
.
collect
(
Collectors
.
toList
());
GoblinFrontArtistTopicHomeVo
vo
=
new
GoblinFrontArtistTopicHomeVo
();
vo
.
setTotal
(
visible
.
size
());
vo
.
setTopics
(
buildHomeItems
(
recommended
));
return
ResponseDto
.
success
(
vo
);
}
// ======================== 专题列表 ========================
public
ResponseDto
<
GoblinFrontArtistTopicListPageVo
>
list
(
int
page
,
int
size
)
{
List
<
GoblinArtistTopicVo
>
visible
=
visibleTopics
();
int
from
=
Math
.
min
((
page
-
1
)
*
size
,
visible
.
size
());
int
to
=
Math
.
min
(
from
+
size
,
visible
.
size
());
GoblinFrontArtistTopicListPageVo
vo
=
new
GoblinFrontArtistTopicListPageVo
();
vo
.
setPage
(
page
);
vo
.
setSize
(
size
);
vo
.
setTotal
(
visible
.
size
());
vo
.
setList
(
buildListItems
(
visible
.
subList
(
from
,
to
)));
return
ResponseDto
.
success
(
vo
);
}
// ======================== 专题详情 ========================
public
ResponseDto
<
GoblinFrontArtistTopicDetailVo
>
detail
(
String
topicId
,
String
sortType
,
String
sortOrder
)
{
GoblinArtistTopicVo
topic
=
loadTopic
(
topicId
);
if
(
topic
==
null
||
!
isVisible
(
topic
))
{
return
ResponseDto
.
failure
(
"专题不存在"
);
}
GoblinFrontArtistTopicDetailVo
vo
=
new
GoblinFrontArtistTopicDetailVo
();
vo
.
setTopicId
(
topic
.
getTopicId
());
vo
.
setTopicName
(
topic
.
getTopicName
());
vo
.
setArtistId
(
topic
.
getArtistId
());
vo
.
setTemplateType
(
topic
.
getTemplateType
());
vo
.
setBannerUrl
(
topic
.
getBannerUrl
());
vo
.
setBannerHeight
(
topic
.
getBannerHeight
());
vo
.
setOnSaleStart
(
topic
.
getOnSaleStart
());
vo
.
setOnSaleEnd
(
topic
.
getOnSaleEnd
());
if
(
StringUtils
.
isNotBlank
(
topic
.
getArtistId
()))
{
KylinArtist
artist
=
kylinArtistMapper
.
selectOne
(
new
LambdaQueryWrapper
<
KylinArtist
>()
.
eq
(
KylinArtist:
:
getArtistId
,
topic
.
getArtistId
())
.
last
(
"limit 1"
));
if
(
artist
!=
null
)
{
vo
.
setArtistName
(
artist
.
getArtistName
());
vo
.
setAvatarUrl
(
artist
.
getAvatarUrl
());
}
}
vo
.
setGoods
(
buildGoods
(
topic
.
getGoods
(),
sortType
,
sortOrder
));
return
ResponseDto
.
success
(
vo
);
}
// ======================== 私有:可见专题 ========================
/** 已上架 + 未删除 + 上架区间内 + 艺人授权有效;sort ASC, createdAt DESC */
private
List
<
GoblinArtistTopicVo
>
visibleTopics
()
{
LocalDateTime
now
=
LocalDateTime
.
now
();
Query
query
=
new
Query
(
Criteria
.
where
(
"status"
).
is
(
GoblinArtistConst
.
TOPIC_ONLINE
)
.
and
(
"delFlg"
).
is
(
GoblinArtistConst
.
DEL_NO
)
.
andOperator
(
saleWindowCriteria
(
now
)));
query
.
with
(
Sort
.
by
(
Sort
.
Order
.
asc
(
"sort"
),
Sort
.
Order
.
desc
(
"createdAt"
)));
List
<
GoblinArtistTopicVo
>
topics
=
mongoTemplate
.
find
(
query
,
GoblinArtistTopicVo
.
class
,
GoblinArtistTopicVo
.
class
.
getSimpleName
());
Set
<
String
>
authSet
=
validAuthSet
(
topics
,
now
);
return
topics
.
stream
()
.
filter
(
t
->
StringUtils
.
isBlank
(
t
.
getArtistId
())
||
authSet
.
contains
(
t
.
getStoreId
()
+
"_"
+
t
.
getArtistId
()))
.
collect
(
Collectors
.
toList
());
}
private
boolean
isVisible
(
GoblinArtistTopicVo
topic
)
{
if
(!
Objects
.
equals
(
topic
.
getStatus
(),
GoblinArtistConst
.
TOPIC_ONLINE
)
||
!
Objects
.
equals
(
topic
.
getDelFlg
(),
GoblinArtistConst
.
DEL_NO
))
{
return
false
;
}
LocalDateTime
now
=
LocalDateTime
.
now
();
if
(!
withinSaleWindow
(
topic
,
now
))
{
return
false
;
}
return
StringUtils
.
isBlank
(
topic
.
getArtistId
())
||
!
validAuthSet
(
Collections
.
singletonList
(
topic
),
now
).
isEmpty
();
}
/** 上架区间:开始为空或已到,结束为空或未过 */
private
Criteria
saleWindowCriteria
(
LocalDateTime
now
)
{
return
new
Criteria
().
andOperator
(
new
Criteria
().
orOperator
(
Criteria
.
where
(
"onSaleStart"
).
is
(
null
),
Criteria
.
where
(
"onSaleStart"
).
lte
(
now
)),
new
Criteria
().
orOperator
(
Criteria
.
where
(
"onSaleEnd"
).
is
(
null
),
Criteria
.
where
(
"onSaleEnd"
).
gte
(
now
)));
}
private
boolean
withinSaleWindow
(
GoblinArtistTopicVo
topic
,
LocalDateTime
now
)
{
return
(
topic
.
getOnSaleStart
()
==
null
||
!
topic
.
getOnSaleStart
().
isAfter
(
now
))
&&
(
topic
.
getOnSaleEnd
()
==
null
||
!
topic
.
getOnSaleEnd
().
isBefore
(
now
));
}
/** 有效授权(申请已通过且未过期)的 storeId_artistId 集合 */
private
Set
<
String
>
validAuthSet
(
List
<
GoblinArtistTopicVo
>
topics
,
LocalDateTime
now
)
{
List
<
String
>
artistIds
=
topics
.
stream
()
.
map
(
GoblinArtistTopicVo:
:
getArtistId
)
.
filter
(
StringUtils:
:
isNotBlank
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
artistIds
.
isEmpty
())
{
return
Collections
.
emptySet
();
}
List
<
GoblinArtistAuthApplyVo
>
auths
=
mongoTemplate
.
find
(
new
Query
(
Criteria
.
where
(
"status"
).
is
(
GoblinArtistConst
.
APPLY_APPROVED
)
.
and
(
"authExpireAt"
).
gt
(
now
)
.
and
(
"artistId"
).
in
(
artistIds
)),
GoblinArtistAuthApplyVo
.
class
,
GoblinArtistAuthApplyVo
.
class
.
getSimpleName
());
return
auths
.
stream
()
.
map
(
a
->
a
.
getStoreId
()
+
"_"
+
a
.
getArtistId
())
.
collect
(
Collectors
.
toSet
());
}
// ======================== 私有:详情读取 ========================
/** Redis 缓存 → MongoDB 回源(对齐 B 端 loadTopic,C 端不限店铺) */
private
GoblinArtistTopicVo
loadTopic
(
String
topicId
)
{
String
redisKey
=
GoblinRedisConst
.
ARTIST_TOPIC
+
topicId
;
Object
cached
=
goblinRedisUtils
.
get
(
redisKey
);
if
(
cached
instanceof
GoblinArtistTopicVo
)
{
GoblinArtistTopicVo
topic
=
(
GoblinArtistTopicVo
)
cached
;
return
Objects
.
equals
(
topic
.
getDelFlg
(),
GoblinArtistConst
.
DEL_NO
)
?
topic
:
null
;
}
GoblinArtistTopicVo
topic
=
mongoTemplate
.
findOne
(
new
Query
(
Criteria
.
where
(
"topicId"
).
is
(
topicId
)
.
and
(
"delFlg"
).
is
(
GoblinArtistConst
.
DEL_NO
)),
GoblinArtistTopicVo
.
class
,
GoblinArtistTopicVo
.
class
.
getSimpleName
());
if
(
topic
!=
null
)
{
goblinRedisUtils
.
set
(
redisKey
,
topic
,
TOPIC_TTL
);
}
return
topic
;
}
/** 内嵌商品实时校验可售,name/图/价取实时值;支持默认/价格排序 */
private
List
<
GoblinFrontArtistTopicDetailVo
.
GoodsItem
>
buildGoods
(
List
<
GoblinArtistTopicVo
.
GoodsItem
>
embedded
,
String
sortType
,
String
sortOrder
)
{
List
<
GoblinFrontArtistTopicDetailVo
.
GoodsItem
>
goods
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isEmpty
(
embedded
))
{
return
goods
;
}
for
(
GoblinArtistTopicVo
.
GoodsItem
item
:
embedded
)
{
GoblinGoodsInfoVo
info
=
goblinRedisUtils
.
getGoodsInfoVo
(
item
.
getSpuId
());
if
(!
isSaleable
(
info
))
{
continue
;
}
GoblinFrontArtistTopicDetailVo
.
GoodsItem
good
=
new
GoblinFrontArtistTopicDetailVo
.
GoodsItem
();
good
.
setSpuId
(
info
.
getSpuId
());
good
.
setName
(
info
.
getName
());
good
.
setCoverPic
(
info
.
getCoverPic
());
good
.
setSellPrice
(
info
.
getSellPrice
());
good
.
setPriceGe
(
info
.
getPriceGe
());
good
.
setPriceLe
(
info
.
getPriceLe
());
good
.
setSort
(
item
.
getSort
());
goods
.
add
(
good
);
}
if
(
SORT_PRICE
.
equals
(
sortType
))
{
Comparator
<
BigDecimal
>
priceCmp
=
ORDER_DESC
.
equals
(
sortOrder
)
?
Comparator
.
nullsLast
(
Comparator
.
reverseOrder
())
:
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
());
goods
.
sort
(
Comparator
.
comparing
(
GoblinFrontArtistTopicDetailVo
.
GoodsItem
::
getPriceGe
,
priceCmp
));
}
else
{
goods
.
sort
(
Comparator
.
comparing
(
GoblinFrontArtistTopicDetailVo
.
GoodsItem
::
getSort
,
Comparator
.
nullsLast
(
Comparator
.
naturalOrder
())));
}
return
goods
;
}
/** 可售口径对齐 C 端现有商品列表:未删除 + 已上架 + 非隐藏 */
private
boolean
isSaleable
(
GoblinGoodsInfoVo
info
)
{
return
info
!=
null
&&
"0"
.
equals
(
info
.
getDelFlg
())
&&
"3"
.
equals
(
info
.
getShelvesStatus
())
&&
"0"
.
equals
(
info
.
getSpuAppear
());
}
// ======================== 私有:列表项组装 ========================
private
Map
<
String
,
KylinArtist
>
artistMap
(
List
<
GoblinArtistTopicVo
>
topics
)
{
List
<
String
>
artistIds
=
topics
.
stream
()
.
map
(
GoblinArtistTopicVo:
:
getArtistId
)
.
filter
(
StringUtils:
:
isNotBlank
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
artistIds
.
isEmpty
())
{
return
Collections
.
emptyMap
();
}
return
kylinArtistMapper
.
selectList
(
new
LambdaQueryWrapper
<
KylinArtist
>()
.
in
(
KylinArtist:
:
getArtistId
,
artistIds
))
.
stream
()
.
collect
(
Collectors
.
toMap
(
KylinArtist:
:
getArtistId
,
a
->
a
,
(
a
,
b
)
->
a
));
}
private
List
<
GoblinFrontArtistTopicHomeVo
.
TopicItem
>
buildHomeItems
(
List
<
GoblinArtistTopicVo
>
topics
)
{
Map
<
String
,
KylinArtist
>
artistMap
=
artistMap
(
topics
);
return
topics
.
stream
().
map
(
t
->
{
GoblinFrontArtistTopicHomeVo
.
TopicItem
item
=
new
GoblinFrontArtistTopicHomeVo
.
TopicItem
();
item
.
setTopicId
(
t
.
getTopicId
());
item
.
setTopicName
(
t
.
getTopicName
());
item
.
setBannerUrl
(
t
.
getBannerUrl
());
item
.
setBannerHeight
(
t
.
getBannerHeight
());
item
.
setRecommendPosition
(
t
.
getRecommendPosition
());
item
.
setArtistId
(
t
.
getArtistId
());
KylinArtist
artist
=
artistMap
.
get
(
t
.
getArtistId
());
if
(
artist
!=
null
)
{
item
.
setArtistName
(
artist
.
getArtistName
());
item
.
setAvatarUrl
(
artist
.
getAvatarUrl
());
}
return
item
;
}).
collect
(
Collectors
.
toList
());
}
private
List
<
GoblinFrontArtistTopicListPageVo
.
TopicItem
>
buildListItems
(
List
<
GoblinArtistTopicVo
>
topics
)
{
Map
<
String
,
KylinArtist
>
artistMap
=
artistMap
(
topics
);
return
topics
.
stream
().
map
(
t
->
{
GoblinFrontArtistTopicListPageVo
.
TopicItem
item
=
new
GoblinFrontArtistTopicListPageVo
.
TopicItem
();
item
.
setTopicId
(
t
.
getTopicId
());
item
.
setTopicName
(
t
.
getTopicName
());
item
.
setBannerUrl
(
t
.
getBannerUrl
());
item
.
setBannerHeight
(
t
.
getBannerHeight
());
item
.
setRecommendPosition
(
t
.
getRecommendPosition
());
item
.
setArtistId
(
t
.
getArtistId
());
KylinArtist
artist
=
artistMap
.
get
(
t
.
getArtistId
());
if
(
artist
!=
null
)
{
item
.
setArtistName
(
artist
.
getArtistName
());
item
.
setAvatarUrl
(
artist
.
getAvatarUrl
());
}
return
item
;
}).
collect
(
Collectors
.
toList
());
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinFrontServiceImpl.java
View file @
dd1f7480
...
@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.service.impl;
...
@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.github.pagehelper.PageInfo
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.commons.lang.util.*
;
...
@@ -1027,8 +1028,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
...
@@ -1027,8 +1028,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
if
(
StringUtil
.
isNotBlank
(
spuids
))
{
if
(
StringUtil
.
isNotBlank
(
spuids
))
{
query
.
addCriteria
(
Criteria
.
where
(
"spuId"
).
nin
(
spuids
.
split
(
","
)));
query
.
addCriteria
(
Criteria
.
where
(
"spuId"
).
nin
(
spuids
.
split
(
","
)));
}
}
query
.
addCriteria
(
Criteria
.
where
(
"delFlg"
).
is
(
"0"
).
and
(
"shelvesStatus"
).
is
(
"3"
).
and
(
"spuAppear"
).
is
(
"0"
).
and
(
"marketId"
).
is
(
null
)
query
.
addCriteria
(
selectGoodsCriteria
());
.
and
(
"spuType"
).
ne
(
33
).
and
(
"showInMall"
).
ne
(
0
).
and
(
"cateFid"
).
nin
(
"22196120924543"
,
"22196122839313"
).
and
(
"name"
).
not
().
regex
(
Pattern
.
compile
(
SELECT_GOODS_EXCLUDE_NAME
)));
//redis里面获取排序规则 1、上架时间2、销量3、价格高到低4、价格低到高
//redis里面获取排序规则 1、上架时间2、销量3、价格高到低4、价格低到高
...
@@ -1318,6 +1318,63 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
...
@@ -1318,6 +1318,63 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
// return null;
// return null;
}
}
/**
* 商城商品真分页列表:sortType default-后台配置排序 price-价格排序(page 从1开始)
*/
public
PageInfo
<
GoblinGoodsInfoVo
>
getSelectGoodsPage
(
int
page
,
int
pageSize
,
String
sortType
,
String
sortOrder
)
{
Query
query
=
new
Query
(
selectGoodsCriteria
());
long
total
=
mongoTemplate
.
count
(
query
,
GoblinGoodsInfoVo
.
class
,
GoblinGoodsInfoVo
.
class
.
getSimpleName
());
Sort
sort
;
if
(
"price"
.
equals
(
sortType
))
{
Sort
.
Direction
direction
=
"desc"
.
equals
(
sortOrder
)
?
Sort
.
Direction
.
DESC
:
Sort
.
Direction
.
ASC
;
sort
=
Sort
.
by
(
direction
,
"priceGe"
);
query
.
collation
(
numericCollation
());
}
else
{
sort
=
configSort
(
query
);
}
query
.
with
(
PageRequest
.
of
(
Math
.
max
(
page
-
1
,
0
),
pageSize
,
sort
));
List
<
GoblinGoodsInfoVo
>
list
=
mongoTemplate
.
find
(
query
,
GoblinGoodsInfoVo
.
class
,
GoblinGoodsInfoVo
.
class
.
getSimpleName
());
PageInfo
<
GoblinGoodsInfoVo
>
pageInfo
=
new
PageInfo
<>(
list
);
pageInfo
.
setPageNum
(
page
);
pageInfo
.
setPageSize
(
pageSize
);
pageInfo
.
setTotal
(
total
);
pageInfo
.
setPages
((
int
)
((
total
+
pageSize
-
1
)
/
pageSize
));
return
pageInfo
;
}
/** 后台配置排序规则 1、上架时间 2、销量 3、价格高到低 4、价格低到高(同 getspuId) */
private
Sort
configSort
(
Query
query
)
{
int
sortType
=
0
;
if
(
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS_SORT
))
{
sortType
=
(
int
)
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS_SORT
);
}
if
(
sortType
==
1
)
{
return
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"shelvesAt"
);
}
if
(
sortType
==
2
)
{
return
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"count"
,
"createdAt"
);
}
query
.
collation
(
numericCollation
());
return
sortType
==
3
?
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"priceGe"
)
:
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"priceGe"
);
}
/** 数值排序 collation(priceGe 字符串存储) */
private
Collation
numericCollation
()
{
Document
source
=
new
Document
();
source
.
put
(
"locale"
,
"zh"
);
source
.
put
(
"numericOrdering"
,
true
);
return
Collation
.
from
(
source
);
}
/** 精选商品过滤口径(与存量精选/首页货架一致) */
private
Criteria
selectGoodsCriteria
()
{
return
Criteria
.
where
(
"delFlg"
).
is
(
"0"
).
and
(
"shelvesStatus"
).
is
(
"3"
).
and
(
"spuAppear"
).
is
(
"0"
).
and
(
"marketId"
).
is
(
null
)
.
and
(
"spuType"
).
ne
(
33
).
and
(
"showInMall"
).
ne
(
0
).
and
(
"cateFid"
).
nin
(
"22196120924543"
,
"22196122839313"
)
.
and
(
"name"
).
not
().
regex
(
Pattern
.
compile
(
SELECT_GOODS_EXCLUDE_NAME
));
}
@Override
@Override
public
GoblinSqbPerformanceSelectGoodVo
getPerformanceSelectGoods
(
String
performancesId
,
int
page
,
int
pageSize
)
{
public
GoblinSqbPerformanceSelectGoodVo
getPerformanceSelectGoods
(
String
performancesId
,
int
page
,
int
pageSize
)
{
GoblinSqbPerformanceSelectGoodVo
respVo
=
GoblinSqbPerformanceSelectGoodVo
.
getNew
();
GoblinSqbPerformanceSelectGoodVo
respVo
=
GoblinSqbPerformanceSelectGoodVo
.
getNew
();
...
...
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