|
@ -13,21 +13,16 @@ import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; |
|
|
import com.qs.serve.modules.goods.entity.*; |
|
|
import com.qs.serve.modules.goods.entity.*; |
|
|
import com.qs.serve.modules.goods.entity.bo.GoodsAccreditBo; |
|
|
import com.qs.serve.modules.goods.entity.bo.GoodsAccreditBo; |
|
|
|
|
|
import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto; |
|
|
import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo; |
|
|
import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo; |
|
|
import com.qs.serve.modules.goods.mapper.GoodsAccreditItemMapper; |
|
|
import com.qs.serve.modules.goods.mapper.*; |
|
|
import com.qs.serve.modules.goods.mapper.GoodsCategoryMapper; |
|
|
|
|
|
import com.qs.serve.modules.goods.mapper.GoodsSpuMapper; |
|
|
|
|
|
import com.qs.serve.modules.goods.service.GoodsAccreditItemService; |
|
|
import com.qs.serve.modules.goods.service.GoodsAccreditItemService; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import com.qs.serve.modules.goods.service.GoodsAccreditService; |
|
|
import com.qs.serve.modules.goods.service.GoodsAccreditService; |
|
|
import com.qs.serve.modules.goods.mapper.GoodsAccreditMapper; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.*; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -42,10 +37,12 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
|
|
|
|
|
|
private final GoodsCategoryMapper categoryMapper; |
|
|
private final GoodsCategoryMapper categoryMapper; |
|
|
private final GoodsSpuMapper goodsSpuMapper; |
|
|
private final GoodsSpuMapper goodsSpuMapper; |
|
|
|
|
|
private final GoodsSkuMapper goodsSkuMapper; |
|
|
|
|
|
|
|
|
private final BmsRegionMapper regionMapper; |
|
|
private final BmsRegionMapper regionMapper; |
|
|
private final BmsRegion2Mapper region2Mapper; |
|
|
private final BmsRegion2Mapper region2Mapper; |
|
|
private final BmsSupplierMapper supplierMapper; |
|
|
private final BmsSupplierMapper supplierMapper; |
|
|
|
|
|
private final GoodsSpuMapper spuMapper; |
|
|
|
|
|
|
|
|
private final GoodsAccreditItemService goodsAccreditItemService; |
|
|
private final GoodsAccreditItemService goodsAccreditItemService; |
|
|
|
|
|
|
|
@ -326,6 +323,105 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
return this.listByIds(accIds); |
|
|
return this.listByIds(accIds); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public GoodsAccrIdsDto listIgnoreAcc2(String supplierId, List<String> bizRegionIds, List<String> saleRegionIds) { |
|
|
|
|
|
//查询自身所有
|
|
|
|
|
|
LambdaQueryWrapper<GoodsAccreditItem> lqw = new LambdaQueryWrapper<>(); |
|
|
|
|
|
lqw.select(GoodsAccreditItem::getId,GoodsAccreditItem::getAccType) |
|
|
|
|
|
.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<Long> selfNotInIds = goodsAccreditItemService.list(lqw).stream() |
|
|
|
|
|
.filter(a->a.getAccType().equals(1)).map(GoodsAccreditItem::getId).collect(Collectors.toList()); |
|
|
|
|
|
List<Long> selfInIds = goodsAccreditItemService.list(lqw).stream() |
|
|
|
|
|
.filter(a->a.getAccType().equals(0)).map(GoodsAccreditItem::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询其它维度所有in
|
|
|
|
|
|
LambdaQueryWrapper<GoodsAccreditItem> lqw2 = new LambdaQueryWrapper<>(); |
|
|
|
|
|
lqw2.select(GoodsAccreditItem::getId) |
|
|
|
|
|
.eq(GoodsAccreditItem::getAccType,0).and( |
|
|
|
|
|
qw->{ |
|
|
|
|
|
qw.or(a->a.eq(GoodsAccreditItem::getTargetType,"supplier").ne(GoodsAccreditItem::getTargetId,supplierId)) |
|
|
|
|
|
.or(a->a.eq(GoodsAccreditItem::getTargetType,"saleRegion").notIn(GoodsAccreditItem::getTargetId,saleRegionIds)) |
|
|
|
|
|
.or(a->a.eq(GoodsAccreditItem::getTargetType,"bizRegion").notIn(GoodsAccreditItem::getTargetId,bizRegionIds)); |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
List<Long> otherInIds = goodsAccreditItemService.list(lqw2) |
|
|
|
|
|
.stream().map(GoodsAccreditItem::getId).collect(Collectors.toList()); |
|
|
|
|
|
selfNotInIds.addAll(otherInIds); |
|
|
|
|
|
|
|
|
|
|
|
List<Long> skuIds = new ArrayList<>(); |
|
|
|
|
|
List<Long> spuIds = new ArrayList<>(); |
|
|
|
|
|
List<String> cateIds = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
List<Long> skuNotInIds = new ArrayList<>(); |
|
|
|
|
|
List<Long> spuNotInIds = new ArrayList<>(); |
|
|
|
|
|
List<String> cateNotInIds = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
//设置默认值 防止空in
|
|
|
|
|
|
skuIds.add(-1000L); |
|
|
|
|
|
spuIds.add(-1000L); |
|
|
|
|
|
cateIds.add("-999"); |
|
|
|
|
|
skuNotInIds.add(-1000L); |
|
|
|
|
|
spuNotInIds.add(-1000L); |
|
|
|
|
|
cateNotInIds.add("-999"); |
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(selfNotInIds)){ |
|
|
|
|
|
List<GoodsAccredit> notInList = this.listByIds(selfNotInIds); |
|
|
|
|
|
Set<Long> spuIds2 = notInList.stream().map(GoodsAccredit::getSpuId).filter(Objects::nonNull).collect(Collectors.toSet()); |
|
|
|
|
|
Set<Long> skuIds2 = notInList.stream().map(GoodsAccredit::getSkuId).filter(Objects::nonNull).collect(Collectors.toSet()); |
|
|
|
|
|
Set<String> cateIds2 = notInList.stream().map(GoodsAccredit::getCategoryId).filter(Objects::nonNull).collect(Collectors.toSet()); |
|
|
|
|
|
skuIds.addAll(skuIds2); |
|
|
|
|
|
spuIds.addAll(spuIds2); |
|
|
|
|
|
cateIds.addAll(cateIds2); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(selfInIds)){ |
|
|
|
|
|
List<GoodsAccredit> inList = this.listByIds(selfInIds); |
|
|
|
|
|
Set<Long> spuIds2 = inList.stream().map(GoodsAccredit::getSpuId).filter(Objects::nonNull).collect(Collectors.toSet()); |
|
|
|
|
|
Set<Long> skuIds2 = inList.stream().map(GoodsAccredit::getSkuId).filter(Objects::nonNull).collect(Collectors.toSet()); |
|
|
|
|
|
Set<String> cateIds2 = inList.stream().map(GoodsAccredit::getCategoryId).filter(Objects::nonNull).collect(Collectors.toSet()); |
|
|
|
|
|
skuNotInIds.addAll(skuIds2); |
|
|
|
|
|
spuNotInIds.addAll(spuIds2); |
|
|
|
|
|
cateNotInIds.addAll(cateIds2); |
|
|
|
|
|
} |
|
|
|
|
|
return new GoodsAccrIdsDto(skuIds,spuIds,cateIds,skuNotInIds,spuNotInIds,cateNotInIds); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean checkSkuCode(List<Long> spuIds, List<GoodsAccredit> accreditList, boolean throwEx) { |
|
|
|
|
|
if(CollUtil.isEmpty(spuIds)){ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
List<GoodsSpu> spuList = spuMapper.selectBatchIds(spuIds); |
|
|
|
|
|
for (GoodsAccredit accredit : accreditList) { |
|
|
|
|
|
if(accredit.getSpuId()!=null){ |
|
|
|
|
|
for (GoodsSpu spu : spuList) { |
|
|
|
|
|
if(spu.getId().equals(accredit.getSpuId())){ |
|
|
|
|
|
if(throwEx){ |
|
|
|
|
|
Assert.throwEx("SKU["+spu.getSpuCode()+"]不可下单"); |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else if (accredit.getCategoryId()!=null){ |
|
|
|
|
|
for (GoodsSpu spu : spuList) { |
|
|
|
|
|
for (String categoryId : spu.listCategoryIds()) { |
|
|
|
|
|
if(categoryId.equals(accredit.getCategoryId())){ |
|
|
|
|
|
if(throwEx){ |
|
|
|
|
|
Assert.throwEx("SKU["+spu.getSpuCode()+"]不可下单"); |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private GoodsAccredit getGoodsAccredit(GoodsAccreditBo param){ |
|
|
private GoodsAccredit getGoodsAccredit(GoodsAccreditBo param){ |
|
|
GoodsAccredit accredit = null; |
|
|
GoodsAccredit accredit = null; |
|
|
if(param.getCategoryId()!=null){ |
|
|
if(param.getCategoryId()!=null){ |
|
@ -344,6 +440,14 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go |
|
|
accredit = new GoodsAccredit(); |
|
|
accredit = new GoodsAccredit(); |
|
|
accredit.setSpuId(spu.getId()); |
|
|
accredit.setSpuId(spu.getId()); |
|
|
} |
|
|
} |
|
|
|
|
|
}else if (param.getSkuId()!=null){ |
|
|
|
|
|
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>() |
|
|
|
|
|
.eq(GoodsAccredit::getSkuId,param.getSkuId()),false); |
|
|
|
|
|
if(accredit==null){ |
|
|
|
|
|
GoodsSku sku = goodsSkuMapper.selectById(param.getSkuId()); |
|
|
|
|
|
accredit = new GoodsAccredit(); |
|
|
|
|
|
accredit.setSkuId(sku.getId()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return accredit; |
|
|
return accredit; |
|
|
} |
|
|
} |
|
|