xuhy
2024-09-25 ca825fdfe67223b2eb8a3f9c14b4e60e2339efc6
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponFallbackFactory.java
@@ -5,6 +5,8 @@
import com.ruoyi.other.api.domain.TGoods;
import com.ruoyi.other.api.feignClient.CouponClient;
import com.ruoyi.other.api.feignClient.GoodsClient;
import io.seata.core.exception.TransactionException;
import io.seata.tm.api.GlobalTransactionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -35,6 +37,17 @@
         public R<List<Integer>> getCouponIdsByName(String name) {
            return R.fail("根据名称查询优惠券ids:" + throwable.getMessage());
         }
         @Override
         public R updateCoupon(TCoupon coupon) {
            // 手动进行全局事务回滚
            try {
               GlobalTransactionContext.getCurrent().rollback();
            } catch (TransactionException e) {
               throw new RuntimeException(e);
            }
            return R.fail("修改优惠券失败");
         }
      };
   }