|
|
@@ -381,16 +381,19 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
|
|
|
}
|
|
|
|
|
|
private void saveLotCategoryRelation(Lot lot) {
|
|
|
- List<Long> categoryIds = new ArrayList<>();
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
if (StringUtils.isNotEmpty(lot.getCategory())) {
|
|
|
- categoryIds.add(Long.parseLong(lot.getCategory()));
|
|
|
+ names.add(lot.getCategory());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(lot.getSubCategory())) {
|
|
|
- categoryIds.add(Long.parseLong(lot.getSubCategory()));
|
|
|
+ names.add(lot.getSubCategory());
|
|
|
}
|
|
|
- if (!categoryIds.isEmpty()) {
|
|
|
- spuCategoryMapper.deleteLotCategoryRelation(lot.getId());
|
|
|
- spuCategoryMapper.insertLotCategoryRelation(lot.getId(), categoryIds);
|
|
|
+ if (!names.isEmpty()) {
|
|
|
+ List<Long> categoryIds = spuCategoryMapper.selectCategoryIdsByNames(names);
|
|
|
+ if (!CollectionUtils.isEmpty(categoryIds)) {
|
|
|
+ spuCategoryMapper.deleteLotCategoryRelation(lot.getId());
|
|
|
+ spuCategoryMapper.insertLotCategoryRelation(lot.getId(), categoryIds);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|