package com.cxyxiaomo.epp.common.enums;

import java.util.Arrays;
import java.util.Optional;

public enum OrderStatus {
    PENDING("Pending", "等待确认"),
    PROCESSING("Processing", "已支付，等待发货中"),
    SHIPPED("Shipped", "已发货，等待确认收货"),
    DELIVERED("Delivered", "已送达"),
    CANCELLED("Cancelled", "已取消");

    private final String value;
    private final String description;

    private OrderStatus(String value, String description) {
        this.value = value;
        this.description = description;
    }

    public static OrderStatus get(String code) {
        Optional<OrderStatus> first = Arrays.stream(OrderStatus.values()).filter(e -> e.getValue().equals(code)).findFirst();
        OrderStatus orderStatus = first.orElse(null);
        return orderStatus;
    }

    public String getValue() {
        return value;
    }

    public String toString() {
        return description;
    }
}
