package com.jeesharp.business.modules.finance.invoice.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 发票申请业务类型枚举，与 {@code app_member_invoice_apply.biz_type} 存储值一致（小写）。
 *
 * @author jeesharp
 * @since 2026-06-12
 */
@Getter
@AllArgsConstructor
public enum MemberInvoiceApplyBizTypeEnum {

    /** 商城 */
    MALL("mall", "商城"),

    /** 酒店 */
    HOTEL("hotel", "酒店"),

    /** 景区 */
    SCENIC("scenic", "景区"),

    /** 美食 */
    FOOD("food", "美食"),

    /** 休闲 */
    LEISURE("leisure", "休闲"),

    /** 讲解 */
    EXPLAIN("explain", "讲解"),

    /** 年卡 */
    YEAR_CARD("yearcard", "年卡"),

    /** 研学 */
    STUDY("study", "研学"),

    /** 非遗 */
    HERITAGE("heritage", "非遗"),

    /** 文化 */
    CULTURE("culture", "文化"),

    /** 线路 */
    ROUTE("route", "线路"),

    /** 村落 */
    VILLAGE("village", "村落");

    private final String value;
    private final String desc;

    public static MemberInvoiceApplyBizTypeEnum fromValue(String value) {
        if (value == null || value.isBlank()) {
            return null;
        }
        String normalized = value.trim();
        for (MemberInvoiceApplyBizTypeEnum e : values()) {
            if (e.value.equalsIgnoreCase(normalized)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByValue(String value) {
        MemberInvoiceApplyBizTypeEnum e = fromValue(value);
        return e != null ? e.getDesc() : value != null ? value : "";
    }
}
