package com.haha.common.enums;

import com.haha.common.vo.StatusLabel;
import lombok.Getter;

/**
 * 分销佣金状态枚举
 */
@Getter
public enum DistributorCommissionStatus {

    PENDING(0, "待结算", "info"),
    SETTLED(1, "已结算", "success");

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

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

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

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

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