补齐父手机客户

This commit is contained in:
2026-05-19 09:31:13 +08:00
parent b73f5505bf
commit 893af21ce2
4 changed files with 47 additions and 3 deletions

View File

@@ -177,4 +177,8 @@ public class LbUser implements Serializable {
@TableField("pname")
@Schema(description = "上级用户昵称")
private String pname;
@TableField("pmobile")
@Schema(description = "上级用户手机号")
private String pmobile;
}

View File

@@ -14,4 +14,9 @@ public interface LbUserMapper extends BaseMapper<LbUser> {
* 按用户 id 批量 upsert同步外部用户数据
*/
int upsertBatch(@Param("list") List<LbUser> list);
/**
* 按 pid 关联同租户上级用户,将其 mobile 写入当前用户的 pmobile。
*/
int fillPmobileByTenantId(@Param("tenantId") String tenantId);
}

View File

@@ -376,9 +376,21 @@ public class LbUserServiceImpl extends ServiceImpl<LbUserMapper, LbUser> impleme
page++;
}
int pmobileFilled = fillParentMobile(tid);
if (pmobileFilled < 0) {
result.put("success", false);
result.put("message", "用户已同步,但补齐上级手机号失败");
result.put("synced", totalSynced);
result.put("pmobileFilled", 0);
result.put("remoteCount", firstBody != null ? firstBody.count() : 0);
result.put("pages", page);
return result;
}
result.put("success", true);
result.put("message", totalSynced == 0 ? "接口成功,无用户数据" : "同步完成");
result.put("synced", totalSynced);
result.put("pmobileFilled", pmobileFilled);
result.put("remoteCount", firstBody != null ? firstBody.count() : 0);
result.put("pages", page);
return result;
@@ -398,6 +410,20 @@ public class LbUserServiceImpl extends ServiceImpl<LbUserMapper, LbUser> impleme
}
}
/**
* 同步完成后,按 pid 查找上级用户并将其 mobile 写入 pmobile。
*
* @return 受影响行数;失败返回 -1
*/
private int fillParentMobile(String tenantId) {
try {
return baseMapper.fillPmobileByTenantId(tenantId);
} catch (Exception e) {
log.error("fillParentMobile failed, tenantId={}", tenantId, e);
return -1;
}
}
/**
* @return 实际 upsert 条数;无有效 id 时返回 0失败返回 -1
*/