package com.pj.api.client.level_one_server;

import com.pj.api.client.admin.AdminInterfaceFallback;
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.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author Mechrevo
 * @Date 2023 08 01 10 32
 **/
@Component
public class LevelOneServerInterfaceFallback implements FallbackFactory<LevelOneServerInterface> {

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

    @Override
    public LevelOneServerInterface create(Throwable throwable) {
        return new LevelOneServerInterface() {
            @Override
            public boolean tradeSettlementDto(TradeSettlementDto tradeSettlementDto) {
                log.error("接收航通订单表信息时,生成大订单和小定单时错误,当前对象:{},错误信息是:{}",tradeSettlementDto.toString(),throwable.getMessage());
                return false;
            }

            @Override
            public boolean cooperativeDto(CooperativeDto cooperativeDto) {
                log.error("查询一级市场商户错误,当前对象:{},错误信息是:{}",cooperativeDto.toString(),throwable.getMessage());
                return false;
            }

            @Override
            public boolean shopDto(ShopDto shopDto) {
                log.error("查询一级市场商户错误,当前对象:{},错误信息是:{}",shopDto.toString(),throwable.getMessage());
                return false;
            }

            @Override
            public boolean updateOrderCallCarStatus(OrderDto orderDto) {
                System.out.println(throwable.getMessage());
                log.error("查询一级市场商户错误,当前对象:{},错误信息是:{}",orderDto.toString(),throwable.getMessage());
                return false;
            }

            @Override
            public EnterpriseDto getEnterpriseById(Long enterpriseId) {
                System.out.println(throwable.getMessage());
                log.error("查询一级市场商户错误,当前ID:{},错误信息是:{}",enterpriseId,throwable.getMessage());
                return null;
            }

            @Override
            public GoodsTransitDto getGoodsTransitById(Long goodsTransitId, Long enterpriseId) {
                System.out.println(throwable.getMessage());
                log.error("查询一级市场过审商品错误,过审商品表ID:{},一级市场商户ID:{},错误信息是:{}",goodsTransitId,enterpriseId,throwable.getMessage());
                return null;
            }

            @Override
            public OrderDto getOrderDtoById(Long orderId) {
                System.out.println(throwable.getMessage());
                log.error("查询一级市场订单错误,当前ID:{},错误信息是:{}",orderId,throwable.getMessage());
                return null;
            }

            @Override
            public List<OrderDto> selectOrderList( Long appUserId) {
                System.out.println(throwable.getMessage());
                log.error("查询一级市场订单列表错误,当前用户ID:{},错误信息是:{}",appUserId,throwable.getMessage());
                return new ArrayList<>();
            }

            @Override
            public List<PeopleDto> getPeopleList(Long groupId) {
                System.out.println(throwable.getMessage());
                log.error("根据groupId查询旗下所有边民错误:{},错误信息是:{}",groupId,throwable.getMessage());
                return null;
            }

            @Override
            public GoodsDto getByGoodsId(Long goodsId) {
                System.out.println(throwable.getMessage());
                log.error("根据goodsId查询海关允许销售商品错误:{},错误信息是:{}",goodsId,throwable.getMessage());
                return null;
            }

            @Override
            public PeopleDto getRpcById(Long peopleId) {
                System.out.println(throwable.getMessage());
                log.error("互市区组长需求报价错误:{},错误信息是:{}",peopleId,throwable.getMessage());
                return null;
            }

            @Override
            public GroupDto getRpcById(String id) {
                System.out.println(throwable.getMessage());
                log.error("互市区组长错误:{},错误信息是:{}",id,throwable.getMessage());
                return null;
            }

            @Override
            public boolean enterpriseDto(EnterpriseDto enterpriseDto) {
                System.out.println(throwable.getMessage());
                log.error("互市区商家信息添加错误:{},错误信息是:{}",enterpriseDto,throwable.getMessage());
                return false;
            }

            @Override
            public boolean groupDto(GroupDto groupDto) {
                System.out.println(throwable.getMessage());
                log.error("互市区组长信息添加错误:{},错误信息是:{}",groupDto,throwable.getMessage());
                return false;
            }

            @Override
            public boolean peopleDto(PeopleDto peopleDto) {
                System.out.println(throwable.getMessage());
                log.error("互市区普通边民信息添加错误:{},错误信息是:{}",peopleDto,throwable.getMessage());
                return false;
            }

            @Override
            public boolean audit(EnterpriseAuditDto dto) {
                return false;
            }

            @Override
            public CooperativeDto getCooperativeById(Long cooperativeId) {
                System.out.println(throwable.getMessage());
                log.error("查询一级市场商户错误,当前ID:{},错误信息是:{}",cooperativeId,throwable.getMessage());
                return null;
            }

            @Override
            public boolean updateResaleStatus(Long orderId) {
                return false;
            }

            @Override
            public List<EnterpriseDto> getEnterpriseDtoListByPhone(String phone) {
                System.out.println(throwable.getMessage());
                log.error("查询一级市场外籍商户错误,当前电话:{},错误信息是:{}",phone,throwable.getMessage());
                return new ArrayList<>();
            }

            @Override
            public List<ShopDto> getShopDtoListByPhone(String phone) {
                System.out.println(throwable.getMessage());
                log.error("查询一级市场商铺错误,当前电话:{},错误信息是:{}",phone,throwable.getMessage());
                return new ArrayList<>();
            }

            @Override
            public boolean goodsDto(GoodsDto goodsDto) {
                System.out.println(throwable.getMessage());
                log.error("海关监管商品错误,当前对象:{},错误信息是:{}",goodsDto,throwable.getMessage());
                return false;
            }

            @Override
            public AppUserDto getAppUserByBorderPutrecNo(String borderPutrecNo) {
                System.out.println(throwable.getMessage());
                log.error("根据航通主键查询appUser错误,当前对象:{},错误信息是:{}",borderPutrecNo,throwable.getMessage());
                return null;
            }

            @Override
            public boolean orderFinish(String billCode) {
                return false;
            }
        };
    }
}
