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); + } + /** * 更新促销活动商品库存 *