优化编辑商品时的生成索引和操作促销活动时更新索引促销信息,增加事务监听在事务提交后发送mq信息
This commit is contained in:
parent
68ef46195c
commit
90185d8c32
@ -0,0 +1,19 @@
|
|||||||
|
package cn.lili.modules.goods.event;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author paulG
|
||||||
|
* @since 2022/1/19
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class GeneratorEsGoodsIndexEvent extends ApplicationEvent {
|
||||||
|
|
||||||
|
private String goodsId;
|
||||||
|
|
||||||
|
public GeneratorEsGoodsIndexEvent(Object source, String goodsId) {
|
||||||
|
super(source);
|
||||||
|
this.goodsId = goodsId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package cn.lili.modules.goods.listener;
|
||||||
|
|
||||||
|
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||||
|
import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent;
|
||||||
|
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||||
|
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||||
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.event.TransactionPhase;
|
||||||
|
import org.springframework.transaction.event.TransactionalEventListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author paulG
|
||||||
|
* @since 2022/1/19
|
||||||
|
**/
|
||||||
|
@Component
|
||||||
|
public class GeneratorEsGoodsIndexListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rocketMq
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private RocketMQTemplate rocketMQTemplate;
|
||||||
|
/**
|
||||||
|
* rocketMq配置
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||||
|
|
||||||
|
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||||
|
public void generatorEsGoodsIndex(GeneratorEsGoodsIndexEvent esGoodsIndexEvent) {
|
||||||
|
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
||||||
|
//发送mq消息
|
||||||
|
rocketMQTemplate.asyncSend(destination, esGoodsIndexEvent.getGoodsId(), RocketmqSendCallbackBuilder.commonCallback());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,6 +22,7 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuSpecVO;
|
|||||||
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||||
import cn.lili.modules.goods.entity.vos.SpecValueVO;
|
import cn.lili.modules.goods.entity.vos.SpecValueVO;
|
||||||
|
import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent;
|
||||||
import cn.lili.modules.goods.mapper.GoodsSkuMapper;
|
import cn.lili.modules.goods.mapper.GoodsSkuMapper;
|
||||||
import cn.lili.modules.goods.service.CategoryService;
|
import cn.lili.modules.goods.service.CategoryService;
|
||||||
import cn.lili.modules.goods.service.GoodsGalleryService;
|
import cn.lili.modules.goods.service.GoodsGalleryService;
|
||||||
@ -48,10 +49,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.event.TransactionPhase;
|
|
||||||
import org.springframework.transaction.event.TransactionalEventListener;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -110,6 +110,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PromotionGoodsService promotionGoodsService;
|
private PromotionGoodsService promotionGoodsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(List<Map<String, Object>> skuList, Goods goods) {
|
public void add(List<Map<String, Object>> skuList, Goods goods) {
|
||||||
// 检查是否需要生成索引
|
// 检查是否需要生成索引
|
||||||
@ -544,15 +547,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
* @param goods 商品信息
|
* @param goods 商品信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
|
||||||
public void generateEs(Goods goods) {
|
public void generateEs(Goods goods) {
|
||||||
// 不生成没有审核通过且没有上架的商品
|
// 不生成没有审核通过且没有上架的商品
|
||||||
if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) {
|
if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品索引事件", goods.getId()));
|
||||||
//发送mq消息
|
|
||||||
rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package cn.lili.modules.promotion.event;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author paulG
|
||||||
|
* @since 2022/1/19
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class UpdateEsGoodsIndexPromotionsEvent extends ApplicationEvent {
|
||||||
|
|
||||||
|
private String promotionsJsonStr;
|
||||||
|
|
||||||
|
public UpdateEsGoodsIndexPromotionsEvent(Object source, String promotionsJsonStr) {
|
||||||
|
super(source);
|
||||||
|
this.promotionsJsonStr = promotionsJsonStr;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package cn.lili.modules.promotion.listener;
|
||||||
|
|
||||||
|
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||||
|
import cn.lili.modules.promotion.event.UpdateEsGoodsIndexPromotionsEvent;
|
||||||
|
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||||
|
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||||
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.event.TransactionPhase;
|
||||||
|
import org.springframework.transaction.event.TransactionalEventListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author paulG
|
||||||
|
* @since 2022/1/19
|
||||||
|
**/
|
||||||
|
@Component
|
||||||
|
public class UpdateEsGoodsIndexPromotionsListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rocketMq
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private RocketMQTemplate rocketMQTemplate;
|
||||||
|
/**
|
||||||
|
* rocketMq配置
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||||
|
|
||||||
|
|
||||||
|
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||||
|
public void updateEsGoodsIndexPromotions(UpdateEsGoodsIndexPromotionsEvent event) {
|
||||||
|
//更新商品促销消息
|
||||||
|
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name();
|
||||||
|
//发送mq消息
|
||||||
|
rocketMQTemplate.asyncSend(destination, event.getPromotionsJsonStr(), RocketmqSendCallbackBuilder.commonCallback());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -10,6 +10,7 @@ import cn.lili.modules.promotion.entity.dos.BasePromotions;
|
|||||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||||
import cn.lili.modules.promotion.entity.dto.search.BasePromotionsSearchParams;
|
import cn.lili.modules.promotion.entity.dto.search.BasePromotionsSearchParams;
|
||||||
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
|
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
|
||||||
|
import cn.lili.modules.promotion.event.UpdateEsGoodsIndexPromotionsEvent;
|
||||||
import cn.lili.modules.promotion.service.AbstractPromotionsService;
|
import cn.lili.modules.promotion.service.AbstractPromotionsService;
|
||||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||||
@ -23,6 +24,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -31,7 +33,6 @@ import java.util.*;
|
|||||||
* @author paulG
|
* @author paulG
|
||||||
* @since 2021/11/30
|
* @since 2021/11/30
|
||||||
**/
|
**/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public abstract class AbstractPromotionsServiceImpl<M extends BaseMapper<T>, T extends BasePromotions> extends ServiceImpl<M, T> implements AbstractPromotionsService<T> {
|
public abstract class AbstractPromotionsServiceImpl<M extends BaseMapper<T>, T extends BasePromotions> extends ServiceImpl<M, T> implements AbstractPromotionsService<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,6 +53,9 @@ public abstract class AbstractPromotionsServiceImpl<M extends BaseMapper<T>, T e
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RocketMQTemplate rocketMQTemplate;
|
private RocketMQTemplate rocketMQTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用促销保存
|
* 通用促销保存
|
||||||
* 调用顺序:
|
* 调用顺序:
|
||||||
@ -264,10 +268,7 @@ public abstract class AbstractPromotionsServiceImpl<M extends BaseMapper<T>, T e
|
|||||||
map.put("promotionsType", promotions.getClass().getName());
|
map.put("promotionsType", promotions.getClass().getName());
|
||||||
// 促销实体
|
// 促销实体
|
||||||
map.put("promotions", promotions);
|
map.put("promotions", promotions);
|
||||||
//更新商品促销消息
|
applicationEventPublisher.publishEvent(new UpdateEsGoodsIndexPromotionsEvent("更新商品索引促销事件", JSONUtil.toJsonStr(map)));
|
||||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name();
|
|
||||||
//发送mq消息
|
|
||||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(map), RocketmqSendCallbackBuilder.commonCallback());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import cn.lili.modules.promotion.service.CouponActivityItemService;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ public class CouponActivityItemServiceImpl extends ServiceImpl<CouponActivityIte
|
|||||||
* @param couponIds 优惠券id集合
|
* @param couponIds 优惠券id集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void removeByCouponId(List<String> couponIds) {
|
public void removeByCouponId(List<String> couponIds) {
|
||||||
this.remove(new LambdaQueryWrapper<CouponActivityItem>()
|
this.remove(new LambdaQueryWrapper<CouponActivityItem>()
|
||||||
.in(CouponActivityItem::getCouponId, couponIds));
|
.in(CouponActivityItem::getCouponId, couponIds));
|
||||||
|
@ -23,6 +23,7 @@ import cn.lili.modules.promotion.tools.PromotionTools;
|
|||||||
import groovy.util.logging.Slf4j;
|
import groovy.util.logging.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -140,6 +141,7 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl<Cou
|
|||||||
* @return 是否更新成功
|
* @return 是否更新成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public boolean updatePromotionsGoods(CouponActivity couponActivity) {
|
public boolean updatePromotionsGoods(CouponActivity couponActivity) {
|
||||||
boolean result = super.updatePromotionsGoods(couponActivity);
|
boolean result = super.updatePromotionsGoods(couponActivity);
|
||||||
if (couponActivity instanceof CouponActivityDTO
|
if (couponActivity instanceof CouponActivityDTO
|
||||||
@ -189,7 +191,8 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl<Cou
|
|||||||
* @param memberList 用户列表
|
* @param memberList 用户列表
|
||||||
* @param couponActivityItems 优惠券列表
|
* @param couponActivityItems 优惠券列表
|
||||||
*/
|
*/
|
||||||
private void sendCoupon(List<Map<String, Object>> memberList, List<CouponActivityItem> couponActivityItems) {
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
|
void sendCoupon(List<Map<String, Object>> memberList, List<CouponActivityItem> couponActivityItems) {
|
||||||
|
|
||||||
for (CouponActivityItem couponActivityItem : couponActivityItems) {
|
for (CouponActivityItem couponActivityItem : couponActivityItems) {
|
||||||
//获取优惠券
|
//获取优惠券
|
||||||
|
@ -42,7 +42,6 @@ import java.util.stream.Collectors;
|
|||||||
* @since 2020/8/21
|
* @since 2020/8/21
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMapper, Coupon> implements CouponService {
|
public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMapper, Coupon> implements CouponService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,6 +77,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
|
|||||||
* @param receiveNum 领取数量
|
* @param receiveNum 领取数量
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void receiveCoupon(String couponId, Integer receiveNum) {
|
public void receiveCoupon(String couponId, Integer receiveNum) {
|
||||||
Coupon coupon = this.getById(couponId);
|
Coupon coupon = this.getById(couponId);
|
||||||
if (coupon == null) {
|
if (coupon == null) {
|
||||||
@ -88,6 +88,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public boolean removePromotions(List<String> ids) {
|
public boolean removePromotions(List<String> ids) {
|
||||||
//删除优惠券信息
|
//删除优惠券信息
|
||||||
this.memberCouponService.closeMemberCoupon(ids);
|
this.memberCouponService.closeMemberCoupon(ids);
|
||||||
@ -104,6 +105,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
|
|||||||
* @param usedNum 使用数量
|
* @param usedNum 使用数量
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void usedCoupon(String couponId, Integer usedNum) {
|
public void usedCoupon(String couponId, Integer usedNum) {
|
||||||
Coupon coupon = this.getById(couponId);
|
Coupon coupon = this.getById(couponId);
|
||||||
if (coupon == null) {
|
if (coupon == null) {
|
||||||
@ -156,6 +158,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
|
|||||||
* @return 是否更新成功
|
* @return 是否更新成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public boolean updateStatus(List<String> ids, Long startTime, Long endTime) {
|
public boolean updateStatus(List<String> ids, Long startTime, Long endTime) {
|
||||||
List<Coupon> list = this.list(new LambdaQueryWrapper<Coupon>().in(Coupon::getId, ids).eq(Coupon::getRangeDayType, CouponRangeDayEnum.DYNAMICTIME.name()));
|
List<Coupon> list = this.list(new LambdaQueryWrapper<Coupon>().in(Coupon::getId, ids).eq(Coupon::getRangeDayType, CouponRangeDayEnum.DYNAMICTIME.name()));
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
@ -221,6 +224,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public boolean updatePromotionsGoods(Coupon promotions) {
|
public boolean updatePromotionsGoods(Coupon promotions) {
|
||||||
boolean result = super.updatePromotionsGoods(promotions);
|
boolean result = super.updatePromotionsGoods(promotions);
|
||||||
if (!PromotionsStatusEnum.CLOSE.name().equals(promotions.getPromotionStatus()) &&
|
if (!PromotionsStatusEnum.CLOSE.name().equals(promotions.getPromotionStatus()) &&
|
||||||
@ -245,6 +249,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
|
|||||||
* @param promotions 优惠券信息
|
* @param promotions 优惠券信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void updateEsGoodsIndex(Coupon promotions) {
|
public void updateEsGoodsIndex(Coupon promotions) {
|
||||||
Coupon coupon = JSONUtil.parse(promotions).toBean(Coupon.class);
|
Coupon coupon = JSONUtil.parse(promotions).toBean(Coupon.class);
|
||||||
super.updateEsGoodsIndex(coupon);
|
super.updateEsGoodsIndex(coupon);
|
||||||
|
@ -33,7 +33,6 @@ import java.util.List;
|
|||||||
* @since 2020/8/21
|
* @since 2020/8/21
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public class FullDiscountServiceImpl extends AbstractPromotionsServiceImpl<FullDiscountMapper, FullDiscount> implements FullDiscountService {
|
public class FullDiscountServiceImpl extends AbstractPromotionsServiceImpl<FullDiscountMapper, FullDiscount> implements FullDiscountService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,6 +109,7 @@ public class FullDiscountServiceImpl extends AbstractPromotionsServiceImpl<FullD
|
|||||||
* @return 是否更新成功
|
* @return 是否更新成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public boolean updatePromotionsGoods(FullDiscount promotions) {
|
public boolean updatePromotionsGoods(FullDiscount promotions) {
|
||||||
boolean result = super.updatePromotionsGoods(promotions);
|
boolean result = super.updatePromotionsGoods(promotions);
|
||||||
if (!PromotionsStatusEnum.CLOSE.name().equals(promotions.getPromotionStatus())
|
if (!PromotionsStatusEnum.CLOSE.name().equals(promotions.getPromotionStatus())
|
||||||
|
@ -145,6 +145,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void addSeckillApply(String seckillId, String storeId, List<SeckillApplyVO> seckillApplyList) {
|
public void addSeckillApply(String seckillId, String storeId, List<SeckillApplyVO> seckillApplyList) {
|
||||||
Seckill seckill = this.seckillService.getById(seckillId);
|
Seckill seckill = this.seckillService.getById(seckillId);
|
||||||
if (seckill == null) {
|
if (seckill == null) {
|
||||||
|
@ -39,9 +39,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 秒杀活动业务层实现
|
* 秒杀活动业务层实现
|
||||||
@ -154,19 +152,7 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl<SeckillMap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!seckillApplies.isEmpty()) {
|
if (!seckillApplies.isEmpty()) {
|
||||||
log.info("更新限时抢购商品状态:{}", seckill);
|
this.updateEsGoodsIndex(seckill);
|
||||||
String promotionKey = PromotionTypeEnum.SECKILL.name() + "-" + seckill.getId();
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
// es促销key
|
|
||||||
map.put("esPromotionKey", promotionKey);
|
|
||||||
// 促销类型全路径名
|
|
||||||
map.put("promotionsType", Seckill.class.getName());
|
|
||||||
// 促销实体
|
|
||||||
map.put("promotions", seckill);
|
|
||||||
//更新商品促销消息
|
|
||||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name();
|
|
||||||
//发送mq消息
|
|
||||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(map), RocketmqSendCallbackBuilder.commonCallback());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user