package com.xhpc.common.api.factory;

import com.xhpc.common.api.PileOrderService;
import com.xhpc.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author yuyang
 * @date 2021/8/15 16:55
 */
@Component
public class PileOrderFallbackFactory implements FallbackFactory<PileOrderService> {

    private static final Logger logger = LoggerFactory.getLogger(PileOrderFallbackFactory.class);

    @Override
    public PileOrderService create(Throwable cause) {

        logger.error("订单服务调用失败：{}//fallback",cause.getMessage());
        return new PileOrderService() {
            @Override
            public R pileStartup(String orderNo, Integer status, String remark) {

                return R.fail("桩启动回调接口失败:" + cause.getMessage());
            }

            @Override
            public R pileStop(String orderNo, Integer status, String remark) {

                return R.fail("桩停止回调接口失败:" + cause.getMessage());
            }

            @Override
            public R pileEndOrder(String orderNo) {

                return null;
            }

            @Override
            public R pileRimeOrder(String orderNo) {

                return R.fail("桩实时订单回调接口失败:" + cause.getMessage());
            }

            @Override
            public R abnormalOrder(String orderNo) {

                return R.fail("订单异常回调接口失败:" + cause.getMessage());
            }

            @Override
            public R pileStartUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId) {

                return R.fail("互联网订单启动失败:" + cause.getMessage());
            }
        };
    }

}
