package com.haha.common.enums;

public enum PaymentCycle {

    MONTHLY("MONTHLY", "月付"),
    QUARTERLY("QUARTERLY", "季度付"),
    SEMI_ANNUAL("SEMI_ANNUAL", "半年付"),
    ANNUAL("ANNUAL", "年付");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

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

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