5.12 更新当前用户资料【未授权拦截通过,待登录态联调】

PATCH /tieup/api/v1/me/profile

请求体:

{
  "nickname": "用户昵称",
  "avatar": "https://example.com/avatar.png",
  "gender": 1,
  "birth_date": "1998-08-17",
  "province_code": "310000",
  "province_name": "上海市",
  "city_code": "310100",
  "city_name": "上海市",
  "district_code": "310101",
  "district_name": "黄浦区",
  "signature": "个人签名"
}

请求参数:

参数 类型 必填 说明
nickname string 否 用户展示昵称
avatar string/null 条件必填 头像图片 URL;当前版本市场策略要求头像且用户原资料无头像时必须传入非空值;仅策略明确配置为非必须时允许传 null 清空
gender integer 否 0=未知,1=男,2=女
birth_date string/null 否 出生日期,格式 YYYY-MM-DD;提交非空值时必须已满 18 周岁且周岁不得超过 120,传 null 可清空
province_code string/null 否 省级行政区编码
province_name string/null 否 省级行政区名称
city_code string/null 否 市级行政区编码
city_name string/null 否 市级行政区名称
district_code string/null 否 区县行政区编码
district_name string/null 否 区县行政区名称
signature string 否 个人签名或简介

鉴权:需要 Authorization: Bearer <access_token>。策略定位使用登录用户的 channel_code、X-App-Platform、X-App-Build 和 X-App-Market;不使用客户端 X-App-Channel 覆盖登录用户渠道。

头像策略规则:服务端按 channel_code + X-App-Platform + X-App-Build 精确定位 APP 版本,再按 version_id + X-App-Market 查询市场策略。仅精确命中且 must_upload_avatar=2 时头像非必传;请求头缺失或非法、H5、版本不存在、市场为空或 *、策略不存在及异常配置值均默认必须保留头像。已有头像且本次未提交 avatar 时允许 PATCH 局部更新;必传策略下最终头像为空时返回 422,且不会进入内容审核或写入数据库。

响应字段:

字段 类型 说明
id integer 主键 ID
rong_user_id string 当前使用端对应的融云用户 ID
group_code string 应用分组编码
channel_code string 渠道编码
nickname string 用户昵称
phone string 手机号
avatar string/null 头像 URL,清空或未上传时为 null
profile_completion_step integer 当前资料完善步骤:0=未上传头像,1=已上传头像但核心资料未完善,2=核心资料已完善
gender integer 性别:0=未知,1=男,2=女
birth_date string/null 出生日期,格式 YYYY-MM-DD,未填写时为 null
age integer 根据出生日期实时计算的周岁;出生日期为空或异常时返回 18
province_code / province_name string/null 省份编码和名称
city_code / city_name string/null 城市编码和名称
district_code / district_name string/null 区县编码和名称
signature string/null 个性签名
status integer 账号状态:1=正常,2=禁用,3=最终注销,4=注销中
is_idol integer 是否开通艺人身份:1=是,2=否
candy_balance string 糖果余额
online_status integer 在线状态:0=离线,1=在线
current_identity string 当前使用端:fan=粉丝端,artist=艺人端
available_identities array 当前账号可切换的使用端列表

响应示例:

{
  "code": 200,
  "message": "成功",
    "data": {
      "id": 10001,
      "rong_user_id": "tieup_fan_10001",
      "group_code": "tieup",
      "channel_code": "appstore",
      "phone": "13800138000",
      "nickname": "Tieup用户",
      "avatar": "https://cdn.example.com/avatar.png",
      "profile_completion_step": 2,
      "gender": 2,
      "birth_date": "1998-08-17",
      "age": 28,
      "province_code": "310000",
      "province_name": "上海市",
      "city_code": "310100",
      "city_name": "上海市",
      "district_code": "310101",
      "district_name": "黄浦区",
      "signature": "个人签名",
      "status": 1,
      "is_idol": 2,
      "candy_balance": "1000.00",
      "online_status": 1,
      "current_identity": "fan",
      "available_identities": [
        "fan"
      ]
  }
}

未满 18 周岁响应示例:

{
  "code": 422,
  "message": "未满 18 周岁禁止使用",
  "data": []
}

必须头像响应示例:

{
  "code": 422,
  "message": "当前版本市场策略要求上传头像",
  "data": []
}

说明:当前仅允许更新头像、昵称、性别、出生日期、地区和个性签名等资料字段,接口按 PATCH 语义支持局部更新。头像必传按更新后的最终资料判断:已有头像可不重复提交,无头像时必须上传,必传策略下不能用 null 或空字符串清空;策略明确为非必传时保持原清空能力。首次编辑资料不强制提交 birth_date;本次提交非空 birth_date 时,服务端按 Asia/Shanghai 当日计算周岁,恰好满 18 周岁可保存,未满 18 周岁返回 422 和提示“未满 18 周岁禁止使用”,且不会进入内容审核或写入数据库;未提交或传 null 时不执行年龄校验。不允许通过该接口修改手机号、状态、身份、余额或资料完善步骤。旧请求字段 age 已停用,提交时返回 422 并提示改传 birth_date。响应中的 age 由服务端按 Asia/Shanghai 当日和 birth_date 实时计算,客户端不能提交;profile_completion_step 仍由更新后的当前资料实时计算,未填写 birth_date 时不会进入步骤 2,客户端无需且不能提交该字段。

测试状态:已完成代码实现和 PHP 语法检查,待资料编辑联调。