From ede7a37e37600e83c853b4a24126b2aa99acb56f Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 5 Dec 2022 17:17:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=BA=93=E5=AD=98=E6=97=B6=EF=BC=8C=E4=BF=83?= =?UTF-8?q?=E9=94=80=E5=95=86=E5=93=81=E5=BA=93=E5=AD=98=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/serviceimpl/GoodsSkuServiceImpl.java | 1 + .../dto/search/PromotionGoodsSearchParams.java | 6 ++++-- .../service/PromotionGoodsService.java | 8 ++++++++ .../serviceimpl/PromotionGoodsServiceImpl.java | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 84236cda..cdfe4c3f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -508,6 +508,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i List goodsSkus = new ArrayList<>(); goodsSkus.add(goodsSku); this.updateGoodsStuck(goodsSkus); + this.promotionGoodsService.updatePromotionGoodsStock(goodsSku.getId(), quantity); } } diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PromotionGoodsSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PromotionGoodsSearchParams.java index 01f5f211..576a488d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PromotionGoodsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/PromotionGoodsSearchParams.java @@ -4,8 +4,7 @@ import cn.hutool.core.text.CharSequenceUtil; import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; +import lombok.*; import java.util.Arrays; import java.util.List; @@ -18,6 +17,9 @@ import java.util.List; **/ @EqualsAndHashCode(callSuper = true) @Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class PromotionGoodsSearchParams extends BasePromotionsSearchParams { @ApiModelProperty(value = "促销活动id") diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java index 375ccb9c..2c63d63d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java @@ -137,6 +137,14 @@ public interface PromotionGoodsService extends IService { */ void updatePromotionGoodsStock(List promotionGoodsList); + /** + * 更新促销活动商品库存 + * + * @param skuId 商品skuId + * @param quantity 库存 + */ + void updatePromotionGoodsStock(String skuId, Integer quantity); + /** * 更新促销活动商品索引 * diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index 3502b2ed..948a2da4 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import cn.lili.cache.Cache; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.dos.GoodsSku; @@ -71,6 +72,9 @@ public class PromotionGoodsServiceImpl extends ServiceImpl findSkuValidPromotion(String skuId, String storeIds) { @@ -262,6 +266,20 @@ public class PromotionGoodsServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PromotionGoods::getSkuId, skuId); + this.list(queryWrapper).forEach(promotionGoods -> { + String promotionStockKey = PromotionGoodsService.getPromotionGoodsStockCacheKey(PromotionTypeEnum.valueOf(promotionGoods.getPromotionType()), promotionGoods.getPromotionId(), promotionGoods.getSkuId()); + cache.remove(promotionStockKey); + }); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(PromotionGoods::getSkuId, skuId); + updateWrapper.set(PromotionGoods::getQuantity, quantity); + this.update(updateWrapper); + } + /** * 更新促销活动商品库存 *