puzhibing
2026-09-29 010b1028b7121ae37d76441af1df7a2d9f698fc5
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
68
69
70
71
72
73
74
75
76
package com.ruoyi.other.api.factory;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.TFleet;
import com.ruoyi.other.api.domain.TGroupCompany;
import com.ruoyi.other.api.feignClient.GroupCompanyClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
import java.math.BigDecimal;
import java.util.List;
 
/**
 * 公司(企业)/车队服务降级处理
 *
 * @author mxcd
 */
@Component
public class GroupCompanyFallbackFactory implements FallbackFactory<GroupCompanyClient> {
 
    private static final Logger log = LoggerFactory.getLogger(GroupCompanyFallbackFactory.class);
 
    @Override
    public GroupCompanyClient create(Throwable throwable) {
        log.error("公司/车队服务调用失败:{}", throwable.getMessage());
        return new GroupCompanyClient() {
 
            @Override
            public R<TGroupCompany> getCompanyById(Integer id) {
                return R.fail("查询公司信息失败:" + throwable.getMessage());
            }
 
            @Override
            public R<List<TGroupCompany>> listCompaniesByIds(List<Integer> ids) {
                return R.fail("查询公司列表失败:" + throwable.getMessage());
            }
 
            @Override
            public R<BigDecimal> deductBalance(Integer companyId, BigDecimal amount) {
                return R.fail("扣减公司可用余额失败:" + throwable.getMessage());
            }
 
            @Override
            public R<BigDecimal> refundBalance(Integer companyId, BigDecimal amount) {
                return R.fail("退还公司可用余额失败:" + throwable.getMessage());
            }
 
            @Override
            public R<BigDecimal> lockBalance(Integer companyId, BigDecimal amount) {
                return R.fail("锁定公司金额失败:" + throwable.getMessage());
            }
 
            @Override
            public R<BigDecimal> settleBalance(Integer companyId, BigDecimal lockedAmount, BigDecimal actualAmount) {
                return R.fail("结算公司金额失败:" + throwable.getMessage());
            }
 
            @Override
            public R<BigDecimal> unlockBalance(Integer companyId, BigDecimal amount) {
                return R.fail("释放公司锁定金额失败:" + throwable.getMessage());
            }
 
            @Override
            public R<TFleet> getFleetById(Integer id) {
                return R.fail("查询车队信息失败:" + throwable.getMessage());
            }
 
            @Override
            public R<List<TFleet>> listFleetsByIds(List<Integer> ids) {
                return R.fail("查询车队列表失败:" + throwable.getMessage());
            }
        };
    }
}