package com.sckw.payment.model.constant;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * @author Aick Spt
 * @date 2023-07-27 12:54
 */
public enum WalletChannelEnum {
    ALL(0, "0", "all", "全部"),

    //汇付
    HF(1, "1", "huifu", "汇付天下"),
    //新生
    XS(2, "2", "newpay", "新生"),
    //中信
    ZX(3, "3", "citic", "中信银行");

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

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

    public int getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }

    public String getChannel() {
        return channel;
    }

    public String getValue() {
        return value;
    }

    public static String getDesc(String channel) {
        for (WalletChannelEnum walletChannelEnum : values()) {
            if (StringUtils.equals(walletChannelEnum.getChannel(), channel)) {
                return walletChannelEnum.getDesc();
            }
        }
        return "";
    }

    /**
     * 通过交易方式字典获取渠道
     *
     * @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;
    }

    /**
     * 去除全部的渠道
     *
     * @return
     */
    public static List<WalletChannelEnum> channelEnumList() {
        return Arrays.stream(values()).filter(a -> !(WalletChannelEnum.ALL.getStatus() == a.getStatus())).toList();
    }


}
