fix: 修复批量更新商品配送模版,没有更新sku问题

This commit is contained in:
misworga831 2024-09-13 17:27:39 +08:00
parent 7b485753a6
commit 18e2c89891
3 changed files with 21 additions and 0 deletions

View File

@ -296,4 +296,13 @@ public interface GoodsSkuService extends IService<GoodsSku> {
* @return 库存数量 * @return 库存数量
*/ */
Integer getGoodsStock(String goodsId); Integer getGoodsStock(String goodsId);
/**
* 更新sku运费模版
*
* @param goodsId 商品id
* @param templateId 运费模版id
* @return 操作结果
*/
Boolean freight(List<String> goodsId, String templateId);
} }

View File

@ -437,6 +437,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
lambdaUpdateWrapper.in(Goods::getId, goodsIds); lambdaUpdateWrapper.in(Goods::getId, goodsIds);
List<String> goodsCache = goodsIds.stream().map(item -> CachePrefix.GOODS.getPrefix() + item).collect(Collectors.toList()); List<String> goodsCache = goodsIds.stream().map(item -> CachePrefix.GOODS.getPrefix() + item).collect(Collectors.toList());
cache.multiDel(goodsCache); cache.multiDel(goodsCache);
goodsSkuService.freight(goodsIds, templateId);
return this.update(lambdaUpdateWrapper); return this.update(lambdaUpdateWrapper);
} }

View File

@ -888,6 +888,17 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
} }
@Override
public Boolean freight(List<String> goodsId, String templateId) {
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(GoodsSku::getGoodsId, goodsId);
updateWrapper.set(GoodsSku::getFreightTemplateId, templateId);
updateWrapper.set(GoodsSku::getUpdateTime, new Date());
List<String> skuIds = this.list(updateWrapper).stream().map(GoodsSku::getId).collect(Collectors.toList());
skuIds.forEach(this::clearCache);
return this.update(updateWrapper);
}
/** /**
* 渲染商品sku * 渲染商品sku
* *