package com.xhpc.common.api.factory;

import com.xhpc.common.api.RefundOrderService;
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.util.Map;

/**
 * @author yuyang
 * @date 2021/12/28 15:34
 */
@Component
public class RefundOrderFallbackFactory implements FallbackFactory<RefundOrderService> {
    private static final Logger logger = LoggerFactory.getLogger(RefundOrderFallbackFactory.class);

    @Override
    public RefundOrderService create(Throwable cause) {
        logger.error("申请退款服务调用失败:{} //fallback", cause.getMessage());
        return new RefundOrderService() {
            @Override
            public R sendNotice(String amount, String openid, Integer source, String type, String userId,String tenantId,String remark) {
                return R.fail(3886,"自动申请退款失败:" + cause.getMessage());
            }
            @Override
            public R cycOrderCheckOut(String amount, Integer source, String userId, String tenantId) {
                return R.fail(3886,"云块充自动申请退款失败:" + cause.getMessage());
            }
        };

    }
}
