package com.cool.store.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 *  * 通用错误返回处理，后续全部将使用这个返回，请遵守以下规范。
 *  * 1.枚举名必须要大写。
 *  * 2.枚举中包含属性：code,msg,en(英文尽量写)
 *  * 3.code的命名以系统模块划分，前三位为模块划分。逐级细分。（7位数字先到先取原则，细化不浪费）
 * @author zhangchenbiao
 * @FileName: ErrorCodeEnum
 * @Description: 返回响应状态和文案枚举
 * @date 2023-05-19 04:30
 */
public enum ErrorCodeEnum {

    PARTNER_MOBILE_INCORRECT(418, "请输入正确的手机号", null),
    PUBLIC_LINE_NOT_FOLLOW(419, "该线索已存在公海，无跟进人", null),
    LINE_EXIST_FOLLOW(420, "该线索已存在，跟进人为【{0}，{1}】", null),

    ERROR_MESSAGE(421, "{0}", null),


    /**
     * 000000 未知错误
     */
    UNKNOWN(000000, "未知错误", null),
    /**
     * 2000001 token与当前登录企业不匹配
     */
    TOKEN_ERROR(2000001,"请求异常，与当前登录企业不匹配",null),
    FAIL(400000, "FAIL", null),
    ACCESS_TOKEN_INVALID(400005, "Invalid token", null),
    PARAMS_VALIDATE_ERROR(400003, "参数校验失败！", null),
    LOGIN_ERROR(400004, "登录失败", null),
    ENTERPRISE_INIT(400006, "企业正在初始化，请稍后访问！",null),
    NOT_AUTH(400007, "暂无权限，请联系管理员！", null),
    USER_FREEZE(1021019,"账号被冻结，请联系管理员",null),
    ENTERPRISE_NOT_EXIST(1021020,"企业不存在",null),
    USER_NOT_EXIST(1021021,"用户不存在",null),
    JOBNUMBER_NOT_EXIST(1021017,"用户工号不存在",null),
    USER_WAIT_AUDIT(1021018,"账号审核中，请联系企业管理员",null),
    OPERATION_OVER_TIME(1021019, "您的操作过于频繁,休息一下~", null),
    GET_APP_SECRET_ERROR(1021020, "获取secret异常", null),
    WX_SERVICE_ERROR(1021021, "调用微信服务异常", null),
    SESSION_KEY_ERROR(1021022, "sessionKey过期", null),
    GET_WECHAT_USER_INFO_FAIL(1021023,"获取小程序用户信息失败", null),
    USER_GROUP_NAME_EXIST(1021076, "用户分组名称已存在", null),
    USER_GROUP_NOT_EXIST(1021077, "用户分组不存在", null),
    GET_INFO_ERROR(1021078, "获取信息异常", null),
    GET_PHONENUMBER_INFO_ERROR(1021079, "手机号归属地获取异常", null),
    IDENTITY_CARD_PARSE_FAIL(1021080, "身份证解析失败", null),
    WECHAT_BIND_OTHER_MOBILE(1021081, "授权号码有误，请核对", null),
    BUSINESS_LICENSE_PARSE_FAIL(1021082, "营业证照解析失败", null),
    BUSINESS_LICENSE_OR_ID_CARD_REPEAT(1021083, "身份证或企业信用编码重复", null),
    PARAMS_REQUIRED(400002, "参数缺失！", null),
    DATA_CONVERT_ERROR(400002, "日期转换异常！", null),
    PARENT_NODE_NOT_EXIST(400002, "父节点不存在", null),


