jeecgboot/JeecgBoot · error · JeecgBootException

当前用户不存在,请核对手机号

Error message

当前用户不存在,请核对手机号

What it means

Thrown by SysTenantServiceImpl.invitationUserJoin in the phone branch: userService.getUserByPhone(phone) returns null, meaning no system account is registered with that phone number. invitationUserJoin invites an existing platform user into one or more tenants, so a non-existent user cannot be invited.

Source

Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTenantServiceImpl.java:117

    @Override
    public boolean removeTenantById(String id) {
        // 查找出已被关联的用户数量
        return super.removeById(Integer.parseInt(id));
    }

    @Override
    @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
    public void invitationUserJoin(String ids, String phone,String username) {
        String[] idArray = ids.split(SymbolConstant.COMMA);
        String userId = null;
        SysUser userByPhone = null;
        // 代码逻辑说明: 【QQYUN-4605】后台的邀请谁加入租户,没办法选不是租户下的用户,通过手机号邀请------------
        if(oConvertUtils.isNotEmpty(phone)){
            userByPhone = userService.getUserByPhone(phone);
            //说明用户不存在
            if(null == userByPhone){
                throw new JeecgBootException("当前用户不存在,请核对手机号");
            }
            userId = userByPhone.getId();
        }else{
            userByPhone = userService.getUserByName(username);
            //说明用户不存在
            if(null == userByPhone){
                throw new JeecgBootException("当前用户不存在,请核对手机号");
            }
            userId = userByPhone.getId();
        }

        //循环租户id
        for (String id:idArray) {
            //获取被邀请人是否已存在
            SysUserTenant userTenant = userTenantMapper.getUserTenantByTenantId(userId, Integer.valueOf(id));
            if(null == userTenant){
                SysUserTenant relation = new SysUserTenant();
                relation.setUserId(userId);

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Verify the phone number digit-for-digit against the user's profile; correct typos and re-submit.
  2. Confirm the user has not been logically deleted (check sys_user delete_flag).
  3. Normalize phone format (strip spaces, country code, dashes) before lookup to match stored format.
  4. If the user genuinely doesn't exist, create the account first, then invite.

Example fix

// before
tenantService.invitationUserJoin(tenantIds, phone, "");

// after
SysUser found = userService.getUserByPhone(normalizePhone(phone));
if (found == null) {
    return Result.error("未找到该手机号对应的用户,请确认号码或先注册账号");
}
tenantService.invitationUserJoin(tenantIds, phone, "");
Defensive patterns

Strategy: validation

Validate before calling

SysUser found = userService.getUserByPhone(normalizePhone(phone));
if (found == null) {
    return Result.error("未找到该手机号用户,请确认或先注册");
}

Prevention

When it happens

Trigger: Calling the invitation endpoint with a phone number that has no matching SysUser record (oConvertUtils.isNotEmpty(phone) is true, so the phone branch is taken). The ids param is a comma-joined list of tenant IDs to invite the user into.

Common situations: Typo in the phone number; the invitee registered with a different phone; the user was soft-deleted; phone stored with a country code or formatting mismatch (e.g. +86 prefix vs bare digits); testing with a fabricated number.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/134db8fc019176cf. Report an issue: GitHub.