# 批量创建一次性支付记录

通过传入的一次性支付记录数据，校验并创建一次性支付记录，并返回创建失败原因或创建成功数据的ID
**注意事项**：本接口支持部分成功，失败部分详细报错信息参考 `data.operate_results.code`。
- 当 `data.operate_results.code` 存在非 0 时，响应体 code 仍可能返回 0
- 仅当出现非预期异常时，响应体 code 才会为非 0

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/compensation/v1/lump_sum_payment/batch_create
HTTP Method | POST
接口频率限制 | [10 次/秒](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用** | 一次性支付写权限(corehr:compensation.lump_sum_payment:write)
字段权限要求 | **注意事项**：该接口返回体中存在下列敏感字段，仅当开启对应的权限后才会返回；如果无需获取这些字段，则不建议申请<br>获取用户 user ID(contact:user.employee_id:readonly)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | 是 | **固定值**："application/json; charset=utf-8"

### 查询参数

名称 | 类型 | 必填 | 描述
---|---|---|---
user_id_type | string | 是 | 用户 ID 类型<br>**示例值**：open_id<br>**可选值有**：<br>- open_id：标识一个用户在某个应用中的身份。同一个用户在不同应用中的 Open ID 不同。[了解更多：如何获取 Open ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-openid)<br>- union_id：标识一个用户在某个应用开发商下的身份。同一用户在同一开发商下的应用中的 Union ID 是相同的，在不同开发商下的应用中的 Union ID 是不同的。通过 Union ID，应用开发商可以把同个用户在多个应用中的身份关联起来。[了解更多：如何获取 Union ID？](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-union-id)<br>- user_id：标识一个用户在某个租户内的身份。同一个用户在租户 A 和租户 B 内的 User ID 是不同的。在同一个租户内，一个用户的 User ID 在所有应用（包括商店应用）中都保持一致。User ID 主要用于在不同的应用间打通用户数据。[了解更多：如何获取 User ID？](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-user-id)<br>- people_corehr_id：以people_corehr_id来识别用户<br>**默认值**：`open_id`<br>**当值为 `user_id`，字段权限要求**：<br>获取用户 user ID(contact:user.employee_id:readonly)

### 请求体

名称 | 类型 | 必填 | 描述
---|---|---|---
records | lump_sum_payment_for_create\[\] | 否 | 要创建的一次性支付信息<br>**数据校验规则**：<br>- 长度范围：`0` ～ `500`
unique_id | string | 是 | 外部幂等id，由上游业务决定<br>**示例值**："7402510801304718380_7309316347007764012_7402523725868058156_1726070400000_10000"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
user_id | string | 是 | 员工id，具体类型由入参中的 user_id_type 指定<br>**示例值**："7337149697626801708"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
total_amount | string | 是 | 总金额，字符串表达的数字，单位为入参中 currency_id 给定的币种<br>**示例值**："2000.00"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
binding_period | int | 是 | 绑定期，单位为月<br>**示例值**：2<br>**数据校验规则**：<br>- 取值范围：`0` ～ `2147483647`
currency_id | string | 是 | 币种 id（通过[【查询币种】](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/basic_info-currency/search)) 接口进行查询）<br>**示例值**："6863329932261459464"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
issuance_frequency | int | 是 | 发放次数，必须与 details 的长度一致<br>**示例值**：3<br>**数据校验规则**：<br>- 取值范围：`0` ～ `2147483647`
item_id | string | 是 | 薪酬项 id（通过[【查询薪酬项】](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/compensation-v1/item/list)) 接口进行查询）<br>**示例值**："7411039006180312620"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
reference_period_start_date | string | 否 | 所属期开始日期<br>**示例值**："2024-08-01"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
reference_period_end_date | string | 否 | 所属期结束日期<br>**示例值**："2024-08-01"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
details | lump_sum_payment_detail_for_create\[\] | 是 | 发放明细列表<br>**数据校验规则**：<br>- 长度范围：`0` ～ `2147483647`
issuance_amount | string | 是 | 一次性支付明细发放金额，可转数字的字符串，单位为入参中 currency_id 给定的币种<br>**示例值**："2000.00"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
issuance_status | string | 是 | 发放状态<br>**示例值**："to_be_issued"<br>**可选值有**：<br>- to_be_issued：应发放<br>- not_issued：不发放<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
issuance_way | string | 是 | 发放方式<br>**示例值**："with_salary"<br>**可选值有**：<br>- with_salary：随工资发放<br>- with_cash：现金发放<br>- with_year_end_bonus：随年终奖发放
issuance_time | string | 是 | 发放时间<br>**示例值**："2024-08-01"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
belong_time | string | 是 | 申请发放日期<br>**示例值**："2025-01-20"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
issuance_country_region_id | string | 否 | 发放国家ID（可通过[查询国家/地区信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/basic_info-country_region/search)进行查询）<br>**示例值**："6862995757234914824"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
issuance_pay_group_id | string | 否 | 发放薪资组ID（可通过[获取薪资组基本信息](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/payroll-v1/paygroup/list)<br>进行查询）<br>**示例值**："6862995757234914824"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
remark | string | 否 | 备注<br>**示例值**："该员工表现优异，为其发放一笔奖金"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `3000` 字符

