package cn.pluss.platform.yt;

import cn.pluss.platform.entitiy.SettleTypeEnum;
import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.util.StringUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * TODO
 * 圆通物流状态枚举类
 * @author crystal
 * @date 2022/3/24 16:38
 */
@Getter
@AllArgsConstructor
public enum YtStatusEnum {

    WAIT("WAIT","00","待发货"),
    ACCEPT("ACCEPT","01","已接单"),
    GOT("GOT","02","已揽收"),
    ARRIVAL("ARRIVAL","03","已收入"),
    DEPARTURE("DEPARTURE","04","已发出"),
    PACKAGE("PACKAGE","05","已打包"),
    SENT_SCAN("SENT_SCAN","06","派件中"),
    INBOUND("INBOUND","07","自提柜入库"),
    SIGNED("SIGNED","08","已签收"),
    NOT_SEND("NOT_SEND","90","揽收失败"),
    FAILED("FAILED","99","签收失败");

    private String code;

    private String value;

    private String desc;

    public static String getValueByCode(String code) {
        if(StringUtil.isEmpty(code)){
            MsgException.throwException("圆通code为空,状态转换失败");
        }
        YtStatusEnum[] ytStatusEnums = values();
        for (YtStatusEnum ytStatusEnum : ytStatusEnums) {
            if (ytStatusEnum.code.equals(code)) {
                return ytStatusEnum.getValue();
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        if(StringUtil.isEmpty(code)){
            MsgException.throwException("圆通code为空,状态转换失败");
        }
        YtStatusEnum[] ytStatusEnums = values();
        for (YtStatusEnum ytStatusEnum : ytStatusEnums) {
            if (ytStatusEnum.code.equals(code)) {
                return ytStatusEnum.getDesc();
            }
        }
        return null;
    }
}
