优化编辑商品时的生成索引和操作促销活动时更新索引促销信息,增加事务监听在事务提交后发送mq信息

This commit is contained in:
paulGao 2022-01-19 14:16:02 +08:00
parent e961711dcb
commit ab1e9f806f
5 changed files with 5 additions and 4 deletions

View File

@ -33,7 +33,6 @@ public class SnowFlake {
*/
public static void initialize(long workerId, long datacenterId) {
snowflake = IdUtil.getSnowflake(workerId, datacenterId);
log.error(workerId+""+datacenterId);
}
public static long getId() {

View File

@ -383,6 +383,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateStock(String goodsId, Integer quantity) {
LambdaUpdateWrapper<Goods> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
lambdaUpdateWrapper.set(Goods::getQuantity, quantity);

View File

@ -131,6 +131,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) {
// 是否存在规格
if (skuList == null || skuList.isEmpty()) {
@ -577,7 +578,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
* @param skuList sku列表
* @param goods 商品信息
*/
private List<GoodsSku> addGoodsSku(List<Map<String, Object>> skuList, Goods goods) {
@Transactional(rollbackFor = Exception.class)
List<GoodsSku> addGoodsSku(List<Map<String, Object>> skuList, Goods goods) {
List<GoodsSku> skus = new ArrayList<>();
for (Map<String, Object> skuVO : skuList) {
Map<String, Object> resultMap = this.add(skuVO, goods);

View File

@ -29,7 +29,7 @@ public class UpdateEsGoodsIndexPromotionsListener {
private RocketmqCustomProperties rocketmqCustomProperties;
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true)
public void updateEsGoodsIndexPromotions(UpdateEsGoodsIndexPromotionsEvent event) {
//更新商品促销消息
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name();

View File

@ -249,7 +249,6 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl<CouponMappe
* @param promotions 优惠券信息
*/
@Override
@Transactional(rollbackFor = {Exception.class})
public void updateEsGoodsIndex(Coupon promotions) {
Coupon coupon = JSONUtil.parse(promotions).toBean(Coupon.class);
super.updateEsGoodsIndex(coupon);