|
|
@ -524,6 +524,9 @@ public class GoodsSpuController { |
|
|
|
*/ |
|
|
|
@GetMapping("/export") |
|
|
|
public R<List<GoodsSpuExportVo>> export(GoodsSpu param){ |
|
|
|
if(DevEnvironmentConfig.OPEN_TENANT_BOOK){ |
|
|
|
param.setBookCodeList(BookAccountUtil.getCurrentUserAccount()); |
|
|
|
} |
|
|
|
List<GoodsSpu> list = goodsSpuService.selectSpuList(param); |
|
|
|
List<GoodsSpuExportVo> exportVoList = list.stream().map(a->{ |
|
|
|
GoodsSpuExportVo vo = new GoodsSpuExportVo(); |
|
|
@ -534,7 +537,8 @@ public class GoodsSpuController { |
|
|
|
vo.setOrderFlag(a.getOrderFlag()); |
|
|
|
vo.setCostFlag(a.getCostFlag()); |
|
|
|
vo.setGoodsSaleType(a.getGoodsSaleType()); |
|
|
|
vo.setCateCode(a.getCategoryThird()); |
|
|
|
vo.setSpuCunhuoFlag(a.getSpuCunhuoFlag()); |
|
|
|
vo.setCateCode(a.getCateThirdCode()); |
|
|
|
vo.setCateName(a.getCateThirdLabel()); |
|
|
|
return vo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
@ -556,12 +560,12 @@ public class GoodsSpuController { |
|
|
|
|
|
|
|
//导入
|
|
|
|
List<String> spuCodes = new ArrayList<>(); |
|
|
|
List<String> cateNames = new ArrayList<>(); |
|
|
|
List<String> cateCodes = new ArrayList<>(); |
|
|
|
for (GoodsSpuImportBo.SpuItem item : param.getSpuList()) { |
|
|
|
spuCodes.add(item.getSpuCode()); |
|
|
|
//删除只需要spu编码
|
|
|
|
if(StringUtils.hasText(item.getCategoryCode())&&!item.getOpt().equals(DELETE)){ |
|
|
|
cateNames.add(item.getCategoryCode()); |
|
|
|
cateCodes.add(item.getCategoryCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(spuCodes.size()<1){ |
|
|
@ -572,9 +576,9 @@ public class GoodsSpuController { |
|
|
|
List<GoodsSpu> spuList = goodsSpuService.list(spuLqw); |
|
|
|
|
|
|
|
List<GoodsCategory> cateList = null; |
|
|
|
if(cateNames.size()>0){ |
|
|
|
if(cateCodes.size()>0){ |
|
|
|
LambdaQueryWrapper<GoodsCategory> cateLqw = new LambdaQueryWrapper<>(); |
|
|
|
cateLqw.in(GoodsCategory::getName,cateNames); |
|
|
|
cateLqw.in(GoodsCategory::getCode,cateCodes); |
|
|
|
cateLqw.eq(GoodsCategory::getLevel,3); |
|
|
|
cateList = goodsCategoryService.list(cateLqw); |
|
|
|
} |
|
|
@ -592,7 +596,7 @@ public class GoodsSpuController { |
|
|
|
item.setErrMsg("["+item.getCategoryCode()+"]类目不存在"); |
|
|
|
}else { |
|
|
|
String cateName = item.getCategoryCode(); |
|
|
|
boolean existCate = cateList.stream().anyMatch(a->a.getName().equals(cateName)); |
|
|
|
boolean existCate = cateList.stream().anyMatch(a->a.getCode().equals(cateName)); |
|
|
|
if(!existCate){ |
|
|
|
isError = true; |
|
|
|
item.setErrMsg("["+item.getCategoryCode()+"]类目不存在"); |
|
|
@ -615,7 +619,7 @@ public class GoodsSpuController { |
|
|
|
} |
|
|
|
|
|
|
|
if(isError){ |
|
|
|
return R.ok(param); |
|
|
|
return R.ok(param,"数据错误"); |
|
|
|
} |
|
|
|
|
|
|
|
List<Long> rmIds = new ArrayList<>(); |
|
|
@ -688,6 +692,8 @@ public class GoodsSpuController { |
|
|
|
if(cateList !=null){ |
|
|
|
for (GoodsCategory category : cateList) { |
|
|
|
if(category.getCode().equals(spuItem.getCategoryCode())){ |
|
|
|
spu.setBookName(category.getBookName()); |
|
|
|
spu.setBookBelong(category.getBookBelong()); |
|
|
|
String[] cateIds = category.getLevelPath().split("_"); |
|
|
|
if(cateIds.length==3){ |
|
|
|
spu.setCategoryFirst(cateIds[0]); |
|
|
|