优化修改sku时,如存在sku则不新增
This commit is contained in:
parent
46f1fcc269
commit
ccdcb1d0f6
@ -36,4 +36,11 @@ public interface GoodsGalleryService extends IService<GoodsGallery> {
|
||||
*/
|
||||
List<GoodsGallery> goodsGalleryList(String goodsId);
|
||||
|
||||
/**
|
||||
* 根据商品 id删除商品相册缩略图
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
*/
|
||||
void removeByGoodsId(String goodsId);
|
||||
|
||||
}
|
@ -75,4 +75,14 @@ public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, Goo
|
||||
//根据商品id查询商品相册
|
||||
return this.baseMapper.selectList(new QueryWrapper<GoodsGallery>().eq("goods_id", goodsId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品 id删除商品相册缩略图
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
*/
|
||||
@Override
|
||||
public void removeByGoodsId(String goodsId) {
|
||||
this.baseMapper.delete(new UpdateWrapper<GoodsGallery>().eq("goods_id", goodsId));
|
||||
}
|
||||
}
|
@ -149,10 +149,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
oldSkuIds.add(goodsSkuVO.getId());
|
||||
cache.remove(GoodsSkuService.getCacheKeys(goodsSkuVO.getId()));
|
||||
}
|
||||
goodsIndexService.deleteIndexByIds(oldSkuIds);
|
||||
this.removeByIds(oldSkuIds);
|
||||
//删除sku相册
|
||||
goodsGalleryService.removeByIds(oldSkuIds);
|
||||
goodsGalleryService.removeByGoodsId(goods.getId());
|
||||
// 添加商品sku
|
||||
newSkuList = this.addGoodsSku(skuList, goods);
|
||||
|
||||
@ -633,7 +632,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
skus.add(goodsSku);
|
||||
cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity());
|
||||
}
|
||||
this.saveBatch(skus);
|
||||
this.saveOrUpdateBatch(skus);
|
||||
return skus;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user