package com.ruoyi.payment.api.factory;
|
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.payment.api.feignClient.AliPaymentClient;
|
import com.ruoyi.payment.api.model.RefundReq;
|
import com.ruoyi.payment.api.model.RefundResp;
|
import com.ruoyi.payment.api.vo.AliPaymentReq;
|
import com.ruoyi.payment.api.vo.AliPaymentResp;
|
import com.ruoyi.payment.api.vo.AliQueryOrder;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.stereotype.Component;
|
|
|
/**
|
* 充电订单服务降级处理
|
*
|
* @author ruoyi
|
*/
|
@Component
|
public class AliPaymentFallbackFactory implements FallbackFactory<AliPaymentClient>
|
{
|
private static final Logger log = LoggerFactory.getLogger(AliPaymentFallbackFactory.class);
|
|
@Override
|
public AliPaymentClient create(Throwable throwable) {
|
log.error("支付宝支付调用失败:{}", throwable.getMessage());
|
return new AliPaymentClient() {
|
|
@Override
|
public R<AliPaymentResp> payment(AliPaymentReq req) {
|
throw new RuntimeException("调起支付宝小程序支付失败:" + throwable.getMessage());
|
}
|
|
@Override
|
public R<AliQueryOrder> query(String outTradeNo) {
|
throw new RuntimeException("查询支付订单失败:" + throwable.getMessage());
|
}
|
|
@Override
|
public void close(String outTradeNo) {
|
throw new RuntimeException("关闭支付订单失败:" + throwable.getMessage());
|
}
|
|
@Override
|
public R<RefundResp> refund(RefundReq dto) {
|
throw new RuntimeException("支付宝退款失败:" + throwable.getMessage());
|
}
|
};
|
}
|
}
|