puzhibing
2024-08-16 ab46a451cf1c94b01e8718e2aa6be6c7fc1886c1
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
package com.ruoyi.order.api.factory;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.TChargingCountQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
/**
 * 充电订单服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class ChargingOrderFallbackFactory implements FallbackFactory<ChargingOrderClient>
{
    private static final Logger log = LoggerFactory.getLogger(ChargingOrderFallbackFactory.class);
 
    @Override
    public ChargingOrderClient create(Throwable throwable) {
        log.error("充电订单调用失败:{}", throwable.getMessage());
        return new ChargingOrderClient() {
 
            @Override
            public R<Long> useOrderCount(Long userId) {
                return R.fail("订单计数:" + throwable.getMessage());
 
            }
 
            @Override
            public R<TChargingOrder> orderDetail(Long orderId) {
                return R.fail("订单详情:" + throwable.getMessage());
            }
 
            @Override
            public R<Integer> getChargingCount(TChargingCountQuery req) {
                return R.fail("根据会员id和有效期查询有效期内享受充电折扣次数:" + throwable.getMessage());
            }
 
            @Override
            public R<TChargingOrder> getOrderDetailByGunId(Integer chargingGunId) {
                return R.fail("根据充电枪获取正在充电的订单:" + throwable.getMessage());
            }
        };
    }
}