jeecgboot/JeecgBoot · warning · JeecgBootException

手机号用户:{phone} 昵称:{realname},{tenantErrorInfo}

Error message

手机号用户:{phone} 昵称:{realname},{tenantErrorInfo}

What it means

Thrown by invitationUserJoin when, for a given tenant id, the user is already linked (userTenantMapper.getUserTenantByTenantId returns non-null). The message is built dynamically: it embeds the phone, realname, and a tenantErrorInfo string describing the existing relation's status (e.g. already a member / under review / refused). JeecgBootException carries the full concatenated message.

Source

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

        //循环租户id
        for (String id:idArray) {
            //获取被邀请人是否已存在
            SysUserTenant userTenant = userTenantMapper.getUserTenantByTenantId(userId, Integer.valueOf(id));
            if(null == userTenant){
                SysUserTenant relation = new SysUserTenant();
                relation.setUserId(userId);
                relation.setTenantId(Integer.valueOf(id));
                relation.setStatus(CommonConstant.USER_TENANT_NORMAL);
                userTenantMapper.insert(relation);
                //给当前用户添加租户下的所有套餐
                this.addPackUser(userId,id);
                //邀请用户加入租户,发送消息
                this.sendInvitationTenantMessage(userByPhone,id);
            }else{
                // 代码逻辑说明: 【QQYUN-5885】邀请用户加入提示不准确------------
                String tenantErrorInfo = getTenantErrorInfo(userTenant.getStatus());
                String errMsg = "手机号用户:" + userByPhone.getPhone() + " 昵称:" + userByPhone.getRealname() + "," + tenantErrorInfo;
                throw new JeecgBootException(errMsg);
            }
        }
    }

    /**
     * 低代码下发送邀请加入租户消息
     * 
     * @param user
     * @param id
     */
    private void sendInvitationTenantMessage(SysUser user, String id) {
        LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
        // 发消息
        SysTenant sysTenant = this.baseMapper.querySysTenant((Integer.valueOf(id)));
        MessageDTO messageDTO = new MessageDTO();
        messageDTO.setToAll(false);
        messageDTO.setToUser(user.getUsername());
        messageDTO.setFromUser("system");

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Read the tenantErrorInfo in the message to see the existing status; if 'already a member', no action is needed.
  2. If the user is under review, have an admin approve/reject the pending relation before re-inviting.
  3. Filter the requested tenant ids to exclude tenants where the user already has an active relation before calling invitationUserJoin.
  4. If the relation is stale/erroneous, remove the SysUserTenant row then retry.

Example fix

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

// after
List<Integer> eligible = allTenantIds.stream()
    .filter(id -> userTenantMapper.getUserTenantByTenantId(userId, id) == null)
    .collect(Collectors.toList());
if (eligible.isEmpty()) {
    return Result.ok("该用户已加入全部所选组织");
}
tenantService.invitationUserJoin(String.join(",", eligible), phone, "");
Defensive patterns

Strategy: validation

Validate before calling

for (String id : ids.split(",")) {
    if (userTenantMapper.getUserTenantByTenantId(userId, Integer.valueOf(id)) != null) {
        // exclude or notify; do not pass this tenant id
    }
}

Try / catch

try {
    tenantService.invitationUserJoin(ids, phone, username);
} catch (JeecgBootException e) {
    if (e.getMessage().startsWith("手机号用户:")) {
        return Result.error("用户已在某组织中:" + e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: Inviting a user who already has a SysUserTenant relation with one of the tenants in the ids list. getTenantErrorInfo(status) maps the existing status code to a human reason; the loop throws on the first conflicting tenant.

Common situations: Re-inviting a user who is already a member; inviting into a tenant where the user is pending review; a previous invitation left a relation row that was never cleaned up; bulk invite that includes tenants the user already belongs to.

Related errors


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