package com.yonge.cooleshow.common.enums.payment;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * 三方支付渠道
 */
@Getter
public enum EPaymentChannel {

    ALIPAY_QR("alipay_qr", "支付宝正扫", 1),
    ALIPAY_WAP("alipay_wap", "支付宝H5支付", 1),
    WX_PUB("wx_pub", "微信公众号支付", 2),
    WX_LITE("wx_lite", "微信小程序支付", 2),
    ;

    private final String msg;
    private final int payType;

    private final String code;

    EPaymentChannel(String code, String msg, int payType) {
        this.code = code;
        this.msg = msg;
        this.payType = payType;
    }

    /**
     * 支付渠道
     * @param code 渠道商
     * @return EPaymentChannel
     */
    public static EPaymentChannel get(String code) {

        EPaymentChannel[] values = EPaymentChannel.values();
        if (StringUtils.isNotBlank(code)) {

            for (EPaymentChannel item : values) {
                if (item.getCode().equals(code)) {
                    return item;
                }
            }
        }
        return WX_PUB;
    }

}
