package com.haha.common.enums;

import com.haha.common.vo.StatusLabel;

public enum ActivityTypeEnum {

    FIRST_ORDER_DISCOUNT(1, "首单立减", "primary"),
    DISCOUNT(2, "优惠折扣", "success"),
    FULL_REDUCTION(3, "商品满减", "warning"),
    INVITE_REWARD(4, "邀请有礼", "danger");

    private final int code;
    private final String label;
    private final String color;

    ActivityTypeEnum(int code, String label, String color) {
        this.code = code;
        this.label = label;
        this.color = color;
    }

    public int getCode() {
        return code;
    }

    public String getLabel() {
        return label;
    }

    public String getColor() {
        return color;
    }

    public StatusLabel getStatusLabel() {
        return new StatusLabel(label, color);
    }

    public static StatusLabel getLabelByCode(Integer code) {
        if (code == null) {
            return StatusLabel.info("未知");
        }
        for (ActivityTypeEnum type : values()) {
            if (type.code == code) {
                return type.getStatusLabel();
            }
        }
        return StatusLabel.info("未知");
    }

    public static ActivityTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ActivityTypeEnum type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }
}
