ShareOrdersStatusEnum.java 2.97 KB
package com.yoho.unions.common.enums;

import org.apache.commons.lang.StringUtils;

/**
 * Created by mingdan.ge on 2018/5/10.
 */
public enum ShareOrdersStatusEnum {

    //10-已支付 -> 20-可结算、91-不可结算取消、92-不可结算退货、93-不可结算换货、100 因拆单作废
    //20-可结算 -> 30-打款中 -> 40-已打款
    PAY(1,"10","已支付","待结算"),
    CAN_SETTLE(2,"20","可结算","已达成"),
    SETTLE(3,"30","打款中","打款中"),
    HAS_SETTLE(4,"40","已打款","已打款"),
    ORDER_CANCEL(2,"91","不可结算取消","未达成"),
    ORDER_RETURN(2,"92","不可结算退货","未达成"),
    ORDER_EXCHANGE(2,"93","不可结算换货","未达成"),
    ORDER_DISCARD(2,"100","因拆单作废","未达成"),//前台不展示100类
    ORDER_ZERO(2,"150","0元佣金无效","未达成"),//前台不展示150类
    ACTIVITY_DISCARD(2,"200","活动作废","未达成");//前台不展示200类

    private int level;//低level可以变为高level
    private String code;
    private String desc;
    private String otherDesc;

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

    ShareOrdersStatusEnum(int level,String code, String desc, String otherDesc) {
        this.level = level;
        this.code = code;
        this.desc = desc;
        this.otherDesc = otherDesc;
    }

    public static int getLevelByCode(String code) {
        for (ShareOrdersStatusEnum e : values()) {
            if (e.getCode().equals(code)) {
                return e.getLevel();
            }
        }
        return 0;

    }

    public static String getDescByCode(String code){
        if(StringUtils.isEmpty(code)){
            return null;
        }
        for(ShareOrdersStatusEnum e:values()){
            if (code.equals(e.getCode())) {
                return e.getDesc();
            }
        }
        return null;
    }

    public static String getOtherDescByCode(String code){
        if(StringUtils.isEmpty(code)){
            return null;
        }
        for(ShareOrdersStatusEnum e:values()){
            if (code.equals(e.getCode())) {
                return e.getOtherDesc();
            }
        }
        return null;
    }

    public static boolean isFailOrder(String status) {
        return (!status.equals(ShareOrdersStatusEnum.CAN_SETTLE.getCode())) && (ShareOrdersStatusEnum.getLevelByCode(status)==2);
    }
    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public String getCode() {
        return code;
    }

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

    public String getDesc() {
        return desc;
    }

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

    public String getOtherDesc() {
        return otherDesc;
    }

    public void setOtherDesc(String otherDesc) {
        this.otherDesc = otherDesc;
    }
}