
package com.tmerclub.cloud.api.payment.constant;

import java.util.Objects;

/**
 * 支付入口 0订单 1充值 2开通会员
 *
 * @author tmerclub
 */
public enum PayEntry {

    /**
     * 订单
     */
    ORDER(0, "订单"),

    /**
     * 充值
     */
    RECHARGE(1, "充值"),

    /**
     * 开通会员
     */
    VIP(2, "开通会员"),

    /**
     * 商家余额支付采购费用(通联支付独有)
     */
    SHOP_BALANCE_PAY_PURCHASE(3, "商家余额支付(通联支付独有)"),

    /**
     * 商家余额支付退款自行处理费用(通联支付独有)
     */
    SHOP_BALANCE_PAY_REFUND_SPREAD(4, "商家余额支付退款自行处理费用(通联支付独有)");

    private final Integer num;
    private final String payName;

    public Integer value() {
        return num;
    }

    PayEntry(Integer num, String payName) {
        this.num = num;
        this.payName = payName;
    }

    public static PayEntry instance(Integer value) {
        PayEntry[] enums = values();
        for (PayEntry statusEnum : enums) {
            if (statusEnum.value().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static String getPayTypeName(Integer value) {
        PayEntry payEntry = instance(value);
        if (Objects.isNull(payEntry)) {
            return null;
        }
        return payEntry.payName;
    }
}
