package com.jeesharp.business.modules.member.constants;

/**
 * 移动端认证相关常量（短信场景、JustAuth 源、会员状态、扫码登录等），避免魔法值。
 *
 * @author jeesharp
 * @version 2026-03-19
 */
public final class MobileAuthConstants {

    private MobileAuthConstants() {
    }

    // ==================== 短信 / 邮箱验证码场景 ====================

    public static final String SMS_SCENE_LOGIN = "LOGIN";

    public static final String SMS_SCENE_BIND = "BIND";

    public static final String SMS_SCENE_RESET_PASSWORD = "RESET_PWD";

    /** 消息中心发送配置编码：移动端登录短信验证码（平台运维维护） */
    public static final String MESSAGE_SEND_CONFIG_APP_LOGIN = "APP_LOGIN";

    // ==================== 会员来源 member.source ====================

    public static final String MEMBER_SOURCE_APP = "APP";

    public static final String MEMBER_SOURCE_WECHAT_MINI = "WECHAT_MINI";

    public static final String MEMBER_SOURCE_ONE_CLICK = "ONE_CLICK";

    // ==================== JustAuth AuthRequestFactory 键（与 jeesharp.justauth.type 一致）====================

    public static final String JUSTAUTH_WECHAT_MINI_APP = "WECHAT_MINI_APP";

    public static final String JUSTAUTH_WECHAT_APP = "WECHAT_APP";

    public static final String JUSTAUTH_WECHAT_MP = "WECHAT_MP";

    public static final String JUSTAUTH_ALIPAY = "ALIPAY";

    public static final String JUSTAUTH_QQ = "QQ";

    public static final String JUSTAUTH_WEIBO = "WEIBO";

    public static final String JUSTAUTH_DOUYIN = "DOUYIN";

    public static final String JUSTAUTH_HUAWEI_APP = "HUAWEI_APP";

    public static final String JUSTAUTH_HUAWEI_ATOMIC = "HUAWEI_ATOMIC";

    public static final String JUSTAUTH_HUAWEI = "HUAWEI";

    // ==================== 会员状态 ====================

    /** 禁用 */
    public static final int MEMBER_STATUS_DISABLED = 0;

    /** 正常 */
    public static final int MEMBER_STATUS_NORMAL = 1;

    /** 已注销 */
    public static final int MEMBER_STATUS_CANCELLED = 3;

    // ==================== Token ====================

    public static final String TOKEN_TYPE_BEARER = "Bearer";

    /** 访问令牌有效期（秒），默认 7 天 */
    public static final long TOKEN_EXPIRE_SECONDS = 604800L;

    /** 二维码登录 Token 有效期（秒），10 分钟 */
    public static final long QR_TOKEN_EXPIRE_SECONDS = 600L;

    /** 扫码登录 Redis key 前缀 */
    public static final String QR_LOGIN_REDIS_PREFIX = "qr:login:";

    /** 二维码 token 片段分隔（时间戳与随机串之间） */
    public static final String QR_TOKEN_PART_SEPARATOR = "_";

    // ==================== 校验 ====================

    /** 中国大陆手机号 */
    public static final String PATTERN_CN_MOBILE = "^1[3-9]\\d{9}$";

    /** 第三方登录「新用户」判定：创建时间在最近 N 秒内 */
    public static final long NEW_USER_CREATE_WITHIN_SECONDS = 60L;

    // ==================== 手机号脱敏 ====================

    public static final int MOBILE_MIN_LENGTH_FOR_MASK = 11;

    public static final int MOBILE_MASK_PREFIX_LEN = 3;

    public static final int MOBILE_MASK_SUFFIX_INDEX = 7;

    public static final String MOBILE_MASK_PLACEHOLDER = "****";

    // ==================== 扫码登录 Redis ====================

    public static final String QR_STATUS_PENDING = "pending";

    public static final String QR_STATUS_SCANNED = "scanned";

    public static final String QR_STATUS_CONFIRMED = "confirmed";

    public static final String QR_STATUS_EXPIRED = "expired";

    public static final String QR_TOKEN_ID_PREFIX = "qr_";

    public static final int QR_TOKEN_RANDOM_LENGTH = 9;

    public static final String QR_LOGIN_INFO_KEY_SUFFIX = ":info";

    // ==================== 通用响应 Map / JSON 字段 ====================

    public static final String JSON_KEY_EXPIRE_SECONDS = "expireSeconds";

    // 扫码登录暂存会员登录信息（与 LoginResultVO 字段名一致）
    public static final String QR_JSON_ACCESS_TOKEN = "accessToken";

    public static final String QR_JSON_TOKEN_TYPE = "tokenType";

    public static final String QR_JSON_EXPIRES_IN = "expiresIn";

    public static final String QR_JSON_REFRESH_TOKEN = "refreshToken";

    public static final String QR_JSON_IS_NEW_USER = "isNewUser";

    public static final String QR_JSON_NEED_BIND_MOBILE = "needBindMobile";

    public static final String QR_JSON_MEMBER_ID = "memberId";

    public static final String QR_JSON_MEMBER_NO = "memberNo";

    public static final String QR_JSON_NICKNAME = "nickname";

    public static final String QR_JSON_AVATAR = "avatar";

    public static final String QR_JSON_MOBILE = "mobile";

    public static final String QR_JSON_LEVEL_ID = "levelId";

    public static final String QR_JSON_LEVEL_CODE = "levelCode";

    public static final String QR_JSON_GROWTH_VALUE = "growthValue";

    public static final String QR_JSON_LEVEL_EXPIRE_DATE = "levelExpireDate";

    public static final String QR_JSON_IS_VIP = "isVip";

    public static final String QR_JSON_VIP_LEVEL_CODE = "vipLevelCode";

    public static final String QR_JSON_VIP_EXPIRE_DATE = "vipExpireDate";
}
