# 更新买赠促销活动

更新促销活动。
<div class='note'><b>注：</b><br><br>新数据将替换旧数据。如果只想更新促销活动的一部分，也需要在请求中传入所有必需数据。</div>
促销活动会在用户购买时赠送免费赠品。
该促销活动可应用于项目中的任意购买，也可应用于包含特定商品的购买。

Endpoint: PUT /v3/project/{project_id}/admin/promotion/{promotion_id}/bonus
Version: 2.0.0
Security: basicAuth

## Path parameters:

  - `project_id` (integer, required)
    项目ID。您可以在[发布商帐户](https://publisher.xsolla.com/0/projects/0/)的项目名称旁找到此参数；使用项目时，也可以在浏览器地址栏中找到此参数。URL格式如下：`https://publisher.xsolla.com/<merchant_id>/projects/<project_id>`。

  - `promotion_id` (integer, required)
    促销活动ID。项目内的唯一促销活动标识符。

## Request fields (application/json):

  - `id` (integer)
    促销活动ID。项目内的唯一促销活动标识符。

  - `promotion_periods` (array)
    促销活动有效期。若指定了多个时间段，则`date_from`和`date_until`均为必需。

  - `promotion_periods.date_from` (string, required)
    指定促销活动的开始日期。
    Example: 2020-08-11T10:00:00+03:00

  - `promotion_periods.date_until` (string | null)
    促销活动的结束日期。设置为`null`时，促销活动永久有效。仅在指定单个有效期时可设置为`null`。
    Example: 2020-08-11T20:00:00+03:00

  - `condition` (array | null, required)
    要应用促销必须在购买项中包含的一组商品。如果此参数为`null`，则促销将应用于项目内的任何购买。

  - `condition.sku` (string)
    商品SKU。

  - `attribute_conditions` (array)
    用于验证用户属性的条件。根据用户属性是否匹配所有指定条件，确定促销活动是否可用。

  - `attribute_conditions.attribute` (string, required)
    用户属性代码。

  - `attribute_conditions.type` (string, required)
    用户属性类型。
    Enum: "string"

  - `attribute_conditions.operator` (string, required)
    按条件执行的操作类型。用于string属性类型。
可能值：
- `eq` — 等于
- `ne` — 不等于
    Enum: "eq", "ne"

  - `attribute_conditions.value` (string, required)
    与用户属性值进行比较的条件值。类型取决于属性类型。

  - `attribute_conditions.can_be_missing` (boolean)
    表示即使用户属性中缺少该属性，条件仍会被视为满足。传入`true`可向不具有此属性的用户显示该商品。具有该属性但属性值与条件中指定值不匹配的用户将看不到该商品。传入`false`时，具有该属性但属性值不匹配，或缺少该属性的用户都将看不到该商品。

  - `attribute_conditions.operator` (string, required)
    按条件执行的操作类型。用于number属性类型。
可能值：
- `eq` — 等于
- `ne` — 不等于
- `gt` — 大于
- `ge` — 大于或等于
- `lt` — 小于
- `le` — 小于或等于
    Enum: "eq", "ne", "gt", "ge", "lt", "le"

  - `attribute_conditions.operator` (string, required)
    按条件执行的操作类型。用于date属性类型。
可能值：
- `eq` — 等于
- `ne` — 不等于
- `lt` — 早于
- `gt` — 晚于
- `le` — 早于或等于
- `ge` — 晚于或等于
    Enum: "eq", "ne", "lt", "gt", "le", "ge"

  - `bonus` (array | null, required)

  - `bonus.sku` (string)
    商品SKU。

  - `bonus.quantity` (number)
    商品数量。

  - `limits` (object)
    促销活动限制。

  - `limits.per_user` (integer | null)
    针对单独用户的促销活动限制。

  - `limits.recurrent_schedule` (object | null)
    限制数刷新周期。

  - `limits.recurrent_schedule.per_user` (any)
    用户的限制数刷新周期。

  - `limits.recurrent_schedule.per_user.interval_type` (string)
    循环刷新周期类型。
    Enum: "daily"

  - `limits.recurrent_schedule.per_user.time` (string)
    所需时区中的限制数刷新时间（四舍五入到小时）。
    Example: 11:00:00+03:00

  - `limits.recurrent_schedule.per_user.reset_next_date` (integer)
    限制数刷新的日期和时间（Unix时间戳）。
    Example: 1677553200

  - `limits.recurrent_schedule.per_user.displayable_reset_start_date` (string)
    第一次限制数刷新的日期和时间 (ISO 8601)。
    Example: 2023-02-28T11:00:00+08:00

  - `limits.recurrent_schedule.per_user.displayable_reset_next_date` (string)
    应重置限制数的日期和时间(ISO 8601)。
    Example: 2023-02-28T11:00:00+08:00

  - `limits.recurrent_schedule.per_user.day_of_week` (integer | null)
    在一周中的哪一天刷新限制数。其中1是星期一，7是星期日。仅当限制刷新周期类型为`weekly`时不为`null`。

  - `limits.recurrent_schedule.per_user.day_of_month` (integer | null)
    在一个月中的哪一天刷新限制数。如果某个月没有所选日期，则会在该月最后一天刷新。仅当限制刷新周期类型为`monthly`时不为`null`。

  - `price_conditions` (array | null)
    包含条件的对象数组，用于设置应用促销活动的价格范围。 促销活动仅应用于价格符合数组中所有条件的商品。如果传递此数组，请将[condition](/zh/api/shop-builder/operation/create-bonus-promotion/#!path=condition&t=request)对象的值设置为`null`。

  - `price_conditions.operator` (string, required)
    用于设置应用促销活动的价格范围的比较运算符。
可能值：
- `ge` — 大于或等于
- `gt` — 大于
- `le` — 小于或等于
- `lt` — 小于
- `eq` — 等于
- `ne` — 不等于
    Enum: "ge", "gt", "le", "lt", "eq", "ne"

  - `price_conditions.value` (string, required)
    用于决定应用促销活动的价格范围的值。

  - `excluded_promotions` (array)
    应用此促销活动时要排除的促销活动ID列表。示例：`[12, 789]`
    Example: [12,789]

  - `is_enabled` (boolean)
    是否启用了促销活动。
    Example: true

## Response 401 fields (application/json):

  - `statusCode` (integer)
    Example: 401

  - `errorCode` (integer)
    Example: 1020

  - `errorMessage` (string)
    Example: [0401-1020]: Error in Authentication method occurred

## Response 422 fields (application/json):

  - `statusCode` (integer)
    Example: 422

  - `errorCode` (integer)
    Example: 1102

  - `errorMessage` (string)
    Example: [0401-1102]:  Unprocessable Entity. The property `bonus` is required

  - `transactionId` (string)
    Example: x-x-x-x-transactionId-mock-x-x-x

