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
 * @create
 */
@Getter
@AllArgsConstructor
public enum ParkingRefundStartTypeEnum {


    /**
     * 支付时间
     */
    PAY_TIME(1, "支付时间"),

    /**
     * 确认退款
     */
    MONTH_BEGIN_TIME(2, "确认退款"),

    /**
     * 无需退款
     */
    MONTH_END_TIME(3, "无需退款"),
    ;

    private final int value;


    private final String desc;


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


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