商品查询参数新增 是否付费会员

This commit is contained in:
XinWei 2024-09-27 17:51:44 +08:00
parent 88ac93c477
commit 95ae012aab
5 changed files with 16 additions and 1 deletions

View File

@ -51,8 +51,12 @@ public class ProductSpuPageReqVO extends PageParam {
@Schema(description = "商品分类编号", example = "1") @Schema(description = "商品分类编号", example = "1")
private Long categoryId; private Long categoryId;
@Schema(description = "是否是付费会员", example = "1")
private Integer isPaidMember;
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") @Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
} }

View File

@ -39,6 +39,9 @@ public class AppProductSpuPageReqVO extends PageParam {
@Schema(description = "排序方式", example = "true") @Schema(description = "排序方式", example = "true")
private Boolean sortAsc; private Boolean sortAsc;
@Schema(description = "是否是付费会员", example = "1")
private Integer isPaidMember;
@AssertTrue(message = "排序字段不合法") @AssertTrue(message = "排序字段不合法")
@JsonIgnore @JsonIgnore
public boolean isSortFieldValid() { public boolean isSortFieldValid() {

View File

@ -23,4 +23,6 @@ public class AppProductSpuRecommendPageReqVo extends PageParam {
private Integer recommendNew; private Integer recommendNew;
@Schema(description = "优品推荐", example = "1") @Schema(description = "优品推荐", example = "1")
private Integer recommendGood; private Integer recommendGood;
@Schema(description = "是否是付费会员", example = "1")
private Integer isPaidMember;
} }

View File

@ -31,6 +31,7 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
.eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId())
.betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ProductSpuDO::getSort) .orderByDesc(ProductSpuDO::getSort)
.eqIfPresent(ProductSpuDO::getOnlyPaidMemberView, reqVO.getIsPaidMember())
.orderByDesc(ProductSpuDO::getId); .orderByDesc(ProductSpuDO::getId);
appendTabQuery(tabType, queryWrapper); appendTabQuery(tabType, queryWrapper);
return selectPage(reqVO, queryWrapper); return selectPage(reqVO, queryWrapper);
@ -61,7 +62,9 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
.inIfPresent(ProductSpuDO::getCategoryId, categoryIds); .inIfPresent(ProductSpuDO::getCategoryId, categoryIds);
// 上架状态 且有库存 // 上架状态 且有库存
query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus());
if (pageReqVO.getIsPaidMember() == null || pageReqVO.getIsPaidMember() == 0) {
query.eq(ProductSpuDO::getOnlyPaidMemberView, 0);
}
// 排序逻辑 // 排序逻辑
if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) { if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) {
query.last(String.format(" ORDER BY (sales_count + virtual_sales_count) %s, sort DESC, id DESC", query.last(String.format(" ORDER BY (sales_count + virtual_sales_count) %s, sort DESC, id DESC",

View File

@ -186,6 +186,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
if (recommendGood != null && recommendGood != 0){ if (recommendGood != null && recommendGood != 0){
wrapperX.eq(ProductSpuDO::getRecommendGood, recommendGood); wrapperX.eq(ProductSpuDO::getRecommendGood, recommendGood);
} }
if (pageVo.getIsPaidMember() == null || pageVo.getIsPaidMember() == 0){
wrapperX.eq(ProductSpuDO::getOnlyPaidMemberView, 0);
}
wrapperX.eq(ProductSpuDO::getStatus, 1); wrapperX.eq(ProductSpuDO::getStatus, 1);
wrapperX.last(" ORDER BY (sales_count + virtual_sales_count) DESC, sort DESC, id DESC"); wrapperX.last(" ORDER BY (sales_count + virtual_sales_count) DESC, sort DESC, id DESC");
return productSpuMapper.selectList(wrapperX); return productSpuMapper.selectList(wrapperX);