package com.haha.common.enums;

public enum BillingMode {

    RENT_ONLY("RENT_ONLY", "纯租金"),
    RENT_ELECTRIC("RENT_ELECTRIC", "租金+电费"),
    COMMISSION_ONLY("COMMISSION_ONLY", "纯提成"),
    RENT_COMMISSION("RENT_COMMISSION", "租金+提成"),
    RENT_COMMISSION_ELECTRIC("RENT_COMMISSION_ELECTRIC", "租金+提成+电费");

    private final String code;
    private final String description;

    BillingMode(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static BillingMode fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (BillingMode billingMode : values()) {
            if (billingMode.code.equals(code)) {
                return billingMode;
            }
        }
        return null;
    }

    public static String getDescription(String code) {
        BillingMode billingMode = fromCode(code);
        return billingMode != null ? billingMode.description : "未知";
    }
}
