
package com.tmerclub.cloud.common.order.constant;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @author tmerclub
 */
public enum ReturnProcessStatusEnum {

    /**
     * 退款申请中
     */
    APPLY(1),

    /**
     * 卖家处理退款
     */
    PROCESSING(2),

    /**
     * 买家已发货
     */
    CONSIGNMENT(3),

    /**
     * 卖家已收货
     */
    RECEIVE(4),

    /**
     * 退款成功
     */
    SUCCESS(5),

    /**
     * 退款关闭
     */
    FAIL(-1);

    private final Integer num;

    ReturnProcessStatusEnum(Integer num) {
        this.num = num;
    }

    public Integer value() {
        return num;
    }

    public static ReturnProcessStatusEnum instance(Integer value) {
        ReturnProcessStatusEnum[] enums = values();
        for (ReturnProcessStatusEnum statusEnum : enums) {
            if (statusEnum.value().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static List<Integer> closeStatus() {
        return Arrays.asList(ReturnProcessStatusEnum.APPLY.value(),ReturnProcessStatusEnum.PROCESSING.value(),
                ReturnProcessStatusEnum.CONSIGNMENT.value(),ReturnProcessStatusEnum.RECEIVE.value());
    }

    public static Boolean shouldClous(Integer status) {
        if (Objects.equals(ReturnProcessStatusEnum.APPLY.value(), status) || Objects.equals(ReturnProcessStatusEnum.PROCESSING.value(), status)
                || Objects.equals(ReturnProcessStatusEnum.CONSIGNMENT.value(), status) || Objects.equals(ReturnProcessStatusEnum.RECEIVE.value(), status)) {
            return true;
        }
        return false;
    }
}