    LINE_ID_IS_NOT_EXIST(500001, "线索信息不存在！", null),
    WORK_FLOW_STAGE_PASS_ERROR(500002, "审核失败，非对应阶段！", null),
    PARTNER_USER_NOT_EXIST(500003, "加盟商用户信息不存在！", null),
    ZONE_NOT_EXIST(500004, "战区不存在！", null),
    PARTNER_BASEINFO_NOT_EXIST(500005, "基本信息不存在！", null),
    INTENT_INFO_NOT_EXIST(500006, "意向信息不存在！", null),
    INTENT_WHAT_NOT_EXIST(500016, "加盟问卷信息不存在！", null),
    INTENT_AREA_NOT_BING_ZONE(500007, "意向区域没有绑定战区 分配招商经理失败！", null),
    PUBLIC_LINE_NOT_OPERATE(500008, "公海线索不允许操作！", null),
    PARTNER_BASE_INFO_NOT_EXIST(500009, "加盟商信息不存在！", null),
    LINE_STATUS_NOT_ALLOW_OPERATE(500010, "当前线索状态不允许该操作！", null),
    TASK_STATUS_NOT_ALLOW_OPERATE(500011, "当前任务状态不允许该操作！", null),
    DATELINE_BEFORE_NOW(500012, "截止时间不能早于当前时间！", null),
    NO_TRANSFER_REQUIRED(500013, "招商经理现有私海线索无需转让，请检查后重试！", null),
    NO_BATCH_TRANSFER_REQUIRED(500014, "已选线索包含此招商经理现有私海线索，无需转让，请检查后重试!", null),
    PARTNER_MOBILE_EXIST(500010, "手机号码已存在，请核实！", null),
    MOBILE_EXIST(500015, "此手机号码已存在，请修改后重试", null),
    INVESTMENT_MANAGER_NOT_EXIST(500016, "当前招商经理不存在", null),
    PARTNER_MOBILE_EXIST_0(500017, "手机号码已存在", null),
    TIME_OCCUPIED(500018, "预约时间被占用", null),
    LINE_PAY_IS_NOT_EXIST(500019, "意向金信息不存在！", null),
    INTENT_PASS(500020, "审核已通过，请刷新页面！", null),
    APPOINTMENT_TIME_FAIL(500020, "预约失败，请刷新后再试", null),

    POINT_NOT_COMPLETE(600000, "铺位信息未填写完全，请完善后生成评估报告", null),
    POINT_NOT_EXIST(600001, "铺位信息不存在", null),
    POINT_SIGNED(600002, "操作失败，铺位已签约", null),
    NOT_ALLOW_OPERATE(600003, "当前状态不允许该操作", null),
    POINT_AUDIT_NOT_SETTING(600004, "选址审批未设置", null),
    NO_PERMISSION(600004, "暂无处理审批任务权限", null),
    POINT_AUDIT_NODE_ERROR(600005, "当前审批任务异常", null),
    USER_NOT_TODO_AUDIT(600005, "当前用户没有待审批的任务", null),
    NOT_ALLOW_MODIFY_WANT_SHOP_NUM(600006, "当前阶段不允许直接修改意向开店数量", null),
    USER_NOT_ALLOW_ENTER_ROOM(600007, "当前用户不允许进入面试房间", null),

    SHOP_STAGE_ERROR(600008, "店铺阶段错误", null),
    SHOP_NOT_EXIST(600009, "店铺不存在", null),
    POINT_IS_SELECTED(600010, "该铺位已被其他人选择", null),
    POINT_ALREADY_SELECT(600011, "该铺位已被您选择", null),
    SHOP_IS_SELECTED(600012, "该店铺已选址", null),
    SHOP_STAGE_NOT_OPERATE(600013, "当前店铺所处阶段不允许该操作", null),
    POINT_IS_LOCK(600014, "当前铺位已被锁定,刷新后再试", null),
    POINT_IS_INVALID(600015, "该铺位已失效", null),
    POINT_SELECTED(600016, "该铺位已被选择", null),
    NOT_EXIST_UNSELECT_POINT(600017, "当前没有未选择的铺位", null),
    SELECT_POINT_ERROR(600018, "铺位选中失败", null),

    OPEN_NEW_SHOP_RECORD_NOT_EXIST(700001, "开店申请记录不存在", null),
    OPEN_NEW_SHOP_RECORD_AUDITED(700002, "开店申请已审核", null),
    OPEN_NEW_SHOP_RECORD_WAIT_AUDIT(700003, "提交失败，您有开店申请正在审核中", null),

