package com.ruoyi.info.order.exception;

import com.ruoyi.common.enums.IIntegerEnum;
import java.util.Objects;


/**
 * 异常枚举
 */
public enum OrderRefundExceptionEnum implements IIntegerEnum {

    // TODO 注意检查错误码，保证系统内唯一
    OrderRefund_IS_NOT_EXISTS(180001, "售后订单不存在"),
    Order_STATUS_ERROR(180002, "订单状态无法申请退款"),
    Order_USER_ERROR(180003, "当前订单不是您本人的订单，不可退款！"),
    OrderRefund_STATUS_ERROR(180004, "售后订单不是待退款，无法操作！"),
    OrderRefund_OPERATION_STATUS_ERROR(180005, "售后订单操作状态错误！"),
    OrderRefund_OPERATION_AMOUNT_ERROR(180006, "售后订单退款金额不能为空！"),
    OrderRefund_OPERATION_REASON_ERROR(180007, "售后订单退款原因不能为空！"),
    OrderRefund_HAS_REFUND(180008, "当前订单已存在售后订单，请勿重复申请！"),
    Order_QUANTITY_ERROR(180009, "退款数量大于订单数量，不可申请！");

    private Integer code;

    private String msg;

    OrderRefundExceptionEnum(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 OrderRefundExceptionEnum getByCode(int code, OrderRefundExceptionEnum[] values) {
        for (OrderRefundExceptionEnum value : values) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }

}
