package com.seer.teach.common.enums.pay;

import lombok.Getter;

/**
 * 支付渠道枚举
 */
@Getter
public enum PayChannelEnum {

    /**
     * 微信支付
     */
    WECHAT_JSAPI("WECHAT_JSAPI", "微信支付"),

    /**
     * 支付宝支付
     */
    ALIPAY("ALIPAY", "支付宝支付"),

    /**
     * 学豆支付
     */
    COIN("COIN", "学豆支付");

    private final String code;
    private final String description;

    PayChannelEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据编码获取支付渠道枚举
     *
     * @param code 编码
     * @return 支付渠道枚举
     */
    public static PayChannelEnum fromCode(String code) {
        for (PayChannelEnum channel : PayChannelEnum.values()) {
            if (channel.getCode().equals(code)) {
                return channel;
            }
        }
        return null;
    }
}