You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.6 KiB

10 hours ago
meta {
name: 上传导入文件并预校验
type: http
seq: 1
tags: [
generated
]
}
post {
url: {{baseUrl}}/api/customer/contact/import/upload
body: multipartFormData
auth: inherit
}
body:multipartFormData {
customerId: 753314901191032832
file: @联系人导入模板-V1.xlsx
importMode: APPEND_ONLY
duplicateStrategy: SKIP
}
docs {
# 上传导入文件并预校验
`POST /api/customer/contact/import/upload`(本行兼作对账钥匙,勿手改)
目标客户固定(customerId)。文件守门(.xls/.xlsx、≤20MB、模板版本、≤5 万行)→ 行级判定(必填/字典值域/客户内手机号查重,与执行同口径)→ 任务落待确认态,返回预计数 + 明细(上限 100 条);duplicateStrategy=数据重复时覆盖导入(OVERWRITE)/不导入(SKIP,默认)。
## 请求参数
| 参数 | 类型 | 必填 | 默认 | 说明 |
| --- | --- | --- | --- | --- |
| customerId | string | 是 | - | 导入目标客户 id(固定,不可切换) |
| file | file | 是 | - | Excel 文件(.xls/.xlsx,multipart;单 sheet ≤5 万行) |
| importMode | string | 是 | - | 导入方式:APPEND_ONLY 仅新增 / UPDATE_ONLY 仅更新 / UPSERT 新增或更新 |
| duplicateStrategy | string | 否 | SKIP | 数据重复时策略:SKIP 不导入(默认)/ OVERWRITE 覆盖导入 |
## 请求示例
请求头:Authorization: Bearer {{token}}
Content-Type: multipart/form-data
POST /api/customer/contact/import/upload
customerId=753314901191032832
file=@联系人导入模板-V1.xlsx
importMode=APPEND_ONLY
duplicateStrategy=SKIP
## 响应 data 结构
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| taskId | string | 任务ID(待确认状态) |
| customerId | string | 导入目标客户ID(固定,不可切换) |
| importMode | string | 导入方式:APPEND_ONLY/UPDATE_ONLY/UPSERT |
| duplicateStrategy | string | 重复策略:SKIP 不导入(默认)/ OVERWRITE 覆盖导入 |
| totalCount | number | 数据行总数 |
| insertCount | number | 预计新增数 |
| updateCount | number | 预计更新数(含未变化) |
| failCount | number | 预校验失败数 |
| suspectCount | number | 疑似重复数(不写入,人工处理) |
| rows | array | 预校验明细(上限 100 条) |
| rows[].rowNum | number | 数据行号(从 1 起) |
| rows[].identity | string | 联系人识别(姓名原值) |
| rows[].verdict | string | 判定:INSERT/UPDATE/FAIL/SUSPECT |
| rows[].reason | string | 失败/疑似原因(可放行为空) |
## 错误码
- 67023 联系人导入预校验失败(文件/守门/行级静态)
## 响应示例
// 示例数据(E2E 实测真值),字段结构以上表为准
```json
{
"code": 0,
"success": true,
"message": "success",
"data": {
"taskId": "753314959143731200",
"customerId": "753314901191032832",
"importMode": "APPEND_ONLY",
"duplicateStrategy": "SKIP",
"totalCount": 5,
"insertCount": 3,
"updateCount": 0,
"failCount": 2,
"suspectCount": 0,
"rows": [
{ "rowNum": 1, "identity": "cg034667导甲", "verdict": "INSERT", "reason": null },
{ "rowNum": 2, "identity": "cg034667导乙", "verdict": "INSERT", "reason": null },
{ "rowNum": 3, "identity": "cg034667导丙", "verdict": "INSERT", "reason": null },
{ "rowNum": 4, "identity": "cg034667导丁", "verdict": "FAIL", "reason": "手机号须为 11 位手机号格式" },
{ "rowNum": 5, "identity": "cg034667李经理", "verdict": "FAIL", "reason": "手机号必填(导入查重键)" }
]
}
}
```
}