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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 商户应收账流水类型枚举，区分支付应收与退款冲减。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Getter
@AllArgsConstructor
public enum MerchantReceivableEntryTypeEnum {

    /**
     * 支付成功记应收
     */
    PAY("PAY", "支付应收"),

    /**
     * 退款成功记冲减
     */
    REFUND("REFUND", "退款冲减");

    private final String value;

    private final String desc;

    public static MerchantReceivableEntryTypeEnum fromValue(String value) {
        if (value == null) {
            return null;
        }
        for (MerchantReceivableEntryTypeEnum item : values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return null;
    }

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