Appearance
工作微信号管理
工作微信号是平台的数字资产,用于添加嘉宾、红娘、公司、代理等微信好友。本模块提供工作微信号的增删改查、关联管理、转移等完整能力。
核心语义:关联 = 微信好友关系,即该工作微信号已添加到对方的微信中。
关联关系总览
| 关联对象 | 关系 | 说明 |
|---|---|---|
| 管理员 | 1 管理员 : N 工作微信号 | 一个管理员可管理多个工作微信号 |
| 红娘 | 1 工作微信号 : N 红娘 | 通过关联表记录 |
| 公司 | 1 工作微信号 : N 公司 | 通过关联表记录 |
| 代理 | 1 工作微信号 : N 代理 | 通过关联表记录 |
| 用户 | 1 工作微信号 : N 用户 | 通过 users.work_wechat_id 直接关联 |
工作微信号列表
GET /api/open/v1/work-wechats
权限:open:work_wechat:read
查询参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | int | 否 | 页码,默认 1 |
| page_size | int | 否 | 每页条数,默认 20,最大 100 |
| keyword | string | 否 | 搜索关键词(微信号/手机号/设备ID/昵称) |
| status | string | 否 | 状态筛选:active / disabled |
响应示例:
json
{
"code": 200,
"message": "success",
"data": {
"list": [
{
"id": 1,
"admin_id": 5,
"wechat_number": "wx_work_001",
"phone": "13900139000",
"device_id": "DEVICE_001",
"wechat_nickname": "艾恋客服A",
"avatar": "https://oss.ailian.com/avatar/001.jpg",
"qr_code": "https://oss.ailian.com/qrcode/001.jpg",
"status": "active",
"remark": "主要用于嘉宾对接",
"association_count": 12,
"user_count": 56,
"created_at": "2025-06-01 10:00:00",
"updated_at": "2025-07-15 14:30:00"
}
],
"total": 8
}
}注意:
association_count为关联表中的红娘/公司/代理关联数量,user_count为users.work_wechat_id指向该微信号的用户数量。
工作微信号详情
GET /api/open/v1/work-wechats/{id}
权限:open:work_wechat:read
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
响应示例:
json
{
"code": 200,
"message": "success",
"data": {
"id": 1,
"admin_id": 5,
"wechat_number": "wx_work_001",
"phone": "13900139000",
"device_id": "DEVICE_001",
"wechat_nickname": "艾恋客服A",
"avatar": "https://oss.ailian.com/avatar/001.jpg",
"qr_code": "https://oss.ailian.com/qrcode/001.jpg",
"status": "active",
"remark": "主要用于嘉宾对接",
"association_count": 12,
"user_count": 56,
"created_at": "2025-06-01 10:00:00",
"updated_at": "2025-07-15 14:30:00"
}
}创建工作微信号
POST /api/open/v1/work-wechats
权限:open:work_wechat:write
请求体:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| wechat_number | string | 是 | 工作微信号(唯一,最长 100 字符) |
| phone | string | 是 | 手机号(唯一,最长 30 字符) |
| device_id | string | 否 | 设备ID(唯一,最长 100 字符) |
| wechat_nickname | string | 否 | 微信昵称(最长 100 字符) |
| avatar | string | 否 | 微信头像 URL(最长 255 字符) |
| qr_code | string | 否 | 二维码图片 URL(最长 255 字符) |
| remark | string | 否 | 备注(最长 500 字符) |
请求示例:
json
{
"wechat_number": "wx_work_002",
"phone": "13900139001",
"device_id": "DEVICE_002",
"wechat_nickname": "艾恋客服B",
"remark": "主要用于红娘对接"
}响应示例:
json
{
"code": 200,
"message": "success",
"data": {
"id": 2
}
}注意:
wechat_number和phone均需唯一,重复会返回 400 错误。
编辑工作微信号
PUT /api/open/v1/work-wechats/{id}
权限:open:work_wechat:write
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
请求体(所有字段可选,仅传需要修改的字段):
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| wechat_number | string | 否 | 工作微信号 |
| phone | string | 否 | 手机号 |
| device_id | string | 否 | 设备ID |
| wechat_nickname | string | 否 | 微信昵称 |
| avatar | string | 否 | 微信头像 URL |
| qr_code | string | 否 | 二维码图片 URL |
| remark | string | 否 | 备注 |
响应示例:
json
{
"code": 200,
"message": "更新成功",
"data": null
}启用/停用工作微信号
PUT /api/open/v1/work-wechats/{id}/status
权限:open:work_wechat:write
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
查询参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| status | string | 是 | 目标状态:active / disabled |
请求示例:
PUT /api/open/v1/work-wechats/1/status?status=disabled响应示例:
json
{
"code": 200,
"message": "操作成功",
"data": null
}删除工作微信号
DELETE /api/open/v1/work-wechats/{id}
权限:open:work_wechat:write
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
响应示例:
json
{
"code": 200,
"message": "删除成功",
"data": null
}注意:删除前必须先解除所有关联(关联表 + 用户归属),否则返回 400 错误。删除为软删除,释放唯一约束。
关联红娘/公司/代理
POST /api/open/v1/work-wechats/{id}/associate
权限:open:work_wechat:write
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
请求体:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| target_type | string | 是 | 关联类型:matchmaker / company / franchisee |
| target_id | int | 是 | 关联对象 ID |
| remark | string | 否 | 备注 |
请求示例:
json
{
"target_type": "matchmaker",
"target_id": 42,
"remark": "新入职红娘"
}响应示例:
json
{
"code": 200,
"message": "关联成功",
"data": null
}批量关联
POST /api/open/v1/work-wechats/{id}/batch-associate
权限:open:work_wechat:write
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
请求体:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| target_type | string | 是 | 关联类型:matchmaker / company / franchisee |
| target_ids | int[] | 是 | 关联对象 ID 列表 |
| remark | string | 否 | 备注 |
请求示例:
json
{
"target_type": "matchmaker",
"target_ids": [42, 43, 44],
"remark": "批量关联红娘"
}响应示例:
json
{
"code": 200,
"message": "success",
"data": {
"success_count": 3,
"skip_count": 0
}
}注意:已存在的关联会自动跳过,计入
skip_count。
解绑关联
POST /api/open/v1/work-wechats/{id}/disassociate
权限:open:work_wechat:write
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
请求体:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| target_type | string | 是 | 关联类型:matchmaker / company / franchisee |
| target_id | int | 是 | 关联对象 ID |
| remark | string | 否 | 备注 |
响应示例:
json
{
"code": 200,
"message": "解绑成功",
"data": null
}转移关联对象
POST /api/open/v1/work-wechats/{id}/transfer
权限:open:work_wechat:write
将源微信号的关联对象转移到目标微信号。
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 源工作微信号 ID |
请求体:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| target_type | string | 是 | 关联类型:matchmaker / company / franchisee |
| target_ids | int[] | 否 | 指定转移对象 ID 列表,不传则转移该类型全部 |
| target_work_wechat_id | int | 是 | 目标工作微信号 ID |
| remark | string | 否 | 备注 |
请求示例:
json
{
"target_type": "matchmaker",
"target_ids": [42, 43],
"target_work_wechat_id": 3,
"remark": "人员调整,转移关联"
}响应示例:
json
{
"code": 200,
"message": "success",
"data": {
"success_count": 2,
"skip_count": 0,
"details": [
{"target_id": 42, "status": "transferred"},
{"target_id": 43, "status": "transferred"}
]
}
}注意:目标微信号已存在的关联会自动跳过,计入
skip_count,details中标记为"skipped"。
转移管理员归属
POST /api/open/v1/work-wechats/{id}/transfer-admin
权限:open:work_wechat:write
将工作微信号的管理员归属转移到另一个管理员。
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
请求体:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| target_admin_id | int | 是 | 目标管理员 ID |
| remark | string | 否 | 备注 |
请求示例:
json
{
"target_admin_id": 8,
"remark": "管理员离职交接"
}响应示例:
json
{
"code": 200,
"message": "转移成功",
"data": null
}查看关联列表
GET /api/open/v1/work-wechats/{id}/associations
权限:open:work_wechat:read
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
查询参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| target_type | string | 否 | 关联类型筛选:matchmaker / company / franchisee |
| page | int | 否 | 页码,默认 1 |
| page_size | int | 否 | 每页条数,默认 20,最大 100 |
响应示例:
json
{
"code": 200,
"message": "success",
"data": {
"list": [
{
"id": 10,
"work_wechat_id": 1,
"target_type": "matchmaker",
"target_id": 42,
"target_name": "王红娘",
"remark": "新入职红娘",
"created_at": "2025-06-10 09:00:00"
}
],
"total": 12
}
}查看操作日志
GET /api/open/v1/work-wechats/{id}/logs
权限:open:work_wechat:read
路径参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | 工作微信号 ID |
查询参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | int | 否 | 页码,默认 1 |
| page_size | int | 否 | 每页条数,默认 20,最大 100 |
响应示例:
json
{
"code": 200,
"message": "success",
"data": {
"list": [
{
"id": 100,
"work_wechat_id": 1,
"action": "associate",
"target_type": "matchmaker",
"target_id": 42,
"from_value": null,
"to_value": null,
"operator_id": 0,
"operator_name": "Open API",
"remark": "新入职红娘",
"created_at": "2025-06-10 09:00:00"
}
],
"total": 35
}
}操作类型说明:
| action | 说明 |
|---|---|
create | 创建工作微信号 |
update | 编辑信息 |
enable | 启用 |
disable | 停用 |
delete | 删除 |
associate | 关联 |
disassociate | 解绑 |
transfer_in | 转入 |
transfer_out | 转出 |
transfer_admin | 管理员转移 |
注意:通过 Open API 进行的操作,
operator_id为0,operator_name显示为"Open API"。