Skip to content

Commit

Permalink
Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
Browse files Browse the repository at this point in the history
  • Loading branch information
chopper711 committed May 13, 2022
2 parents 57cf3b9 + b683eac commit 6331b0d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 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 All @@ -162,7 +161,13 @@ public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regen
} else {
newSkuList = new ArrayList<>();
for (Map<String, Object> map : skuList) {
GoodsSku sku = new GoodsSku();
GoodsSku sku = null;
if (map.get("id") != null) {
sku = this.getGoodsSkuByIdFromCache(map.get("id").toString());
}
if (sku == null || map.get("id") == null) {
sku = new GoodsSku();
}
//设置商品信息
goodsInfo(sku, goods);
//设置商品规格信息
Expand Down Expand Up @@ -627,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 6331b0d

Please sign in to comment.