package com.ruoyi.account.api.factory;
|
|
import com.ruoyi.account.api.feignClient.AppUserVipDetailClient;
|
import com.ruoyi.account.api.model.TAppUserVipDetail;
|
import com.ruoyi.account.api.vo.GetAppUserVipDetail;
|
import com.ruoyi.common.core.domain.R;
|
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;
|
import org.springframework.stereotype.Component;
|
|
|
/**
|
*
|
* @author ruoyi
|
*/
|
@Component
|
public class AppUserVipDetailFallbackFactory implements FallbackFactory<AppUserVipDetailClient>
|
{
|
private static final Logger log = LoggerFactory.getLogger(AppUserVipDetailFallbackFactory.class);
|
|
@Override
|
public AppUserVipDetailClient create(Throwable throwable) {
|
log.error("用户会员明细调用失败:{}", throwable.getMessage());
|
return new AppUserVipDetailClient() {
|
|
@Override
|
public R<TAppUserVipDetail> getAppUserVipDetail(GetAppUserVipDetail getAppUserVipDetail) {
|
// 手动进行全局事务回滚
|
try {
|
GlobalTransactionContext.getCurrent().rollback();
|
} catch (TransactionException e) {
|
throw new RuntimeException(e);
|
}
|
return R.fail("获取用户当前有效的VIP明细调用失败:" + throwable.getMessage());
|
}
|
|
@Override
|
public void updateAppUserVipDetail(TAppUserVipDetail appUserVipDetail) {
|
// 手动进行全局事务回滚
|
try {
|
GlobalTransactionContext.getCurrent().rollback();
|
} catch (TransactionException e) {
|
throw new RuntimeException(e);
|
}
|
R.fail(throwable.getMessage());
|
}
|
};
|
}
|
}
|