无关风月
2024-08-24 215fde9671b285b4f77fa3f5a669c58b74af17c8
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) {
                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());
            }
        };
    }
}