Skip to content

Commit

Permalink
优化修改sku时,如存在sku则不新增
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed May 13, 2022
1 parent 46f1fcc commit ccdcb1d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ public interface GoodsGalleryService extends IService<GoodsGallery> {
*/
List<GoodsGallery> goodsGalleryList(String goodsId);

/**
* 根据商品 id删除商品相册缩略图
*
* @param goodsId 商品ID
*/
void removeByGoodsId(String goodsId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,14 @@ public List<GoodsGallery> goodsGalleryList(String goodsId) {
//根据商品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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,9 @@ public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regen
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);

Expand Down Expand Up @@ -633,7 +632,7 @@ List<GoodsSku> addGoodsSku(List<Map<String, Object>> skuList, Goods goods) {
skus.add(goodsSku);
cache.put(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity());
}
this.saveBatch(skus);
this.saveOrUpdateBatch(skus);
return skus;
}

Expand Down

0 comments on commit ccdcb1d

Please sign in to comment.