package com.platform.enums;

/**
 * @author abnerhou
 * @date 2020/9/11 9:58
 * @desciption
 */
public enum OrderStatusEnum {
    WAIT_FOR_PAY(0 , "待支付"),
    CANCEL(101 , "订单取消"),
    DELETE(102 , "订单已删除"),
    WAIT_FOR_DELIVER(201 , "订单已付款，等待发货"),
    HAS_DELIVERED(300 , "订单已发货，等待用户收货"),
    USER_CONFIRM(301 , "用户确认收货"),
    NOT_DELIVERED_REFUND(401 , "没有发货，退款"),
    RECEIVED_REFUND(402 , "已收货，退款退货"),
    FINISH(501 , "终态，已完成"),
    ;
    private int code;
    private String desc;

    OrderStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static OrderStatusEnum getByCode(int code){
        for(OrderStatusEnum status : values()){
            if(status.getCode() == code){
                return status;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