    INTERVIEW_ENTER_FAIL(1021101, "进入面审间失败", null),
    DINGDING_USER_NOT_EXIST(1021102, "用户钉钉信息不存在，无法发起资质审核！", null),
    INTERVIEW_NOT_EXIST(1021103, "面审信息不存在！", null),
    INTERVIEW_AND_PARTNER_ID_IS_NULL(1021104, "加盟商用户ID&线索ID和面审官ID不能同时为空！", null),
    INTERVIEW_PLAN_IS_NULL(1021105, "未查询到相关面审安排！", null),
    DATE_PARAMS_IS_ERROR(1021106, "日期参数错误！", null),
    INTERVIEW_PLAN_NOT_EXIST(1021107, "面审计划不存在！", null),
    FEISHU_DELETE_SCHEDULE_ERROR(1021108, "删除原面审安排失败！", null),
    CREATE_CALENDAR_EVENT_FAIL(1021109, "创建面审安排失败！", null),
    FEISHU_UPDATE_SCHEDULE_ERROR(1021110, "开始前10分钟不允许修改时间！", null),
    INTERVIEW_STATUS_ERROR(1021111, "当前面审状态不允许该操作！", null),
    INTERVIEW_PLAN_ALREADY_EXIST(1021112, "面审计划已存在，请勿重复申请！", null),
    INTERVIEW_LINE_ID_IS_NULL(1021113, "线索id为空！", null),
    INTERVIEW_INTERVIEW_TIME_IS_UNUSABLE(1021114, "当前预约时间不可用，请和线索用户协商其他时间后确定预约时间\n面审人：{0} 手机号：{1}", null),
    INTERVIEW_PARTNER_NOT_EXIST(1021115, "线索下的加盟商不存在！", null),
    INTERVIEW_STATUS_NOT_TRANSFER(1021116, "当前面审状态不允许转让！ 面审状态:{0}", null),
    MOBILE_WECHAT_EXIST(1021116, "此号码已绑定其他微信", null),
    INTERVIEW_STATUS_WAS_AUDITED(1021117, "当前面审已审核", null),

    ROOM_STATUS_ERROR(10211156, "当前面审房间状态不允许进行该操作！", null),
    MOBILE_APP_NOT_ONLINE_ERROR(10211157, "呼叫失败，请确认呼出号码正确并检查是否安装并打开呼叫插件", null),
    CALL_RECORD_NOT_EXIST_ERROR(10211158, "通话记录不存在！", null),
    CALL_UP_ERROR(10211159, "拨出电话异常！", null),
    CREATE_CALL_REQUEST_ERROR(10211160, "创建电话请求失败！", null),

    CREATE_APPOINTMENT_TIME_ERROR(10211161, "当前时间不可预约面审，请选择其他时间", null),

    USER_CHANNEL_NOT_EXISTS(10211162, "当前用户渠道不存在", null),
    LINE_ALREADY_EXISTS(10211163, "该线索已存在，跟进人为{0}", null),
    LINE_EXISTS_IN_PUBLIC_SEA(10211164, "该线索已存在，请前往公海认领", null),
    CONTENT_DUPLICATED(10211200, "动态标题重复！", null),
    SIGN_FAIL(600000, "验签失败", null),
    GET_ACCESSTOKEN_ERROR(600001, "获取小程序TOKEN错误！", null),
    NEW_MOBILE_HAS_EXIST(600002,"加盟商用户信息已存在",null),
    INSPECTION_USER_OCCUPY(600003,"当前稽核人已经配置其他战区",null),
    INSPECTION_INFO_NOT_EXIST(600005, "稽核信息不存在！", null),
    OPEN_AREA_NULL(600006,"归属地区不能为空",null),
    NOT_IN_PUBLIC_SEA(600007,"当前线索不在公海 不支持分配招商经理",null),

    LABEL_GROUP_IN_USE(120001, "该标签组下存在标签，不可删除；请确保该标签组下标签数量为0后再进行删除", null),
    LABEL_GROUP_EXIST(120002, "该标签组已存在，请重新输入", null),
    LABEL_EXIST(120003, "该标签已存在，请重新输入", null),


    OPEN_AREA_IS_NOT_EXISTS(107006, "意向区域城市不存在", null),

    REGION_NOT_EXIST(108001, "区域不存在",null),
    ONLY_WAR_REGION_CONFIG(108002, "意向省市只能配置到大区",null),

    NOT_APPROVE_NODE(109001, "不是审批节点",null),


    TIME_FALSE(109002, "结束时间不能早于开始时间",null),

    BUSINESS_ID_NOT_EXIST(109003, "kdzBusinessId解析异常,请检查",null),

