package com.sckw.payment.model.constant;

import org.apache.commons.lang3.StringUtils;

/**
 * @author Aick Spt
 * @date 2023-07-27 12:54
 */
public enum WalletChannelEnum {
    HF(1, "1", "huifu"),//汇付
    XS(2, "2", "xinsheng"),//新生
    ZX(3, "3", "zhongxin");//中信

    private final int status;
    private final String value;
    private final String desc;

    WalletChannelEnum(int status, String value, String desc) {
        this.status = status;
        this.value = value;
        this.desc = desc;
    }

    public int getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }

    public String getValue() {
        return value;
    }

    // 添加静态方法，根据 status 获取对应的 desc
    public static String getStatusDesc(int status) {
        for (WalletChannelEnum walletChannelEnum : values()) {
            if (walletChannelEnum.getStatus() == status) {
                return walletChannelEnum.getDesc();
            }
        }
        return null; // 可根据实际需求返回默认值或其他处理
    }

    /**
     * 通过交易方式字典获取渠道
     *
     * @param trading
     * @return
     */
    public static String getValue(String trading) {
        if (StringUtils.isBlank(trading)) {
            return null;
        }
        String substring = trading.substring(1);
        for (WalletChannelEnum walletChannelEnum : values()) {
            if (StringUtils.equals(walletChannelEnum.getValue(), substring)) {
                return walletChannelEnum.getValue();
            }
        }
        return null; // 可根据实际需求返回默认值或其他处理
    }

}
