|
|
@ -31,8 +31,6 @@ import java.util.List; |
|
|
|
@AllArgsConstructor |
|
|
|
public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> implements GoodsSpuService { |
|
|
|
|
|
|
|
private GoodsSeriesService goodsSeriesService; |
|
|
|
private GoodsBrandService goodsBrandService; |
|
|
|
private GoodsUnitService goodsUnitService; |
|
|
|
private GoodsSkuService goodsSkuService; |
|
|
|
private GoodsSpuSpecService goodsSpuSpecService; |
|
|
@ -41,6 +39,11 @@ public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> im |
|
|
|
private GoodsCategoryService goodsCategoryService; |
|
|
|
private BmsFactoryService bmsFactoryService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<GoodsSpu> selectSpuList(GoodsSpu goodsSpu) { |
|
|
|
return baseMapper.selectSpuList(goodsSpu); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public GoodsSpu getByCode(String code) { |
|
|
|
LambdaQueryWrapper<GoodsSpu> lqw = new LambdaQueryWrapper<>(); |
|
|
@ -55,6 +58,7 @@ public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> im |
|
|
|
List<GoodsSku> skuList = goodsSkuService.getBySpuId(id); |
|
|
|
goodsSpuVo.setSkuList(skuList); |
|
|
|
List<GoodsSkuSpecValueVo> skuSpecValueList = goodsSkuSpecValueService.listSpecValueBySpuId(id); |
|
|
|
goodsSpuVo.setSkuSpecValueList(skuSpecValueList); |
|
|
|
List<GoodsSpuSpecVo> specList = goodsSpuSpecService.listSpuSpecs(id); |
|
|
|
//封装规格的值
|
|
|
|
for (GoodsSpuSpecVo specVo : specList) { |
|
|
@ -80,6 +84,24 @@ public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> im |
|
|
|
} |
|
|
|
} |
|
|
|
goodsSpuVo.setSpecList(specList); |
|
|
|
List<String> categoryIds = new ArrayList<>(); |
|
|
|
categoryIds.add(goodsSpuVo.getCategoryFirst()); |
|
|
|
categoryIds.add(goodsSpuVo.getCategorySecond()); |
|
|
|
categoryIds.add(goodsSpuVo.getCategoryThird()); |
|
|
|
List<GoodsCategory> categories = goodsCategoryService.listByIds(categoryIds); |
|
|
|
for (GoodsCategory category : categories) { |
|
|
|
if(goodsSpuVo.getCategoryFirst().equals(category.getId().toString())){ |
|
|
|
goodsSpuVo.setCateFirstLabel(category.getName()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if(goodsSpuVo.getCategorySecond().equals(category.getId().toString())){ |
|
|
|
goodsSpuVo.setCateSecondLabel(category.getName()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if(goodsSpuVo.getCategoryThird().equals(category.getId().toString())){ |
|
|
|
goodsSpuVo.setCateThirdLabel(category.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
return goodsSpuVo; |
|
|
|
} |
|
|
|
|
|
|
@ -105,8 +127,10 @@ public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> im |
|
|
|
if(param.getId()!=null){ |
|
|
|
spu.setSpuCode(null); |
|
|
|
} |
|
|
|
if(StringUtils.hasText(param.getCategoryId())){ |
|
|
|
GoodsCategory category = goodsCategoryService.getById(param.getCategoryId()); |
|
|
|
relateCate(spu,category); |
|
|
|
} |
|
|
|
this.saveOrUpdate(spu); |
|
|
|
insertSpuSpec(spu.getId()); |
|
|
|
} |
|
|
@ -150,16 +174,6 @@ public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> im |
|
|
|
skuBatchResult.setErrorCode(1); |
|
|
|
return skuBatchResult; |
|
|
|
} |
|
|
|
//设置品牌
|
|
|
|
GoodsBrand goodsBrand = goodsBrandService.getByCode(tasteProduct.getBrandCode()); |
|
|
|
if(goodsBrand!=null){ |
|
|
|
spu.setBrandId(goodsBrand.getId()); |
|
|
|
} |
|
|
|
//设置系列
|
|
|
|
GoodsSeries goodsSeries = goodsSeriesService.getByCode(tasteProduct.getSeriesCode()); |
|
|
|
if(goodsSeries!=null){ |
|
|
|
spu.setSeriesId(goodsSeries.getId()); |
|
|
|
} |
|
|
|
spu.setTasteValue(tasteProduct.getProductTasteValue()); |
|
|
|
if(spu.getId()==null){ |
|
|
|
this.save(spu); |
|
|
|