package com.haha.common.enums;

public enum CommissionBaseType {

    SALES("SALES", "门店实收销售额"),
    GROSS_PROFIT("GROSS_PROFIT", "门店毛利总额"),
    NET_REVENUE("NET_REVENUE", "扣除成本后营收");

    private final String code;
    private final String description;

    CommissionBaseType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static CommissionBaseType fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (CommissionBaseType commissionBaseType : values()) {
            if (commissionBaseType.code.equals(code)) {
                return commissionBaseType;
            }
        }
        return null;
    }

    public static String getDescription(String code) {
        CommissionBaseType commissionBaseType = fromCode(code);
        return commissionBaseType != null ? commissionBaseType.description : "未知";
    }
}
