package com.jeesharp.business.modules.member.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 华为 IAP 业务订单-支付状态
 *
 * @author jeesharp
 */
@Getter
@AllArgsConstructor
public enum IapPayStatusEnum {

    PENDING(0, "待确认"),
    PAID(1, "已支付"),
    FAILED(2, "失败"),
    CLOSED(3, "关闭");

    private final Integer value;
    private final String desc;

    public static IapPayStatusEnum fromValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (IapPayStatusEnum e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByValue(Integer value) {
        IapPayStatusEnum e = fromValue(value);
        return e != null ? e.getDesc() : "";
    }
}
