package com.zfire.mall.manager.enums;

import cn.hutool.core.util.EnumUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

@Getter
@AllArgsConstructor
public enum OrderTypeEnum {
    HOME("HOME", "家用"),
    TRADE("TRADE", "商用"),
    RETAIL("RETAIL", "零售"),
    RETAIL_POLICY("RETAIL_POLICY", "销售政策单"),
    GENERAL("GENERAL", "普通"),
    DIFF("DIFF", "收差"),
    ;

    @JsonValue
    @EnumValue
    private final String key;
    private final String value;

    public static String getName(String orderType) {
        if (StringUtils.isNotBlank(orderType)) {
            Map<String, Object> enumMap = EnumUtil.getNameFieldMap(OrderTypeEnum.class, "value");
            return enumMap.get(orderType).toString();
        }
        return "";
    }
}
