package cn.superdesk.uniorder.common.enums.invoice.common;

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

/**
 * @Description: 发票种类 以数据据表 invoice_type 为准
 * @Author: linjinyu
 * @CreateDate: 2022/4/26 2:46 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/4/26 2:46 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum InvoiceTypeEnum {

    电子普通发票(1L, "电子普通发票"), // 增值税电子普通发票
    纸质专用发票(2L, "纸质专用发票"), // 增值税专用发票
    纸质普通发票(3L, "纸质普通发票"), // 增值税普通发票
    电子专用发票(4L, "电子专用发票"), // 增值税电子专用发票
    ;


    private Long   key;
    private String desc;

    InvoiceTypeEnum(Long key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public Long getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(Long key) {
        for (InvoiceTypeEnum c : InvoiceTypeEnum.values()) {
            if (c.key.equals(key)) {
                return c.getDesc();
            }
        }

        return "未知状态";
    }

    private static final Map<Long, InvoiceTypeEnum> LOOKUP = new HashMap<>();

    static {
        for (InvoiceTypeEnum s : EnumSet.allOf(InvoiceTypeEnum.class)) {
            LOOKUP.put(s.getKey(), s);
        }
    }

    public static InvoiceTypeEnum get(Long key) {
        return LOOKUP.get(key);
    }
}
