package com.haha.common.enums;

import lombok.Getter;

/**
 * 用户消费标签枚举
 * 用于标识用户的消费行为特征
 */
@Getter
public enum UserTag {

    NEW("new", "新用户"),
    REGULAR("regular", "老用户"),
    FREQUENT("frequent", "常客"),
    POTENTIAL("potential", "未消费用户");

    private final String code;
    private final String description;

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

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

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