package com.ym.mec.biz.dal.enums;

import com.ym.mec.common.enums.BaseEnum;
import java.util.Arrays;

/**
 * @program: mec
 * @description: 提现/充值交易类型
 * @author: xw
 * @create: 2019-09-24 16:00
 */
public enum TransTypeEnum implements BaseEnum<Integer, TransTypeEnum> {

    WECHAT(1, "微信"),
    ALIPAY(2, "支付宝"),
    FAST_PAYMENT(3, "快捷支付");

    private Integer code;

    private String description;

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

    @Override
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * 根据枚举值获取枚举信息
     *
     * @param code 枚举值
     * @return 枚举信息
     */
    public static String getDescriptionByCode(Integer code) {
        return Arrays.stream(TransTypeEnum.values())
                .filter(billStatusEnum -> billStatusEnum.getCode().equals(code))
                .findFirst()
                .map(TransTypeEnum::getDescription).orElse(null);
    }
}
