商品删除则删除相关促销商品

This commit is contained in:
Chopper 2022-09-06 19:22:34 +08:00
parent b61cfe8b6b
commit 90a2ec9719
5 changed files with 27 additions and 1 deletions

View File

@ -205,6 +205,8 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
for (String goodsId : JSONUtil.toList(goodsIdsJsonStr, String.class)) { for (String goodsId : JSONUtil.toList(goodsIdsJsonStr, String.class)) {
goodsIndexService.deleteIndex(MapUtil.builder(new HashMap<String, Object>()).put("goodsId", goodsId).build()); goodsIndexService.deleteIndex(MapUtil.builder(new HashMap<String, Object>()).put("goodsId", goodsId).build());
} }
promotionService.removeByGoodsIds(goodsIdsJsonStr);
} catch (Exception e) { } catch (Exception e) {
log.error("删除商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e); log.error("删除商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e);
} }

View File

@ -149,6 +149,13 @@ public interface PromotionGoodsService extends IService<PromotionGoods> {
*/ */
void deletePromotionGoods(List<String> promotionIds); void deletePromotionGoods(List<String> promotionIds);
/**
* 删除商品的促销
*
* @param goodsIds 商品id
*/
void deletePromotionGoodsByGoods(List<String> goodsIds);
/** /**
* 根据参数删除促销商品 * 根据参数删除促销商品
* *

View File

@ -23,10 +23,16 @@ public interface PromotionService {
/** /**
* 根据商品索引获取当前商品索引的所有促销活动信息 * 根据商品索引获取当前商品索引的所有促销活动信息
* *
* @param storeId 店铺id * @param storeId 店铺id
* @param goodsSkuId 商品skuId * @param goodsSkuId 商品skuId
* @return 当前促销活动集合 * @return 当前促销活动集合
*/ */
Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId); Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId);
/**
* 删除商品则删除相关促销信息
*
* @param goodsIdsJsonStr
*/
void removeByGoodsIds(String goodsIdsJsonStr);
} }

View File

@ -281,6 +281,13 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,
this.remove(queryWrapper); this.remove(queryWrapper);
} }
@Override
public void deletePromotionGoodsByGoods(List<String> goodsIds) {
LambdaQueryWrapper<PromotionGoods> queryWrapper = new LambdaQueryWrapper<PromotionGoods>().in(PromotionGoods::getGoodsId, goodsIds);
this.remove(queryWrapper);
}
/** /**
* 根据参数删除促销商品 * 根据参数删除促销商品
* *

View File

@ -116,6 +116,10 @@ public class PromotionServiceImpl implements PromotionService {
return promotionMap; return promotionMap;
} }
@Override
public void removeByGoodsIds(String goodsIdsJsonStr) {
promotionGoodsService.deletePromotionGoods(Arrays.asList(goodsIdsJsonStr.split(",")));
}
private void getGoodsCurrentSeckill(String esPromotionKey, PromotionGoods promotionGoods, Map<String, Object> promotionMap) { private void getGoodsCurrentSeckill(String esPromotionKey, PromotionGoods promotionGoods, Map<String, Object> promotionMap) {
Seckill seckill = seckillService.getById(promotionGoods.getPromotionId()); Seckill seckill = seckillService.getById(promotionGoods.getPromotionId());