package cn.superdesk.uniorder.common.enums.thirdpart.szhtxx.paperInvoice;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description: op申请红字信息表编号-op确认申请-申请说明:;
 * 销方申请-0000000100;
 * 购方申请（已抵扣）-1100000000;
 * 购方申请（未抵扣）-1010000000
 * @Author: linjinyu
 * @CreateDate: 2022/5/26 4:32 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/5/26 4:32 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum SzhtxxPaperInvoiceReqfCodeEnum {

    异常申请("none", "异常申请", "0"),
    销方申请("ghf", "销售方申请", "0000000100"),
    购方申请_已抵扣("xhf_1", "购买方申请（已抵扣）", "1100000000"),
    购方申请_未抵扣("xhf_0", "购买方申请（未抵扣）", "1010000000"),

    ;

    private String reqfCode;
    private String reqfName;
    private String reqExplain;

    SzhtxxPaperInvoiceReqfCodeEnum(String reqfCode, String reqfName, String reqExplain) {
        this.reqfCode = reqfCode;
        this.reqfName = reqfName;
        this.reqExplain = reqExplain;
    }

    public String getReqfCode() {
        return reqfCode;
    }

    public String getReqfName() {
        return reqfName;
    }

    public String getReqExplain() {
        return reqExplain;
    }

    public static String getReqfNameByReqfCode(String reqfCode) {
        for (SzhtxxPaperInvoiceReqfCodeEnum c : SzhtxxPaperInvoiceReqfCodeEnum.values()) {
            if (c.reqfCode.equals(reqfCode)) {
                return c.getReqfName();
            }
        }
        return 异常申请.reqfName;
    }

    public static String getReqExplainByReqfCode(String reqfCode) {
        for (SzhtxxPaperInvoiceReqfCodeEnum c : SzhtxxPaperInvoiceReqfCodeEnum.values()) {
            if (c.reqfCode.equals(reqfCode)) {
                return c.getReqExplain();
            }
        }
        return 异常申请.reqExplain;
    }

    public static SzhtxxPaperInvoiceReqfCodeEnum getByReqfCode(String reqfCode) {
        for (SzhtxxPaperInvoiceReqfCodeEnum commonServiceEnum : SzhtxxPaperInvoiceReqfCodeEnum.values()) {
            if (commonServiceEnum.reqfCode.equals(reqfCode)) {
                return commonServiceEnum;
            }
        }
        return SzhtxxPaperInvoiceReqfCodeEnum.异常申请;
    }


    private static final Map<String, SzhtxxPaperInvoiceReqfCodeEnum> LOOKUP_BY_REQ_CODE  = new HashMap<>();
    private static final Map<String, SzhtxxPaperInvoiceReqfCodeEnum> LOOK_UP_REQ_EXPLAIN = new HashMap<>();

    static {
        for (SzhtxxPaperInvoiceReqfCodeEnum s : EnumSet.allOf(SzhtxxPaperInvoiceReqfCodeEnum.class)) {
            LOOKUP_BY_REQ_CODE.put(s.getReqfCode(), s);
            LOOK_UP_REQ_EXPLAIN.put(s.getReqExplain(), s);
        }
    }

//    public static SzhtxxPaperInvoiceReqfCodeEnum getByReqfCode(String reqfCode) {
//        return LOOKUP_BY_REQ_CODE.get(reqfCode);
//    }

    public static SzhtxxPaperInvoiceReqfCodeEnum getByReqExplain(String reqExplain) {
        return LOOK_UP_REQ_EXPLAIN.get(reqExplain);
    }

}
