package com.yuchen.saas.payment.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.nest.springwrap.core.log.exception.ServiceException;

import java.util.Objects;

/**
 * @author zhouhanwei
 * @create 2023/6/20 11:07
 */
@Getter
@AllArgsConstructor
public enum VerifyRefundStateEnum {


    /**
     * 待确认退款
     */
    VERIFYING_REFUND(0, "待确认退款"),

    /**
     * 确认退款
     */
    VERIFY_REFUND(1, "确认退款"),

    /**
     * 无需退款
     */
    NOT_NEED_REFUND(2, "无需退款"),
    ;

    private final int value;

    private final String desc;

    public static String getDescByCode(Integer value) {
        if (Objects.isNull(value)) {
            return "";
        }
        VerifyRefundStateEnum[] enumArray = VerifyRefundStateEnum.values();
        for (VerifyRefundStateEnum e : enumArray) {
            if (e.getValue() == value) {
                return e.getDesc();
            }
        }
        return "";
    }

    public static VerifyRefundStateEnum getEnumByCode(Integer value) {
        VerifyRefundStateEnum[] enumArray = VerifyRefundStateEnum.values();
        for (VerifyRefundStateEnum e : enumArray) {
            if (e.getValue() == value) {
                return e;
            }
        }
        throw new ServiceException(SaasPaymentErrorEnums.DATA_NOT_EXIST);
    }
}
