package com.xhpc.common.api.factory;

import com.xhpc.common.api.UserTypeService;
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;

import java.math.BigDecimal;

/**
 * @author yuyang
 * @date 2021/12/29 10:27
 */
@Component
public class UserTypeFallbackFactory implements FallbackFactory<UserTypeService> {

    private static final Logger logger = LoggerFactory.getLogger(UserTypeFallbackFactory.class);
    @Override
    public UserTypeService create(Throwable cause) {
        logger.error("用户服务调用失败:{} //fallback", cause.getMessage());
        return new UserTypeService() {
            @Override
            public R getUser(String phone, Long userId, Integer userType,String serialNumber,String tenantId) {
                return R.fail(3886,"用户信息获取失败:" + cause.getMessage());
            }

            @Override
            public R insertUserBalance(BigDecimal money,Long userId, Integer userType, String tenantId, Integer type,Integer status,String remark,Long moneyOrderId) {
                return R.fail(3886,"添加用户金额信息失败:" + cause.getMessage());
            }

            @Override
            public R getMechanismDiscount(Long userId, Integer userType, String tenantId,Long chargingStationId) {
                return R.fail("机构信息获取失败:" + cause.getMessage());
            }

            @Override
            public R getOrderMotorcade(String mark) {
                return R.fail("车队信息获取失败:" + cause.getMessage());
            }
        };
    }
}
