# 批量创建经常性支付记录

根据传入的参数，校验并创建经常性支付记录，返回创建失败的原因或创建成功的数据ID

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/compensation/v1/recurring_payment/batch_create
HTTP Method | POST
接口频率限制 | [10 次/秒](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用** | 经常性支付记录写权限(corehr:compensation.recurring_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 | recurring_payment_for_create\[\] | 否 | 要创建的经常性支付记录<br>**数据校验规则**：<br>- 长度范围：`0` ～ `500`
unique_id | string | 是 | 经常性支付记录 unique_id，unique_id 在创建时由上游指定<br>**示例值**："7402510801304718380_7309316347007764012_7402523725868058156_1726070400000_10000"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
user_id | string | 是 | 员工id，具体类型由入参中的 user_id_type 指定<br>**示例值**："7337149697626801708"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
item_id | string | 是 | 薪酬项 id（通过[【查询薪酬项】](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/compensation-v1/item/list)) 接口进行查询）<br>**示例值**："7411039006180312620"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
each_amount | string | 是 | 每次发放金额<br>**示例值**："20.00"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
start_date | string | 是 | 发放开始时间<br>**示例值**："2024-08-01"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
end_date | string | 是 | 发放结束时间<br>**示例值**："2025-08-01"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
currency_id | string | 是 | 币种 id（通过[【查询币种】](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/basic_info-currency/search)) 接口进行查询）<br>**示例值**："6863329932261459464"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符
issuance_type | string | 是 | 发放方式<br>**示例值**："with_salary"<br>**可选值有**：<br>- with_salary：随工资发放<br>- with_cash：现金发放<br>- with_physical_distribution：实物发放<br>- with_year_end_bonus：随年终奖发放
issuance_period | string | 是 | 发放频率<br>**示例值**："year"<br>**可选值有**：<br>- year：年<br>- half_year：半年<br>- quarterly：季度<br>- bimonthly：双月<br>- month：月<br>- biweekly：双周<br>- week：周<br>- day：天<br>- hour：小时
remark | string | 否 | 备注<br>**示例值**："这是个备注"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `3000` 字符
issuance_country_region_id | string | 否 | 发放国家id（可通过 https://open.larkoffice.com/document/uAjLw4CM/ukTMukTMukTM/corehr-v2/basic_info-country_region/search进行查询）<br>**示例值**："6862995745046267400"<br>**数据校验规则**：<br>- 长度范围：`0` ～ `255` 字符

### 请求体示例
```json
{
    "records": [
        {
            "unique_id": "7402510801304718380_7309316347007764012_7402523725868058156_1726070400000_10000",
            "user_id": "7337149697626801708",
            "item_id": "7411039006180312620",
            "each_amount": "20.00",
            "start_date": "2024-08-01",
            "end_date": "2025-08-01",
            "currency_id": "6863329932261459464",
            "issuance_type": "with_salary",
            "issuance_period": "year",
            "remark": "这是个备注",
            "issuance_country_region_id": "6862995745046267400"
        }
    ]
}
```

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-
operate_results | recurring_payment_operate_result\[\] | 每条记录的操作结果。对于创建成功的记录，会返回创建后的经常性支付记录id
id | string | 操作记录的id
unique_id | string | 操作的记录的 unique_id
code | int | 操作结果状态码<br>**可选值有**：<br>- 0："Success" 操作成功<br>- 21280001："The format of the single payment amount is incorrect" 单次发放金额格式不正确<br>- 21280002："The format of the distribution start time is incorrect" 发放开始时间格式不正确<br>- 21280003："The format of the issuance end time is incorrect" 发放结束时间格式不正确<br>- 21270304："No permission for recurring payment record" 没有该经常性支付记录权限<br>- 21270305："The recurring payment type salary item does not exist" 经常性支付类型薪酬项不存在<br>- 21270306："The currency does not exist" 币种不存在<br>- 21270307："The distribution method does not exist" 发放方式不存在<br>- 21270308："The distribution start time is greater than the distribution end time" 发放开始时间大于发放结束时间<br>- 21270309："Employees are not covered by the remuneration rules" 员工不在薪酬项规则适用范围之内<br>- 21270310："The payment method does not match the salary item rules" 发放方式不匹配薪酬项规则<br>- 21270311："Currency mismatch compensation item rules" 币种不匹配薪酬项规则<br>- 21270312："The distribution start date is earlier than the current date and cannot be deleted" 发放开始日期早于当前日期不可删除<br>- 21270313："The recurring payment record does not exist" 该经常性支付记录不存在<br>- 21270314："Payment frequency does not match the salary item" 发放频率不匹配薪酬项<br>- 21270315："The distribution start date and end date overlap" 发放开始日期和结束日期有重叠<br>- 21270316："Issuing country is empty" 发放国家为空<br>- 21270317："Issuing country does not exist" 发放国家不存在<br>- 21270318："The single payment amount cannot be 0" 单次发放金额不允许为0
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 | 服务端异常，请稍后重试

