longz
2026-07-13 6fc77feef6337bc478423efad5de91fa520b4990
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.ruoyi.payment.api.factory;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.payment.api.feignClient.IcbcPaymentClient;
import com.ruoyi.payment.api.vo.IcbcPaymentReq;
import com.ruoyi.payment.api.vo.IcbcPaymentResp;
import com.ruoyi.payment.api.vo.IcbcRefundReq;
import com.ruoyi.payment.api.vo.IcbcRefundResp;
import com.ruoyi.payment.api.vo.IcbcSubOrderQueryReq;
import com.ruoyi.payment.api.vo.IcbcSubOrderQueryResp;
import com.ruoyi.payment.api.vo.IcbcSubOrderRefundReq;
import com.ruoyi.payment.api.vo.IcbcSubOrderRefundResp;
import com.ruoyi.payment.api.vo.IcbcSubOrderSplitReq;
import com.ruoyi.payment.api.vo.IcbcSubOrderSplitResp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
/**
 * 工行支付调用降级处理。
 */
@Component
public class IcbcPaymentFallbackFactory implements FallbackFactory<IcbcPaymentClient> {
    private static final Logger log = LoggerFactory.getLogger(IcbcPaymentFallbackFactory.class);
 
    @Override
    public IcbcPaymentClient create(Throwable throwable) {
        log.error("工行支付调用失败:{}", throwable.getMessage());
        return new IcbcPaymentClient() {
            @Override
            public R<IcbcPaymentResp> payment(IcbcPaymentReq req) {
                return R.fail("调起工行支付失败:" + throwable.getMessage());
            }
 
            @Override
            public R<IcbcPaymentResp> query(String outTradeNo) {
                return R.fail("查询工行支付订单失败:" + throwable.getMessage());
            }
 
            @Override
            public R<IcbcPaymentResp> close(String outTradeNo) {
                return R.fail("关闭工行支付订单失败:" + throwable.getMessage());
            }
 
            @Override
            public R<IcbcRefundResp> refund(IcbcRefundReq req) {
                return R.fail("工行退款失败:" + throwable.getMessage());
            }
 
            @Override
            public R<IcbcSubOrderSplitResp> splitSubOrder(IcbcSubOrderSplitReq req) {
                return R.fail("工行小订单拆分失败:" + throwable.getMessage());
            }
 
            @Override
            public R<IcbcSubOrderRefundResp> refundSubOrder(IcbcSubOrderRefundReq req) {
                return R.fail("工行小订单拆分退款失败:" + throwable.getMessage());
            }
 
            @Override
            public R<IcbcSubOrderQueryResp> querySubOrder(IcbcSubOrderQueryReq req) {
                return R.fail("查询工行子订单失败:" + throwable.getMessage());
            }
        };
    }
}