package com.haha.common.enums;

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

/**
 * 分销提现状态枚举
 */
@Getter
public enum DistributorWithdrawalStatus {

    PENDING(0, "待审核", "info"),
    APPROVED(1, "已通过", "success"),
    REJECTED(2, "已拒绝", "danger"),
    COMPLETED(3, "已完成", "primary");

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

    DistributorWithdrawalStatus(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 (DistributorWithdrawalStatus status : values()) {
            if (status.code == code) {
                return status.getStatusLabel();
            }
        }
        return StatusLabel.info("未知");
    }

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