package com.ylx.massage.enums;

import com.ylx.common.utils.StringUtils;
import lombok.Getter;
import org.apache.commons.compress.utils.Lists;

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

/**
 * @author jianlong
 * @date 2024-03-27 11:51
 * 订单状态枚举
 */
@Getter
public enum OrderStatusEnum {

    ALL(100, "全部"),

    //进行中(待接单,已接单,已出发,已到达,服务中)

    /**
     * 待付款
     */
    WAIT_PAY(-1, "待付款"),

    /**
     * 待接单
     */
    WAIT_JD(0, "待接单"),

    /**
     * 已接单
     */
    RECEIVED_ORDER(1, "已接单"),

    /**
     * 已出发
     */
    DEPART(6, "已出发"),

    /**
     * 已到达
     */
    ARRIVED(2, "已到达"),

    /**
     * 服务中
     */
    SERVICE(3, "服务中"),

    /**
     * 待评价
     */
    WAIT_EVALUATE(4, "待评价"),

    /**
     * 已完成
     */
    COMPLETE(5, "已完成"),

    /**
     * 已取消
     */
    CANCEL(-2, "已取消"),

    /**
     * 已拒绝
     */
    REFUSE(-3, "已拒绝"),

    /**
     * 退单待审核
     */
    CANCEL_APPLICATION_PENDING(7, "退单待审核"),

    /**
     * 退单审核通过
     */
    CANCEL_APPLICATION_PASS(8, "退单审核通过");


    private final Integer code;
    private final String info;

    OrderStatusEnum(Integer code, String info) {
        this.code = code;
        this.info = info;
    }

    public static List<Enumproject> getStatusEnum() {
        ArrayList<Enumproject> objects = Lists.newArrayList();
        for (OrderStatusEnum value : OrderStatusEnum.values()) {
            Enumproject enumproject = new Enumproject();
            enumproject.setInfo(value.getInfo());
            enumproject.setCode(value.getCode());
            objects.add(enumproject);

        }
        return objects;
    }

    public static String getDescByCode(Integer code) {
        for (OrderStatusEnum value : OrderStatusEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getInfo();
            }
        }
        return StringUtils.EMPTY;
    }

}
