package com.gic.haoban.manage.api.enums.contact;

import org.apache.commons.lang3.StringUtils;

public enum ContactFollowTypeEnum {

    // 跟进表中不会有这两个类型
    SMS(-1, "短信/彩信","系统向客户发送了营销短信/彩信",null),
    AI(-2, "AI电话","客户接听了AI电话",null),

    PRIVATE_PHONE(1, "私人电话","私人电话",null),
    WECHAT_SESSION(2, "企微会话","企微会话",null),
    PRODUCT(3, "发送商品","商品",ContactAutoTypeEnum.GOODS_RECOMMEND.getCode()),
    WECHAT_GROUP_SEND(4, "企微群发","企微群发",null),
    CONTACT(5, "标记建联","标记了建联",null),
    AUTO_CONTACT(6, "系统自动标记","系统自动标记",null),
    MATERIAL(7, "营销素材","营销素材",ContactAutoTypeEnum.MATERIAL.getCode());

    private final int code;
    private final String description;
    private final String textMatch;
    private final Integer contactAutoType;

    ContactFollowTypeEnum(int code, String description,String textMatch,Integer contactAutoType) {
        this.code = code;
        this.description = description;
        this.textMatch = textMatch;
        this.contactAutoType = contactAutoType;
    }

    public String getTextMatch() {
        return textMatch;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public Integer getContactAutoType() {
        return contactAutoType;
    }

    public static ContactFollowTypeEnum fromCode(int code) {
        for (ContactFollowTypeEnum type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }

    public static ContactFollowTypeEnum fromTextMatch(String textMatch) {
        if (StringUtils.isBlank(textMatch)) {
            return null;
        }
        for (ContactFollowTypeEnum type : values()) {
            if (textMatch.contains(type.textMatch)) {
                return type;
            }
        }
        return null;
    }
}