package com.pj.api.client.payment_server;

import com.pj.api.client.cfg.SpCfgInterfaceFallback;
import com.pj.api.dto.*;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class PaymentServerInterfaceFallback implements FallbackFactory<PaymentServerInterface> {

    private static final Logger log = LoggerFactory.getLogger(SpCfgInterfaceFallback.class);

    @Override
    public PaymentServerInterface create(Throwable throwable) {
        return new PaymentServerInterface() {
            @Override
            public void sendCXB001(PaymentDto paymentDto) {
                System.out.println(throwable.getMessage());
                log.error("调用结关报文接口【CXB001】错误,当前对象:{},错误信息是:{}",paymentDto,throwable.getMessage());
            }

            @Override
            public void sendSXB010(PaymentDto paymentDto) {
                System.out.println(throwable.getMessage());
                log.error("调用银行扣款接口【SXB010】错误,当前对象:{},错误信息是:{}",paymentDto,throwable.getMessage());
            }

            @Override
            public void sendSXB013(PaymentDto paymentDto) {
                System.out.println(throwable.getMessage());
                log.error("调用银行退款接口【SXB013】错误,当前对象:{},错误信息是:{}",paymentDto,throwable.getMessage());
            }

            @Override
            public void sendSXB023(PaymentDto paymentDto) {
                System.out.println(throwable.getMessage());
                log.error("调用通关车批信息同步接口(车出一级市场时)【SXB023】错误,当前对象:{},错误信息是:{}",paymentDto,throwable.getMessage());
            }

            @Override
            public void sendMKT006_NoCommission(PaymentTwoDto paymentTwoDto) {
                System.out.println(throwable.getMessage());
                log.error("调用订单扣款（无手续费）接口【MKT006】错误,当前对象:{},错误信息是:{}",paymentTwoDto,throwable.getMessage());
            }

            @Override
            public void sendMKT006(PaymentTwoDto paymentTwoDto) {
                System.out.println(throwable.getMessage());
                log.error("调用订单扣款（+手续费）接口【MKT006】错误,当前对象:{},错误信息是:{}",paymentTwoDto,throwable.getMessage());
            }

            @Override
            public List<BankInfoDto> getListBySource(String source) {
                System.out.println(throwable.getMessage());
                log.error("根据订单号查询银行回执信息错误:{},错误信息是:{}",source,throwable.getMessage());
                return null;
            }
        };
    }
}
