package com.yc.ship.module.trade.enums;


import com.yc.ship.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * 退款- 状态
 *
 */
@RequiredArgsConstructor
@Getter
public enum RefundStatusEnum implements IntArrayValuable {
    INIT(0, "初始状态"),
    AUDITING(1, "审核中"),
    REFUSE(2, "审核拒绝"),
    PASS(3, "审核通过"),
    WAIT_REFUND(4, "等待退款"),
    REFUNDING(5, "退款中"),
    REFUND(6, "已退款"),
    REFUND_FAIL(7, "退款失败"),
    SUPPLIER_REFUND_MAN_HANDLE(8, "供应商退款失败"),
    FAIL_RETRY(9, "失败已重试"),
    SUPPLIER_REFUND_AUDITING(10, "供应商退款审核中"),
    CANCELED(99, "已取消");



    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(RefundStatusEnum::getStatus).toArray();

    /**
     * 状态值
     */
    private final Integer status;
    /**
     * 状态名
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static String getRefundNameByStatus(Integer status) {
        if (null == status) {
            return null;
        }
        RefundStatusEnum[] elements = values();
        for (RefundStatusEnum element : elements) {
            if (element.getStatus() == status.intValue()) {
                return element.name;
            }
        }
        return null;
    }

}
