From 68ef46195c67cede48e345db10cbf315f2a119da Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 19 Jan 2022 10:16:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=8C=85=E7=89=88=E6=9C=AC=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/pom.xml | 41 +++++++++++++++++++++++++++++++++++++++++ pom.xml | 16 ++++++++-------- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/framework/pom.xml b/framework/pom.xml index 952d1c71..7b6af4cb 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -15,6 +15,11 @@ jar + + org.springframework.boot + spring-boot-properties-migrator + runtime + org.junit.vintage junit-vintage-engine @@ -161,6 +166,12 @@ com.aliyun dysmsapi20170525 ${aliyun-sdk-dysms-version} + + + org.jacoco.agent + org.jacoco + + @@ -172,6 +183,12 @@ org.apache.rocketmq rocketmq-spring-boot-starter ${rocketmq-version} + + + fastjson + com.alibaba + + @@ -220,6 +237,10 @@ groovy org.codehaus.groovy + + commons-collections4 + org.apache.commons + @@ -248,6 +269,20 @@ com.alipay.sdk alipay-sdk-java ${alipay-sdk-version} + + + bcprov-jdk15on + org.bouncycastle + + + commons-logging + commons-logging + + + xml-apis + xml-apis + + @@ -314,6 +349,12 @@ com.googlecode.owasp-java-html-sanitizer owasp-java-html-sanitizer ${owasp-java-html-sanitizer} + + + guava + com.google.guava + + diff --git a/pom.xml b/pom.xml index ba666989..30e18428 100644 --- a/pom.xml +++ b/pom.xml @@ -21,18 +21,18 @@ 4.2.3 registry.cn-beijing.aliyuncs.com/lili-images 1 - 4.13.40.ALL - 5.1.48 + 4.22.17.ALL + 8.0.27 3.4.3.4 - 5.7.16 + 5.7.18 2.0.3.RELEASE 3.0.0 2.9.10 1.18.22 4.5.18 3.11.1 - 2.0.1 - 2.1.1 + 2.0.8 + 2.2.1 0.10.7 4.7.2 4.0.0 @@ -48,12 +48,12 @@ 2.3.1 1.21 1.2 - 4.1.2 - 4.1.2 + 5.1.0 + 5.1.0 6.6 3.4.1 1.7.28 - 2.2.0 + 3.2.3 1.4 4.3 2.3.0 From 90185d8c32f75287785a4a2da00d88bec1511144 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 19 Jan 2022 10:18:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=97=B6=E7=9A=84=E7=94=9F=E6=88=90=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=92=8C=E6=93=8D=E4=BD=9C=E4=BF=83=E9=94=80=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E6=9B=B4=E6=96=B0=E7=B4=A2=E5=BC=95=E4=BF=83?= =?UTF-8?q?=E9=94=80=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E7=9B=91=E5=90=AC=E5=9C=A8=E4=BA=8B=E5=8A=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=90=8E=E5=8F=91=E9=80=81mq=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/GeneratorEsGoodsIndexEvent.java | 19 +++++++++ .../GeneratorEsGoodsIndexListener.java | 38 +++++++++++++++++ .../serviceimpl/GoodsSkuServiceImpl.java | 12 +++--- .../UpdateEsGoodsIndexPromotionsEvent.java | 19 +++++++++ .../UpdateEsGoodsIndexPromotionsListener.java | 41 +++++++++++++++++++ .../AbstractPromotionsServiceImpl.java | 11 ++--- .../CouponActivityItemServiceImpl.java | 2 + .../CouponActivityServiceImpl.java | 5 ++- .../serviceimpl/CouponServiceImpl.java | 7 +++- .../serviceimpl/FullDiscountServiceImpl.java | 2 +- .../serviceimpl/SeckillApplyServiceImpl.java | 1 + .../serviceimpl/SeckillServiceImpl.java | 16 +------- 12 files changed, 144 insertions(+), 29 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java create mode 100644 framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java create mode 100644 framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java create mode 100644 framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java diff --git a/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java b/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java new file mode 100644 index 00000000..ff5da90f --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/event/GeneratorEsGoodsIndexEvent.java @@ -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; + } +} diff --git a/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java b/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java new file mode 100644 index 00000000..7c5b95ba --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/goods/listener/GeneratorEsGoodsIndexListener.java @@ -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()); + } + +} 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 fe4cec56..1b3e475d 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 @@ -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.GoodsVO; 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.service.CategoryService; 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 org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.event.TransactionPhase; -import org.springframework.transaction.event.TransactionalEventListener; import java.util.*; import java.util.stream.Collectors; @@ -110,6 +110,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Autowired private PromotionGoodsService promotionGoodsService; + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + @Override public void add(List> skuList, Goods goods) { // 检查是否需要生成索引 @@ -544,15 +547,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param goods 商品信息 */ @Override - @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) public void generateEs(Goods goods) { // 不生成没有审核通过且没有上架的商品 if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) { return; } - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback()); + applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品索引事件", goods.getId())); } /** diff --git a/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java b/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java new file mode 100644 index 00000000..94442bf7 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/promotion/event/UpdateEsGoodsIndexPromotionsEvent.java @@ -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; + } +} diff --git a/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java b/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java new file mode 100644 index 00000000..06b20cab --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java @@ -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()); + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java index 768cf01a..1baa838a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/AbstractPromotionsServiceImpl.java @@ -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.dto.search.BasePromotionsSearchParams; 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.PromotionGoodsService; 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 org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.transaction.annotation.Transactional; import java.util.*; @@ -31,7 +33,6 @@ import java.util.*; * @author paulG * @since 2021/11/30 **/ -@Transactional(rollbackFor = Exception.class) public abstract class AbstractPromotionsServiceImpl, T extends BasePromotions> extends ServiceImpl implements AbstractPromotionsService { /** @@ -52,6 +53,9 @@ public abstract class AbstractPromotionsServiceImpl, T e @Autowired private RocketMQTemplate rocketMQTemplate; + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + /** * 通用促销保存 * 调用顺序: @@ -264,10 +268,7 @@ public abstract class AbstractPromotionsServiceImpl, T e map.put("promotionsType", promotions.getClass().getName()); // 促销实体 map.put("promotions", promotions); - //更新商品促销消息 - String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_PROMOTIONS.name(); - //发送mq消息 - rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(map), RocketmqSendCallbackBuilder.commonCallback()); + applicationEventPublisher.publishEvent(new UpdateEsGoodsIndexPromotionsEvent("更新商品索引促销事件", JSONUtil.toJsonStr(map))); } } diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java index 03eedfa4..b7fcde45 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java @@ -7,6 +7,7 @@ import cn.lili.modules.promotion.service.CouponActivityItemService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -37,6 +38,7 @@ public class CouponActivityItemServiceImpl extends ServiceImpl couponIds) { this.remove(new LambdaQueryWrapper() .in(CouponActivityItem::getCouponId, couponIds)); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java index c413e6a4..ee56fcdc 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java @@ -23,6 +23,7 @@ import cn.lili.modules.promotion.tools.PromotionTools; import groovy.util.logging.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; @@ -140,6 +141,7 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl> memberList, List couponActivityItems) { + @Transactional(rollbackFor = {Exception.class}) + void sendCoupon(List> memberList, List couponActivityItems) { for (CouponActivityItem couponActivityItem : couponActivityItems) { //获取优惠券 diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index 7a2f3d90..2c2715e8 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -42,7 +42,6 @@ import java.util.stream.Collectors; * @since 2020/8/21 */ @Service -@Transactional(rollbackFor = Exception.class) public class CouponServiceImpl extends AbstractPromotionsServiceImpl implements CouponService { /** @@ -78,6 +77,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl ids) { //删除优惠券信息 this.memberCouponService.closeMemberCoupon(ids); @@ -104,6 +105,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl ids, Long startTime, Long endTime) { List list = this.list(new LambdaQueryWrapper().in(Coupon::getId, ids).eq(Coupon::getRangeDayType, CouponRangeDayEnum.DYNAMICTIME.name())); if (!list.isEmpty()) { @@ -221,6 +224,7 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl implements FullDiscountService { /** @@ -110,6 +109,7 @@ public class FullDiscountServiceImpl extends AbstractPromotionsServiceImpl seckillApplyList) { Seckill seckill = this.seckillService.getById(seckillId); if (seckill == null) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java index bf0b00a5..66142a56 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java @@ -39,9 +39,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * 秒杀活动业务层实现 @@ -154,19 +152,7 @@ public class SeckillServiceImpl extends AbstractPromotionsServiceImpl 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()); + this.updateEsGoodsIndex(seckill); } } } From ab1e9f806f5066e0e5ef4195ee72af9d302d4e60 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 19 Jan 2022 14:16:02 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=97=B6=E7=9A=84=E7=94=9F=E6=88=90=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=92=8C=E6=93=8D=E4=BD=9C=E4=BF=83=E9=94=80=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E6=9B=B4=E6=96=B0=E7=B4=A2=E5=BC=95=E4=BF=83?= =?UTF-8?q?=E9=94=80=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E7=9B=91=E5=90=AC=E5=9C=A8=E4=BA=8B=E5=8A=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=90=8E=E5=8F=91=E9=80=81mq=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/src/main/java/cn/lili/common/utils/SnowFlake.java | 1 - .../cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java | 1 + .../lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java | 4 +++- .../listener/UpdateEsGoodsIndexPromotionsListener.java | 2 +- .../lili/modules/promotion/serviceimpl/CouponServiceImpl.java | 1 - 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/common/utils/SnowFlake.java b/framework/src/main/java/cn/lili/common/utils/SnowFlake.java index 18379ea7..e3cb3d70 100644 --- a/framework/src/main/java/cn/lili/common/utils/SnowFlake.java +++ b/framework/src/main/java/cn/lili/common/utils/SnowFlake.java @@ -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() { diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 90ebd4c4..6a68590a 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -383,6 +383,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void updateStock(String goodsId, Integer quantity) { LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); lambdaUpdateWrapper.set(Goods::getQuantity, quantity); 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 cce00a75..40cc4192 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 @@ -131,6 +131,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void update(List> skuList, Goods goods, Boolean regeneratorSkuFlag) { // 是否存在规格 if (skuList == null || skuList.isEmpty()) { @@ -577,7 +578,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param skuList sku列表 * @param goods 商品信息 */ - private List addGoodsSku(List> skuList, Goods goods) { + @Transactional(rollbackFor = Exception.class) + List addGoodsSku(List> skuList, Goods goods) { List skus = new ArrayList<>(); for (Map skuVO : skuList) { Map resultMap = this.add(skuVO, goods); diff --git a/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java b/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java index 06b20cab..00417c5f 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java +++ b/framework/src/main/java/cn/lili/modules/promotion/listener/UpdateEsGoodsIndexPromotionsListener.java @@ -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(); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index 2c2715e8..076d45ea 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -249,7 +249,6 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl