package com.wzj.soopin.transaction.enums;

import jakarta.persistence.criteria.CriteriaBuilder;

/**
 * 支付方式枚举
 *
 * @author Chopper
 * @since 2020/12/18 18:08
 */
public enum PaymentMethodEnum {

    /**
     * 微信
     */
    WECHAT("wechatPlugin", 1),
    /**
     * 支付宝
     */
    ALIPAY("aliPayPlugin", 2),
    /**
     * 余额支付
     */
    WALLET("walletPlugin", 3),
    /**
     * 线下转账
     */
    BANK_TRANSFER("bankTransferPlugin", 4),
    /**
     * 易生支付
     */
    EASY_PAY("easyPayPlugin", 5);

    /**
     * 插件id 调用对象，需要实现payment接口
     */
    private final String plugin;
    /**
     * 支付名称
     */
    private final Integer code;

    public String getPlugin() {
        return plugin;
    }

    public Integer getCode() {
        return code;
    }

    /**
     * 根据支付方式名称返回对象
     *
     * @param name
     * @return
     */
    public static PaymentMethodEnum paymentNameOf(String name) {
        for (PaymentMethodEnum value : PaymentMethodEnum.values()) {
            if (value.name().equals(name)) {
                return value;
            }
        }
        return null;
    }

    PaymentMethodEnum(String plugin, Integer code) {
        this.plugin = plugin;
        this.code = code;
    }

}
