Skip to content

工作微信号管理 ​

工作微信号是平台的数字资产,用于添加嘉宾、红娘、公司、代理等微信好友。本模块提供工作微信号的增删改查、关联管理、转移等完整能力。

核心语义:关联 = 微信好友关系,即该工作微信号已添加到对方的微信中。

关联关系总览 ​

关联对象关系说明
管理员1 管理员 : N 工作微信号一个管理员可管理多个工作微信号
红娘1 工作微信号 : N 红娘通过关联表记录
公司1 工作微信号 : N 公司通过关联表记录
代理1 工作微信号 : N 代理通过关联表记录
用户1 工作微信号 : N 用户通过 users.work_wechat_id 直接关联

工作微信号列表 ​

GET /api/open/v1/work-wechats

权限:open:work_wechat:read

查询参数:

参数类型必填说明
pageint否页码,默认 1
page_sizeint否每页条数,默认 20,最大 100
keywordstring否搜索关键词(微信号/手机号/设备ID/昵称)
statusstring否状态筛选: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

路径参数:

参数类型说明
idint工作微信号 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_numberstring是工作微信号(唯一,最长 100 字符)
phonestring是手机号(唯一,最长 30 字符)
device_idstring否设备ID(唯一,最长 100 字符)
wechat_nicknamestring否微信昵称(最长 100 字符)
avatarstring否微信头像 URL(最长 255 字符)
qr_codestring否二维码图片 URL(最长 255 字符)
remarkstring否备注(最长 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

路径参数:

参数类型说明
idint工作微信号 ID

请求体(所有字段可选,仅传需要修改的字段):

字段类型必填说明
wechat_numberstring否工作微信号
phonestring否手机号
device_idstring否设备ID
wechat_nicknamestring否微信昵称
avatarstring否微信头像 URL
qr_codestring否二维码图片 URL
remarkstring否备注

响应示例:

json
{
    "code": 200,
    "message": "更新成功",
    "data": null
}

启用/停用工作微信号 ​

PUT /api/open/v1/work-wechats/{id}/status

权限:open:work_wechat:write

路径参数:

参数类型说明
idint工作微信号 ID

查询参数:

参数类型必填说明
statusstring是目标状态: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

路径参数:

参数类型说明
idint工作微信号 ID

响应示例:

json
{
    "code": 200,
    "message": "删除成功",
    "data": null
}

注意:删除前必须先解除所有关联(关联表 + 用户归属),否则返回 400 错误。删除为软删除,释放唯一约束。


关联红娘/公司/代理 ​

POST /api/open/v1/work-wechats/{id}/associate

权限:open:work_wechat:write

路径参数:

参数类型说明
idint工作微信号 ID

请求体:

字段类型必填说明
target_typestring是关联类型:matchmaker / company / franchisee
target_idint是关联对象 ID
remarkstring否备注

请求示例:

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

路径参数:

参数类型说明
idint工作微信号 ID

请求体:

字段类型必填说明
target_typestring是关联类型:matchmaker / company / franchisee
target_idsint[]是关联对象 ID 列表
remarkstring否备注

请求示例:

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

路径参数:

参数类型说明
idint工作微信号 ID

请求体:

字段类型必填说明
target_typestring是关联类型:matchmaker / company / franchisee
target_idint是关联对象 ID
remarkstring否备注

响应示例:

json
{
    "code": 200,
    "message": "解绑成功",
    "data": null
}

转移关联对象 ​

POST /api/open/v1/work-wechats/{id}/transfer

权限:open:work_wechat:write

将源微信号的关联对象转移到目标微信号。

路径参数:

参数类型说明
idint源工作微信号 ID

请求体:

字段类型必填说明
target_typestring是关联类型:matchmaker / company / franchisee
target_idsint[]否指定转移对象 ID 列表,不传则转移该类型全部
target_work_wechat_idint是目标工作微信号 ID
remarkstring否备注

请求示例:

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

将工作微信号的管理员归属转移到另一个管理员。

路径参数:

参数类型说明
idint工作微信号 ID

请求体:

字段类型必填说明
target_admin_idint是目标管理员 ID
remarkstring否备注

请求示例:

json
{
    "target_admin_id": 8,
    "remark": "管理员离职交接"
}

响应示例:

json
{
    "code": 200,
    "message": "转移成功",
    "data": null
}

查看关联列表 ​

GET /api/open/v1/work-wechats/{id}/associations

权限:open:work_wechat:read

路径参数:

参数类型说明
idint工作微信号 ID

查询参数:

参数类型必填说明
target_typestring否关联类型筛选:matchmaker / company / franchisee
pageint否页码,默认 1
page_sizeint否每页条数,默认 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

路径参数:

参数类型说明
idint工作微信号 ID

查询参数:

参数类型必填说明
pageint否页码,默认 1
page_sizeint否每页条数,默认 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"。