package com.sckw.order.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @desc: 订单状态枚举
 * @author: yzc
 * @date: 2023-09-18 15:32
 */
@Getter
@AllArgsConstructor
public enum TradeOrderStatusEnum {

    /**
     * 订单状态枚举
     */
    AUDIT(1, "待审核"),
    ING(2, "进行中"),
    DEAL(3, "结算中"),
    SUCCESS(4, "已完成"),
    BACK(5, "审核驳回"),
    CANCEL(6, "已取消"),
    ;
    private final Integer code;
    private final String msg;

    public static String getMsg(Integer code) {
        for (TradeOrderStatusEnum ele : TradeOrderStatusEnum.values()) {
            if (ele.getCode().equals(code)) {
                return ele.getMsg();
            }
        }
        return null;
    }

    public static List<TradeOrderStatusEnum> getSortList() {
        TradeOrderStatusEnum[] enums = TradeOrderStatusEnum.values();
        return Arrays.stream(enums).sorted(Comparator.comparingInt(TradeOrderStatusEnum::getCode)).collect(Collectors.toList());
    }

}
