package com.ruoyi.newwxpay.exception;

import com.ruoyi.common.enums.IIntegerEnum;

import java.util.Objects;

public enum NewWxPayException implements IIntegerEnum {

    // TODO 注意检查错误码，保证系统内唯一
    REFUND_ERROR(9900001, "退款失败"),

    ;

    private Integer code;

    private String msg;

    NewWxPayException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

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

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

    @Override
    public String getMsg() {
        return msg;
    }

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

    public static NewWxPayException getByCode(int code, NewWxPayException[] values) {
        for (NewWxPayException value : values) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }

}
