package com.hzs.common.core.enums;

import com.hzs.common.core.constant.EnumsPrefixConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 订单状态
 * @Author: sui q
 * @Time: 2022/8/31 9:14
 * @Classname: EOrderStatus
 * @PackageName: com.hzs.common.core.enums
 */
@AllArgsConstructor
@Getter
public enum EOrderStatus {

    /**
     * 0=待付款
     */
    WAIT_PAY(0, "待付款", 0, EnumsPrefixConstants.ORDER_STATUS + "0"),

    /**
     * 1=待发货
     */
    PAY(1, "待发货", 0, EnumsPrefixConstants.ORDER_STATUS + "1"),

    /**
     * 2=已合单
     */
    SHIPPING(2, "已合单", 0, EnumsPrefixConstants.ORDER_STATUS + "2"),

    /**
     * 3=待收货
     */
    DELIVERED(3, "待收货", 0, EnumsPrefixConstants.ORDER_STATUS + "3"),

    /**
     * 4=已关闭
     */
    CANCEL(4, "已关闭", 0, EnumsPrefixConstants.ORDER_STATUS + "4"),

    /**
     * 5=已收货
     */
    RECEIVED(5, "已收货", 0, EnumsPrefixConstants.ORDER_STATUS + "5"),

    ;

    /**
     * 实际值
     */
    private final int value;
    /**
     * 显示标签
     */
    private final String label;
    /**
     * 是否启用（0=是,1=否） -- 来源EYesNo
     */
    private final int enable;
    /**
     * 国际化翻译key值
     */
    private final String key;

    /**
     * 会员前端列表
     */
    private static List<EOrderStatus> apiList;

    /**
     * 获取会员前端列表
     *
     * @return
     */
    public static List<EOrderStatus> getApiList() {
        if (null == apiList) {
            apiList = new ArrayList<>();
            apiList.add(WAIT_PAY);
            apiList.add(PAY);
            apiList.add(DELIVERED);
            apiList.add(RECEIVED);
        }
        return apiList;
    }

    public static  EOrderStatus getEOrderStatus(int value){
        for (EOrderStatus eOrderStatus : EOrderStatus.values()) {
            if (eOrderStatus.value == value){
                return eOrderStatus;
            }
        }
        return null;
    }

}
