使用场景:

企业将自有系统中的优惠券模板或规则导入兔展平台


**接口地址** `/api/integrate/coupon/template/batchAdd`

**请求方式** `POST`

**consumes** `["application/json"]`

**produces** `["application/json"]`

**接口描述** `优惠券模板导入接口`


**应用权限** `优惠券->券库存数同步、券库券码同步`




#请求参数
***


###请求头参数

| 参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 | schema |
| ------ | ------ | ------ | ------ | ------ | ------ |
| X-Token | 自建应用访问token | header | true | string | |

  
###公共参数

| 参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 | schema |
| ------ | ------ | ------ | ------ | ------ | ------ |
| publicParams | 导入配置 | body | true | object | [优惠券模板导入配置](#优惠券模板导入配置) |
| data | 导入数据,每次最大500条 | body | true | array | [优惠券模板](#优惠券模板) |


###优惠券模板导入配置

| 参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 | schema |
| ------ | ------ | ------ | ------ | ------ | ------ |
| optType | 导入方式(add: 新增) | body | true | String | |
| batchId | 批次ID | body | true| String | |
| batchStatus | 批次同步状态(0:同步开始, 1:同步中, 2:同步完成, 3:同步失败) | body | true | int | |
| batchMsg | 批次同步信息,同步失败时候,失败信息 | body | false | String | |
| batchTotal | 批次总数 | body | false | long | |

###优惠券模板

| 参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 | schema |
| ------ | ------ | ------ | ------ | ------ | ------ |
| thirdCouponTplId | 第三方卡券模板ID | body | true | String | |
| couponTplCode | 卡卷模板编号 | body | false | String | |
| couponTplType | 模板类型,适用范围(1:通用, 2:线上, 3:线下) | body | true | Integer | |
| couponTitle | 卡券标题 | body | true | String | |
| couponSubtitle | 副标题信息,兑换券-兑换内容 | body | false | String | |
| couponDesc | 券描述 | body | false | String | |
| couponType | 卡券类型| body | true | String | 工作台新增卷模板,券模板Key |
| templateStatus | 模板状态(ENABLE:已生效, DISABLE:已禁用) | body | false | true | 不传,默认生效状态 |
| couponCorlor | 卡券颜色,16进制颜色码 | body | false | String | |
| couponBgimg | 卡券背景图片 | body | false | String | |
| validateType | 卡券码领取时效类型(1:时间区间, 2:按领取后有效天数, 3:永久有效) | body | true | Integer | |
| validActiveBegin | 卡券有效开始时间,时间戳或yyyy-MM-dd HH:mm:ss格式,validateType=1必填 | body | false | Date | |
| validActiveEnd | 卡券有效结束时间,时间戳或yyyy-MM-dd HH:mm:ss格式,validateType=1必填 | body | false | Date | |
| validDays | 领取后有效天数,validateType=2必填 | body | false | Integer | |
| limitConsumeAmountFlag | 是否限制消费金额(0:不限制, 1:限制),如设置满多少使用 | body | true | Integer | |
| atConsumeAmount | 满消费金额,单位:分,limitConsumeAmountFlag=1必填 | body | false | Integer | |
| denomination | 代金券面额,单位:分,couponType=DJ必填 | body | false | Integer | |
| discountRate | 折扣券折扣率,区间(0,100],如88表示8.8折,couponType=ZK必填 | body | false | Integer | |
| discountMax | 优惠最大额度,精确到分,couponType=ZK必填 | body | false | Integer | |
| instructions | 卡券使用说明 | body | false | String | |
| shareType | 卡券分享类型(0:否, 1:是) | body | true | Integer | |
| existStock | 卡券是否有库存(0:无限制库存, 1:限制库存) | body | true | Integer | |
| couponStock | 卡券库存,existStock=1必填 | body | false | Integer | |
| limitGetNum | 每个ID最多可领张数,为0时不限制 | body | true | Integer | |
| giveFriendFlag | 是否可转赠(0:否, 1:是) | body | true | Integer | |
| syncWeixinFlag | 是否可同步微信卡券(0:否, 1:是) | body | true | Integer | |
| extInfo | 扩展信息,json数组,key-value存储 | body | false | String | |


###请求示例

```json
{
    "publicParams": {
        "batchId": "777898241806581760",
        "batchStatus": 0,
        "optType": "add"
    },
    "data": [
        {
            "atConsumeAmount": 100,
            "couponSubtitle": "满1.00可用",
            "couponTitle": "易善复测试优惠券",
            "couponTplType": 3,
            "couponType": "MJ",
            "denomination": 100,
            "existStock": 0,
            "giveFriendFlag": 0,
            "limitConsumeAmountFlag": 1,
            "limitGetNum": 0,
            "shareType": 0,
            "syncWeixinFlag": 0,
            "templateStatus": "ENABLE",
            "thirdCouponTplId": "TTPL00000001",
            "validActiveBegin": 1604419200000,
            "validActiveEnd": 1606751999000,
            "validateType": 1
        }
    ]
}
```





#响应参数
***


| 参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 | schema |
| ------ | ------ | ------ | ------ | ------ | ------ |
| code | 状态码 | body | true | string | |
| errorCode | 异常码 | body | true | string | |
| msg | 描述 | body | true | string | |
| data | 响应数据 | body | true | object | [优惠券模板导入结果](#优惠券模板导入结果) |

###优惠券模板导入结果
| 参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 | schema |
| ------ | ------ | ------ | ------ | ------ | ------ |
| status | 任务状态(-1: 失败, 0: 进行中, 1: 成功, 2: 部分导入成功) | body | true | int | |
| errorData | 导入失败数据 | body | true | array | [优惠券模板](#优惠券模板) |

###响应状态

| 状态码 | 说明 | schema |
| ------ | ------ | ------ |
| 200 | OK | |
| 201 | Created | |
| 401 | Unauthorized | |
| 403 | Forbidden | |
| 404 | Not Found | |


###响应示例
```json
{
    "code": "200",
    "errorCode": "SUCCESS",
    "msg": "ok",
    "data": {
        "status": 1,
        "errorData": null,
        "errorMsg": null
    }
}

```