/**
 * All rights Reserved, Designed By www.freemud.cn
 *
 * @Title: OrderType
 * @Package cn.freemud.enums
 * @Description: 订单状态
 * @author: liming.guo
 * @date: 2018/5/21 14:43
 * @version V1.0
 * @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
 * 注意：本内容仅限于上海非码科技内部传阅，禁止外泄以及用于其他的商业目
 */
package cn.freemud.enums;

import com.freemud.application.sdk.api.ordercenter.enums.orderv1.OrderStatusV1;

/**
 * @warning !!!
 * 这里的订单状态依据的是 老订单的转换操作, 基础服务给出的订单状态如下:
 * 1待支付
 * 2下单
 * 3已接单
 * 4制作完成 5配送中   4/5的状态根据订单类型(自提/外卖)二选一不会同时出现
 * 6已完成
 * 7已关闭(退款完成)
 * @see OrderStatusV1
 */
public enum OrderStatus {

    TAKE_ORDER(1, "下单","place an order"),
    WAIT_PAY(2, "待支付","To be paid"),
    RECEIPT(3, "接单","Receiving orders"),
    DISTRIBUTION(4, "配送中","In delivery"),
    COMPLETE(5, "完成","Complete"),
    CALCEL(6, "取消","Cancel"),
    REFUSE(7,"拒单","Refuse to accept orders"),
    COMPLETE_MAKE(31, "制作完成","Production completed");

    private Integer code;
    private String desc;
    private String descEn;

    OrderStatus(Integer code, String desc,String descEn) {
        this.code = code;
        this.desc = desc;
        this.descEn = descEn;
    }

    public static Integer[] getAllCodes() {
        Integer[] codeArray = new Integer[values().length];
        int i = 0;
        for (OrderStatus orderStatus : values()) {
            codeArray[i] = orderStatus.getCode();
            i++;
        }
        return codeArray;
    }

    public static OrderStatus getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (OrderStatus orderStatus : values()) {
            if (orderStatus.getCode().equals(code)) {
                return orderStatus;
            }
        }
        return null;
    }

    public String getDescEn() {
        return descEn;
    }

    public void setDescEn(String descEn) {
        this.descEn = descEn;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
