Pu Zhibing
8 天以前 7a4f9541331bef779a506b38a27ed5c3373c0bec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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) {
                return R.fail("调起支付宝小程序支付失败:" + throwable.getMessage());
            }
    
            @Override
            public R<AliQueryOrder> query(String outTradeNo) {
                return R.fail("查询支付订单失败:" + throwable.getMessage());
            }
    
            @Override
            public void close(String outTradeNo) {
                R.fail("关闭支付订单失败:" + throwable.getMessage());
            }
 
            @Override
            public R<RefundResp> refund(RefundReq dto) {
                return R.fail("支付宝退款失败:" + throwable.getMessage());
            }
        };
    }
}