    VERIFY_MD5_FALSE(109004, "验签失败,请检查",null),

    LINE_PAY_FALSE(109005, "付款信息查询失败",null),

    LICENSE_NOT_EXIST(109006, "证照不存在",null),

    FOOD_BUSINESS_LICENSE_PARSE_FAIL(109007, "食营证照解析失败", null),


    STORE_NUM_NOT_FOUND(109008, "未找到门店编码", null),

    SIGN_FRANCHISE_NOT_FOUND(109009, "加盟合同签约信息为空", null),

    UNISSUED_STATEMENT(109010, "该门店未发布账单，无法付款", null),

    FRANCHISE_AGREEMENT_FALSE(109011, "特许经营合同API调用失败", null),

    NEW_STORE_FALSE(109011, "新店开业流程API调用失败", null),

    AUDIT_RESULT_FALSE(109012, "意向加盟合同API本次调用结果与上一次不一致", null),


    TIME_NULL_FALSE(109013, "有时间为空", null),

    UNISSUED_STATEMENT_2(109014, "该门店已发布账单", null),

    DUPLICATE_SUBMISSION(109015, "重复提交！", null),


    INSERT_OPENING_OPERATION_PLAN_AUDIT_FALSE(103001,"插入运营方案审核信息失败",null),
    INSERT_OPENING_OPERATION_PLAN_FALSE(103002,"插入运营方案失败",null),
    SHOP_ID_IS_NULL(103003,"验参shopId失败，为空",null),
    ACTIVITY_THEME_LENGTH_FALSE(103004,"活动主题长度大于100",null),
    SURVEYRESULT_LENGTH_FALSE(103005,"调研结果长度大于100",null),
    ID_IS_NULL(103006,"验参Id失败，为空",null),
    UPDATE_AUDIT_PLAN_FALSE(103007,"修改AUDIT_PLAN失败",null),
    UPDATE_PLAN_FALSE(103008,"修改PLAN失败",null),
    UPDATE_SHOP_SUB_STAGE_STATUS_FALSE(103009,"修改开业运营方案阶段状态失败",null),
    SHOP_ID_NOT_EXIST(103010,"shopId不存在",null),
    FIRST_ORDER_PARAM_NULL(103020,"首批订货金参数为空",null),
    USER_NOT_LOGIN(103021,"用户未登录",null),
    XFSG_SERVICE_ERROR(103099,"鲜丰服务调用失败",null),
    GET_FIRST_ORDER(103021,"获取鲜丰首批订货金失败",null),
    YLF_ERROR(110001, "云立方接口异常！异常信息：{0}", null),
    YLF_DATA_IS_NULL(110002, "请联系工程维护云立方系统门店信息!", null),
    //装修
    THREE_ACCEPTANCE(121001,"提交三方验收失败",null),
    CHECK_ITEM(12002,"插入检查项失败",null),
    FITMENT_FAIL(12003,"装修款阶段未完成",null),
    SEE_ACCEPTANCE_ERROR(12004,"获取鲜丰撤场数据失败",null),
    SEE_ACCEPTANCE_AUDIT_NULL(12005,"视觉验收结果为空",null),
    STATUS_NOT_SUPPORT_SUMMIT(121006,"该状态不支持上传",null),
    DESIGN_NO_COMPLETE(121007,"请先完成设计阶段！",null),
    SIGN_COMPLETED(121008,"你已完成验收,无需重复操作！",null),

    UPDATE_FAIL(131000,"修改失败，表单不存在！",null),
    LICENSE_LEGAL_STAGE_FAIL(131001,"营业执照阶段未上传！",null),
    GET_JURIDICAL_ID_CARD_NO_FAIL(131002,"获取法人身份证信息失败！",null)
    ;



    protected static final Map<Integer, ErrorCodeEnum> map = Arrays.stream(values()).collect(
            Collectors.toMap(ErrorCodeEnum::getCode, Function.identity(), (a, b)->a));
    private int code;

    private String message;
    private String en;

    ErrorCodeEnum(int code, String message, String en) {
        this.code = code;
        this.message = message;
        this.en=en;
    }


    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ErrorCodeEnum getByCode(Integer code) {
        return map.get(code);
    }


}
