puzhibing
4 天以前 a0e03b646f2c444b0f09687d24e9995112b99017
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.account.api.factory;
 
import com.ruoyi.account.api.feignClient.CompanyAllocateRecordClient;
import com.ruoyi.account.api.vo.CompanyAllocateSummaryVO;
import com.ruoyi.common.core.domain.R;
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 CompanyAllocateRecordFallbackFactory implements FallbackFactory<CompanyAllocateRecordClient> {
 
    private static final Logger log = LoggerFactory.getLogger(CompanyAllocateRecordFallbackFactory.class);
 
    @Override
    public CompanyAllocateRecordClient create(Throwable throwable) {
        log.error("公司额度分配记录服务调用失败:{}", throwable.getMessage());
        return new CompanyAllocateRecordClient() {
            @Override
            public R<Boolean> recordConsume(Integer companyId, Integer userType, String userInfo, String userName,
                                            BigDecimal beforeBalance, BigDecimal amount, String chargingOrderCode,
                                            String remark) {
                return R.fail("写入消费流水失败:" + throwable.getMessage());
            }
 
            @Override
            public R<List<String>> listConsumedOrderCodes(List<String> orderCodes) {
                return R.fail("查询消费流水订单号失败:" + throwable.getMessage());
            }
 
            @Override
            public R<CompanyAllocateSummaryVO> sumAllocatedBalance(Integer companyId) {
                return R.fail("统计公司分配余额失败:" + throwable.getMessage());
            }
 
            @Override
            public R<BigDecimal> recycleAllocatedBalance(Integer companyId, String operatorName, String companyName,
                                                         BigDecimal companyBalanceBefore) {
                return R.fail("回收公司分配余额失败:" + throwable.getMessage());
            }
        };
    }
}