From f2f76fd3bc06aa8c29e20caaeee10c8d2781977f Mon Sep 17 00:00:00 2001 From: Yen Date: Mon, 8 Apr 2024 08:57:19 +0800 Subject: [PATCH] =?UTF-8?q?opt:=20=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=BB=B4=E5=BA=A6=E8=A7=84=E5=88=99=E6=9F=A5=E8=AF=A2=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E5=8F=98=E4=B8=BA=E5=AD=90=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/controller/GoodsSpuController.java | 19 +++--- .../serve/modules/goods/entity/GoodsSpu.java | 4 ++ .../impl/GoodsAccreditServiceImpl.java | 23 ++++---- .../resources/mapper/goods/GoodsSkuMapper.xml | 6 +- .../resources/mapper/goods/GoodsSpuMapper.xml | 58 ++++++++++++++++++- 5 files changed, 86 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java b/src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java index 79185277..27c9dde4 100644 --- a/src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java +++ b/src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java @@ -158,15 +158,16 @@ public class GoodsSpuController { private void tiSetSpuParam2(GoodsSpu param, BmsSupplier supplier) { GoodsAccrIdsDto accrIdsDto = goodsAccreditService .listIgnoreAcc2(supplier.getId(), supplier.listBizRegionIds(), supplier.listSaleRegionIds()); - List ids = goodsSkuMapper.listByOtherIds( - accrIdsDto.getCateIds(), - accrIdsDto.getSpuIds(), - accrIdsDto.getSkuIds(), - accrIdsDto.getNotInCateIds(), - accrIdsDto.getNotInSpuIds(), - accrIdsDto.getNotInSkuIds() - ); - param.setNotInSkuIds(ids); + param.setSubAccInfo(accrIdsDto); +// List ids = goodsSkuMapper.listByOtherIds( +// accrIdsDto.getCateIds(), +// accrIdsDto.getSpuIds(), +// accrIdsDto.getSkuIds(), +// accrIdsDto.getNotInCateIds(), +// accrIdsDto.getNotInSpuIds(), +// accrIdsDto.getNotInSkuIds() +// ); +// param.setNotInSkuIds(ids); } diff --git a/src/main/java/com/qs/serve/modules/goods/entity/GoodsSpu.java b/src/main/java/com/qs/serve/modules/goods/entity/GoodsSpu.java index 51f648ab..5491698c 100644 --- a/src/main/java/com/qs/serve/modules/goods/entity/GoodsSpu.java +++ b/src/main/java/com/qs/serve/modules/goods/entity/GoodsSpu.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.qs.serve.common.framework.mybatis.handler.meta.SplitStringTypeHandler; +import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto; import lombok.Data; import org.apache.ibatis.type.JdbcType; import org.hibernate.validator.constraints.Length; @@ -225,6 +226,9 @@ public class GoodsSpu implements Serializable { @TableField(exist = false) private String searchCateRuleId; + @TableField(exist = false) + private GoodsAccrIdsDto subAccInfo; + public List listCategoryIds(){ List list = new ArrayList<>(); list.add(this.getCategoryFirst()); diff --git a/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsAccreditServiceImpl.java b/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsAccreditServiceImpl.java index 7e8cf088..7da4af83 100644 --- a/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsAccreditServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsAccreditServiceImpl.java @@ -327,20 +327,20 @@ public class GoodsAccreditServiceImpl extends ServiceImpl bizRegionIds, List saleRegionIds) { //查询自身所有 LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); - lqw.select(GoodsAccreditItem::getId,GoodsAccreditItem::getAccType) + lqw.select(GoodsAccreditItem::getId,GoodsAccreditItem::getAccType,GoodsAccreditItem::getAccId) .or(a->a.eq(GoodsAccreditItem::getTargetType,"supplier").eq(GoodsAccreditItem::getTargetId,supplierId)) .or(a->a.eq(GoodsAccreditItem::getTargetType,"saleRegion").in(GoodsAccreditItem::getTargetId,saleRegionIds)) .or(a->a.eq(GoodsAccreditItem::getTargetType,"bizRegion").in(GoodsAccreditItem::getTargetId,bizRegionIds)); List selfNotInIds = goodsAccreditItemService.list(lqw).stream() - .filter(a->a.getAccType().equals(1)).map(GoodsAccreditItem::getId).collect(Collectors.toList()); + .filter(a->a.getAccType().equals(1)).map(GoodsAccreditItem::getAccId).collect(Collectors.toList()); List selfInIds = goodsAccreditItemService.list(lqw).stream() - .filter(a->a.getAccType().equals(0)).map(GoodsAccreditItem::getId).collect(Collectors.toList()); + .filter(a->a.getAccType().equals(0)).map(GoodsAccreditItem::getAccId).collect(Collectors.toList()); //查询其它维度所有in LambdaQueryWrapper lqw2 = new LambdaQueryWrapper<>(); - lqw2.select(GoodsAccreditItem::getId) + lqw2.select(GoodsAccreditItem::getAccId) .eq(GoodsAccreditItem::getAccType,0).and( qw->{ qw.or(a->a.eq(GoodsAccreditItem::getTargetType,"supplier").ne(GoodsAccreditItem::getTargetId,supplierId)) @@ -349,7 +349,7 @@ public class GoodsAccreditServiceImpl extends ServiceImpl otherInIds = goodsAccreditItemService.list(lqw2) - .stream().map(GoodsAccreditItem::getId).collect(Collectors.toList()); + .stream().map(GoodsAccreditItem::getAccId).collect(Collectors.toList()); selfNotInIds.addAll(otherInIds); List skuIds = new ArrayList<>(); @@ -380,13 +380,14 @@ public class GoodsAccreditServiceImpl extends ServiceImpl inList = this.listByIds(selfInIds); - Set spuIds2 = inList.stream().map(GoodsAccredit::getSpuId).filter(Objects::nonNull).collect(Collectors.toSet()); - Set skuIds2 = inList.stream().map(GoodsAccredit::getSkuId).filter(Objects::nonNull).collect(Collectors.toSet()); - Set cateIds2 = inList.stream().map(GoodsAccredit::getCategoryId).filter(Objects::nonNull).collect(Collectors.toSet()); - skuNotInIds.addAll(skuIds2); - spuNotInIds.addAll(spuIds2); - cateNotInIds.addAll(cateIds2); + Set spuIds3 = inList.stream().map(GoodsAccredit::getSpuId).filter(Objects::nonNull).collect(Collectors.toSet()); + Set skuIds3 = inList.stream().map(GoodsAccredit::getSkuId).filter(Objects::nonNull).collect(Collectors.toSet()); + Set cateIds3 = inList.stream().map(GoodsAccredit::getCategoryId).filter(Objects::nonNull).collect(Collectors.toSet()); + skuNotInIds.addAll(skuIds3); + spuNotInIds.addAll(spuIds3); + cateNotInIds.addAll(cateIds3); } + return new GoodsAccrIdsDto(skuIds,spuIds,cateIds,skuNotInIds,spuNotInIds,cateNotInIds); } diff --git a/src/main/resources/mapper/goods/GoodsSkuMapper.xml b/src/main/resources/mapper/goods/GoodsSkuMapper.xml index 6dcd8580..ccb68d37 100644 --- a/src/main/resources/mapper/goods/GoodsSkuMapper.xml +++ b/src/main/resources/mapper/goods/GoodsSkuMapper.xml @@ -246,17 +246,17 @@ and cate1.id not in - + #{selectId} and cate2.id not in - + #{selectId} and cate3.id not in - + #{selectId} diff --git a/src/main/resources/mapper/goods/GoodsSpuMapper.xml b/src/main/resources/mapper/goods/GoodsSpuMapper.xml index a073d34e..2efb69f0 100644 --- a/src/main/resources/mapper/goods/GoodsSpuMapper.xml +++ b/src/main/resources/mapper/goods/GoodsSpuMapper.xml @@ -90,11 +90,67 @@ ) - and `goods_spu`.`id` in + and `goods_sku`.`id` not in #{selectId} + + and `goods_sku`.`id` not in( + select sku.id FROM goods_sku sku + left join goods_spu spu on sku.spu_id = spu.id + left join goods_category cate1 on cate1.id = spu.category_first + left join goods_category cate2 on cate2.id = spu.category_second + left join goods_category cate3 on cate3.id = spu.category_third + where + ( + sku.id in + + #{selectId} + + or spu.id in + + #{selectId} + + or cate1.id in + + #{selectId} + + or cate2.id in + + #{selectId} + + or cate3.id in + + #{selectId} + + ) and + sku.id not in + + #{selectId} + + and + spu.id not in + + #{selectId} + + and + cate1.id not in + + #{selectId} + + and + cate2.id not in + + #{selectId} + + and + cate3.id not in + + #{selectId} + + ) +