### 请求体示例
```json
{
    "records": [
        {
            "unique_id": "7402510801304718380_7309316347007764012_7402523725868058156_1726070400000_10000",
            "user_id": "7337149697626801708",
            "total_amount": "2000.00",
            "binding_period": 2,
            "currency_id": "6863329932261459464",
            "issuance_frequency": 3,
            "item_id": "7411039006180312620",
            "reference_period_start_date": "2024-08-01",
            "reference_period_end_date": "2024-08-01",
            "details": [
                {
                    "issuance_amount": "2000.00",
                    "issuance_status": "to_be_issued",
                    "issuance_way": "with_salary",
                    "issuance_time": "2024-08-01",
                    "belong_time": "2025-01-20",
                    "issuance_country_region_id": "6862995757234914824",
                    "issuance_pay_group_id": "6862995757234914824"
                }
            ],
            "remark": "该员工表现优异，为其发放一笔奖金"
        }
    ]
}
```

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-
operate_results | lump_sum_payment_operate_result\[\] | 每条记录的操作结果。对于创建成功的记录，会返回创建后的一次性支付记录id
id | string | 操作的记录的 id
unique_id | string | 操作的记录的 unique_id
code | int | 操作结果状态码<br>**可选值有**：<br>- 0："Success" 操作成功<br>- 21270201："The bonus to be changed does not exist" 要更改的奖金不存在<br>- 21270202："Idempotent ID conflict" 幂等id冲突<br>- 21270203："The total amount format is incorrect" 总金额格式不正确<br>- 21270205："Only use the number of decimal places specified in the bonus item rules" 仅限使用奖金项规则中规定的小数位数<br>- 21270206："The sum of the bonus details does not equal the total amount" 奖金明细金额之和不等于总金额<br>- 21270207："issuance frequency not equal to size of details" 奖金明细总数不等于发放次数<br>- 21270208："The number of issuances is less than or equal to 0" 发放次数小于等于0<br>- 21270209："The currency is empty or does not exist" 币种为空或不存在<br>- 21270210："Notes are too long" 备注超长<br>- 21270211："The bonus details amount format is incorrect" 奖金明细金额格式不正确<br>- 21270213："The bonus details payment time format is incorrect" 奖金明细的发放时间格式不正确<br>- 21270214："The bonus details are issued in an illegal manner" 奖金明细的发放方式不合法<br>- 21270215："The bonus details are not in a valid payment status" 奖金明细的发放状态不合法<br>- 21270217："Employees are not covered by the bonus rules" 员工不在奖金项规则适用范围之内<br>- 21270218："The method of awarding bonus details is not covered by the bonus item rules" 奖金明细的发放方式不在奖金项规则适用范围之内<br>- 21270219："Bonus item rules do not support configuration of binding period" 奖金项规则不支持配置绑定期<br>- 21270220："The bonus details payment status is "paid", and cannot be modified" 奖金明细发放状态为「已发放」，不支持修改<br>- 21270221："The bonus item rules already include the currency, and other currencies cannot be specified" 奖金项规则已包含币种，不支持指定其他币种<br>- 21270222："The salary item does not exist" 薪酬项不存在<br>- 21270223："Employee does not exist" 员工不存在<br>- 21270224："The bonus details payment status is "paid", and deletion is not supported" 奖金明细发放状态为「已发放」，不支持删除<br>- 21270225："Bonus rules do not allow multiple awards" 奖金项规则不允许多次发放<br>- 21270226："No data permission" 无数据权限<br>- 21270227："Only positive integers are allowed for the binding period" 绑定期只允许正整数<br>- 21270228："This bonus does not currently support custom binding periods. Please configure and write according to the rules for the binding period of the salary item" 该奖金暂不支持自定义绑定期，请按照薪酬项绑定期规则配置写入<br>- 21270229："The application issuance date must not be later than the issuance date" 申请发放日期不得晚于发放日期<br>- 21270230："The application payment date format of the bonus details is incorrect" 奖金明细的申请发放日期格式不正确
message | string | 操作结果描述

### 响应体示例
```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "operate_results": [
            {
                "id": "7390583861280556588",
                "unique_id": "7390583861280556588",
                "code": 21270202,
                "message": "uqniue id conflict"
            }
        ]
    }
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 2290001 | param is invalid | 参数异常，请检查入参
500 | 2290002 | server error | 服务端异常，请稍后重试

