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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 商户结算模式枚举，决定支付下单是否标记微信分账及后续结算路径。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Getter
@AllArgsConstructor
public enum SettleModeEnum {

    /**
     * 平台代收：资金进平台商户，不传 profit_sharing
     */
    PLATFORM_COLLECT("PLATFORM_COLLECT", "平台代收"),

    /**
     * 微信分账：下单标记 profit_sharing，子单完成后调分账 API
     */
    WECHAT_PROFIT_SHARING("WECHAT_PROFIT_SHARING", "微信分账");

    private final String value;
    private final String desc;

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

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