package com.yuchen.saas.manage.system.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.nest.springwrap.core.tool.utils.Func;

import java.util.Objects;

/**
 * 客户相关
 */
@Getter
@AllArgsConstructor
public class NestCustomerEnum {


    /**
     * 客户类型
     */
    @Getter
    @AllArgsConstructor
    public enum CustomerTypeEnum {
        PARK(1, "园区客户"),

        COMMUNITY(2, "社区客户"),

        SITE(3, "站点客户"),

        SHOP(4, "店铺客户"),

        SERVICE(5, "服务商"),
        ;

        private final int code;
        private final String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestCustomerEnum.CustomerTypeEnum[] enumArray = NestCustomerEnum.CustomerTypeEnum.values();
            for (NestCustomerEnum.CustomerTypeEnum e : enumArray) {
                if (e.getCode() == code) {
                    return e.getDesc();
                }
            }
            return "";
        }

        public static Integer getCodeByDesc(String desc) {
            if (Objects.isNull(desc)) {
                return null;
            }
            NestCustomerEnum.CustomerTypeEnum[] enumArray = NestCustomerEnum.CustomerTypeEnum.values();
            for (NestCustomerEnum.CustomerTypeEnum e : enumArray) {
                if (Func.equalsSafe(desc,e.getDesc()) ) {
                    return e.getCode();
                }
            }
            return null;
        }
    }


    /**
     * 客户主体类型 1:单位；2：企业；3：个体户；4：个人；5：其他")
     */
    @Getter
    @AllArgsConstructor
    public enum CustomerEntityTypeEnum {
        UNIT(1, "单位"),

        ENTERPRISE(2, "企业"),

        INDIVIDUAL(3, "个体户"),

        PERSONAL(4, "个人"),

        OTHER(5, "其他"),
        ;

        private final int code;
        private final String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestCustomerEnum.CustomerEntityTypeEnum[] enumArray = NestCustomerEnum.CustomerEntityTypeEnum.values();
            for (NestCustomerEnum.CustomerEntityTypeEnum e : enumArray) {
                if (e.getCode() == code) {
                    return e.getDesc();
                }
            }
            return "";
        }

        public static Integer getCodeByDesc(String desc) {
            if (Objects.isNull(desc)) {
                return null;
            }
            NestCustomerEnum.CustomerEntityTypeEnum[] enumArray = NestCustomerEnum.CustomerEntityTypeEnum.values();
            for (NestCustomerEnum.CustomerEntityTypeEnum e : enumArray) {
                if (Func.equalsSafe(desc,e.getDesc()) ) {
                    return e.getCode();
                }
            }
            return null;
        }
    }


    /**
     * 证件类型（1：营业执照 2：身份证）
     */
    @Getter
    @AllArgsConstructor
    public enum DocumentTypeEnum {
        LICENSE("1", "营业执照"),

        ID_CARD("2", "身份证"),


                ;
        private final String code;
        private final String desc;

        public static String getDescByCode(String code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestCustomerEnum.DocumentTypeEnum[] enumArray = NestCustomerEnum.DocumentTypeEnum.values();
            for (NestCustomerEnum.DocumentTypeEnum e : enumArray) {
                if (Func.equalsSafe(code,e.getCode()) ) {
                    return e.getDesc();
                }
            }
            return "";
        }

        public static String getCodeByDesc(String desc) {
            if (Objects.isNull(desc)) {
                return null;
            }
            NestCustomerEnum.DocumentTypeEnum[] enumArray = NestCustomerEnum.DocumentTypeEnum.values();
            for (NestCustomerEnum.DocumentTypeEnum e : enumArray) {
                if (Func.equalsSafe(desc,e.getDesc()) ) {
                    return e.getCode();
                }
            }
            return "";
        }
    }


    /**
     * 入驻类型（1：统一运营，2：独立运营）
     */
    @Getter
    @AllArgsConstructor
    public enum CustomerEntryTypeEnum {

        UNIFIED_OPERATIONS(1, "统一运营"),

        INDEPENDENT_OPERATIONS(2, "独立运营"),


        ;

        private final int code;
        private final String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestCustomerEnum.CustomerEntryTypeEnum[] enumArray = NestCustomerEnum.CustomerEntryTypeEnum.values();
            for (NestCustomerEnum.CustomerEntryTypeEnum e : enumArray) {
                if (e.getCode() == code) {
                    return e.getDesc();
                }
            }
            return "";
        }

        public static Integer getCodeByDesc(String desc) {
            if (Objects.isNull(desc)) {
                return null;
            }
            NestCustomerEnum.CustomerEntryTypeEnum[] enumArray = NestCustomerEnum.CustomerEntryTypeEnum.values();
            for (NestCustomerEnum.CustomerEntryTypeEnum e : enumArray) {
                if (Func.equalsSafe(desc,e.getDesc()) ) {
                    return e.getCode();
                }
            }
            return null;
        }

    }


    /**
     * 启用状态 0：禁用；1：启用"
     */
    @Getter
    @AllArgsConstructor
    public enum CustomerStateEnum {

        DISABLE(0, "禁用"),

        ENABLE(1, "启用"),


        ;

        private final int code;
        private final String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestCustomerEnum.CustomerStateEnum[] enumArray = NestCustomerEnum.CustomerStateEnum.values();
            for (NestCustomerEnum.CustomerStateEnum e : enumArray) {
                if (e.getCode() == code) {
                    return e.getDesc();
                }
            }
            return "";
        }

        public static Integer getCodeByDesc(String desc) {
            if (Objects.isNull(desc)) {
                return null;
            }
            NestCustomerEnum.CustomerStateEnum[] enumArray = NestCustomerEnum.CustomerStateEnum.values();
            for (NestCustomerEnum.CustomerStateEnum e : enumArray) {
                if (Func.equalsSafe(desc,e.getDesc()) ) {
                    return e.getCode();
                }
            }
            return null;
        }
    }


}