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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 分账单状态枚举，描述子单分账从待处理到成功/失败的生命周期。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Getter
@AllArgsConstructor
public enum ProfitSharingStatusEnum {

    PENDING("PENDING", "待分账"),
    PROCESSING("PROCESSING", "处理中"),
    SUCCESS("SUCCESS", "成功"),
    FAIL("FAIL", "失败"),
    CANCELLED("CANCELLED", "已取消"),
    FINISHED("FINISHED", "已完结");

    private final String value;
    private final String desc;

    public static ProfitSharingStatusEnum fromValue(String value) {
        if (value == null) {
            return null;
        }
        for (ProfitSharingStatusEnum e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

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