package com.yonge.toolset.payment.base.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.yonge.toolset.base.enums.BaseEnum;

/**
 * 交易状态 pending 交易处理中 succeeded 交易成功 failed 交易失败
 *
 * @Author: liweifan
 * @Data: 2022/3/31 14:59
 */
public enum TradeStatusEnum implements BaseEnum<String, TradeStatusEnum> {
    pending("交易处理中"),
    succeeded("交易成功"),
    failed("交易失败"),
    close("交易关闭");

    @EnumValue
    private String code;
    private String msg;

    TradeStatusEnum(String msg) {
        this.code = this.name();
        this.msg = msg;
    }

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

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String getCode() {
        return this.code;
    }

    public static TradeStatusEnum getByName(String name) {
        for (TradeStatusEnum statusEnum : TradeStatusEnum.values()) {
            if (statusEnum.getCode().equals(name)) {
                return statusEnum;
            }
        }
        return null;
    }
}
