Введение

В этой статье будет рассмотрена следующая ситуация: гость сделал заказ и хочет оплатить часть заказа бонусами, и использовать подарок. Затем он заказал ещё одно блюдо. При этом:

  • Гость уже существует в базе гостей заведения
  • Бонусный баланс гостя — 100 бонусов
  • Бонусами можно оплатить не более 50% заказа
  • У гостя подарок на Напиток.

Для перерасчета лояльности при изменении заказа:

  1. Получите информацию о госте
  2. Подсчитайте лояльность для заказа
  3. Зафиксируйте применение скидки
  4. При изменении заказа сбросьте заказ и примененную лояльность
  5. Пересчитайте лояльность для заказа
  6. Зафиксируйте новое применение лояльности
  7. Завершите заказ, при необходимости списав или начислив бонусы. 

Схема взаимодействия

Запросы

Получите данные о госте с помощью запроса:

{ "openapi": "3.0.1", "paths": { "/b2b/v1/loyalty/guests/get": { "post": { "tags": [ "Получение гостя" ], "summary": "Получить данные о госте", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GetGuestRequestDto" } } } }, "responses": { "200": { "description": "Результат успешной операции", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GetGuestResponseDto" } } } }, "400": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } }, "500": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } } } } } }, "components": { "schemas": { "ErrorDto": { "required": [ "code", "message" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код ошибки", "example": "6666" }, "message": { "type": "string", "description": "Сообщение о ошибке", "example": "Some error description." } }, "additionalProperties": false, "description": "Ошибка" }, "ErrorResponseDto": { "required": [ "error" ], "type": "object", "properties": { "error": { "$ref": "#/components/schemas/ErrorDto" } }, "additionalProperties": false, "description": "Результат операции, завершившейся ошибкой" }, "GuestIdentityType": { "enum": [ "phone" ], "type": "string", "description": "Тип идентификатора гостя" }, "GuestIdentityDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/GuestIdentityType" }, "phone": { "type": "string", "description": "Номер телефона", "nullable": true, "example": "+79990001122" } }, "additionalProperties": false, "description": "Идентификатор гостя" }, "GetGuestRequestDto": { "required": [ "guest", "organization" ], "type": "object", "properties": { "guest": { "$ref": "#/components/schemas/GuestIdentityDto" }, "organization": { "$ref": "#/components/schemas/OrganizationIdentityDto" } }, "additionalProperties": false, "description": "Аргументы операции получения данных о госте" }, "OrganizationIdentityType": { "enum": [ "rkObjectId" ], "type": "string", "description": "Тип идентификатора заведения" }, "OrganizationIdentityDto": { "required": [ "id", "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/OrganizationIdentityType" }, "id": { "type": "string", "description": "Идентификатор", "example": "4174244" } }, "additionalProperties": false, "description": "Идентификатор заведения" }, "GuestLoyaltyCardDto": { "required": [ "isVirtual", "number", "track" ], "type": "object", "properties": { "track": { "type": "string", "description": "Трек номер карты - уникальный идентификатор карты. Может быть использован в запросе удаления карты у пользователя", "example": "1A56CD0" }, "number": { "type": "string", "description": "Номер карты для отображения пользователю", "example": "23000001GF" }, "isVirtual": { "type": "boolean", "description": "Признак, указывающий что карта виртуальная.\r\nЕсли установлен в false - предполагается, что это магнитная пластиковая карта, которая выдана гостю" } }, "additionalProperties": false, "description": "Данные карты лояльности" }, "GetGuestResponseDto": { "type": "object", "properties": { "guest": { "$ref": "#/components/schemas/GuestDto" }, "loyaltyCards": { "type": "array", "items": { "$ref": "#/components/schemas/GuestLoyaltyCardDto" }, "description": "Список карт лояльности пользователя, в т.ч. виртуальных. Могут отсутствовать", "nullable": true } }, "additionalProperties": false, "description": "Результат операции получения данных о госте" }, "GuestDto": { "required": [ "phone" ], "type": "object", "properties": { "phone": { "type": "string", "description": "Номер телефона", "example": "+79990001122" }, "firstName": { "type": "string", "description": "Имя", "nullable": true, "example": "Иван" }, "middleName": { "type": "string", "description": "Отчество", "nullable": true, "example": "Иванович" }, "lastName": { "type": "string", "description": "Фамилия", "nullable": true, "example": "Иванов" }, "email": { "type": "string", "description": "Email", "nullable": true, "example": "test_email@gmail.com" }, "birthday": { "type": "string", "description": "Дата рождения", "format": "date", "nullable": true, "example": "1989-01-17" }, "sex": { "type": "integer", "description": "Пол. 1 - мужской, 2 - женский, 0 - не указано", "format": "int32", "example": 1 } }, "additionalProperties": false, "description": "Данные гостя" } } } }

Так как гость уже существует в базе, то в ответе вернется информация о нем. Гость заказал горячее и напиток. На напиток у него есть подарочный купон.

Отправьте запрос для подсчета лояльности указанного заказа:

{ "openapi": "3.0.1", "paths": {"/b2b/v1/loyalty/orders/calculate": { "post": { "tags": [ "Подсчет лояльности для заказа" ], "summary": "Посчитать лояльность для заказа", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CalculateOrderRequestDto" } } } }, "responses": { "200": { "description": "Результат успешной операции", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CalculateOrderResponseDto" } } } }, "400": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } }, "500": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } } } } } }, "components": { "schemas": { "ErrorResponseDto": { "required": [ "error" ], "type": "object", "properties": { "error": { "$ref": "#/components/schemas/ErrorDto" } }, "additionalProperties": false, "description": "Результат операции, завершившейся ошибкой" }, "ErrorDto": { "required": [ "code", "message" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код ошибки", "example": "6666" }, "message": { "type": "string", "description": "Сообщение о ошибке", "example": "Some error description." } }, "additionalProperties": false, "description": "Ошибка" }, "ProductDto": { "required": [ "code", "name" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код товара (артикул)", "example": "12345" }, "name": { "type": "string", "description": "Название товара", "example": "Пирог с малиной" }, "group": { "type": "string", "description": "Группа товара", "nullable": true, "example": "Мучное" }, "categories": { "type": "array", "items": { "type": "string" }, "description": "Категории товара", "nullable": true } }, "additionalProperties": false, "description": "Данные о товаре" }, "OrderItemModifierDto": { "required": [ "cost", "discount", "modifier", "price", "quantity" ], "type": "object", "properties": { "modifier": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость модификатора по прайсу", "format": "double", "example": 50 }, "cost": { "type": "number", "description": "Полная стоимость модификатора с учетом внеших скидок и наценок", "format": "double", "example": 30 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки", "format": "double", "example": 20 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц модификатора", "format": "double", "example": 4 } }, "additionalProperties": false, "description": "Данные о модификаторе" }, "OrderItemDto": { "required": [ "cost", "price", "product", "quantity" ], "type": "object", "properties": { "product": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость позиции по прайсу", "format": "double", "example": 170 }, "cost": { "type": "number", "description": "Полная стоимость позиции с учетом внеших скидок и наценок", "format": "double", "example": 140 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки (справочная информация, необходимая для отчетов)", "format": "double", "example": 30 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки (справочная информация, необходимая для отчетов)", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц товара в позиции", "format": "double", "example": 4 }, "modifiers": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemModifierDto" }, "description": "Модификаторы позиции", "nullable": true } }, "additionalProperties": false, "description": "Данные о позиции заказа" }, "OrderDto": { "required": [ "items", "openedAt" ], "type": "object", "properties": { "openedAt": { "type": "string", "description": "Дата/время открытия заказа", "format": "date-time" }, "items": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemDto" }, "description": "Позиции заказа" } }, "additionalProperties": false, "description": "Данные о заказе" }, "ExpeditionTypeDto": { "enum": [ "delivery", "pickup" ], "type": "string", "description": "Способ получения заказа" }, "ExpeditionDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/ExpeditionTypeDto" } }, "additionalProperties": false, "description": "Данные о способе получения заказа" }, "DeliveryDto": { "required": [ "expedition" ], "type": "object", "properties": { "expedition": { "$ref": "#/components/schemas/ExpeditionDto" } }, "additionalProperties": false, "description": "Данные о доставке заказа" }, "PromocodeDto": { "required": [ "value" ], "type": "object", "properties": { "value": { "type": "string", "description": "Промокод" } }, "additionalProperties": false, "description": "Данные по промокоду" }, "BonusesProgramResultDto": { "required": [ "max", "min", "notifications", "progress" ], "type": "object", "properties": { "progress": { "$ref": "#/components/schemas/BonusesProgramProgressDto" }, "min": { "$ref": "#/components/schemas/BonusesDto" }, "max": { "$ref": "#/components/schemas/BonusesDto" }, "notifications": { "type": "array", "items": { "$ref": "#/components/schemas/NotificationDto" }, "description": "Уведомления о деталях срабатывания бонусной программы" } }, "additionalProperties": false, "description": "Расчет бонусной программы для заказа" }, "LoyaltyResultDetailsDto": { "required": [ "programs" ], "type": "object", "properties": { "programs": { "type": "array", "items": { "$ref": "#/components/schemas/CampaignResultDto" }, "description": "Акции" }, "bonuses": { "$ref": "#/components/schemas/BonusesProgramResultDto" } }, "additionalProperties": false, "description": "Детали расчета лояльности для заказа" }, "LoyaltyResultDto": { "required": [ "details", "fingerprint", "summary" ], "type": "object", "properties": { "fingerprint": { "type": "string", "description": "Отпечаток (хранит метаинформацию о расчете для подтверждения заказа)", "example": "UGVyc29uYWxpemVk" }, "summary": { "$ref": "#/components/schemas/LoyaltyResultSummaryDto" }, "details": { "$ref": "#/components/schemas/LoyaltyResultDetailsDto" } }, "additionalProperties": false, "description": "Расчет лояльности для заказа" }, "CalculateOrderResponseDto": { "required": [ "loyalty" ], "type": "object", "properties": { "loyalty": { "$ref": "#/components/schemas/LoyaltyResultDto" } }, "additionalProperties": false, "description": "Результат операции расчета лояльности для заказа" }, "GuestIdentityType": { "enum": [ "phone" ], "type": "string", "description": "Тип идентификатора гостя" }, "GuestIdentityDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/GuestIdentityType" }, "phone": { "type": "string", "description": "Номер телефона", "nullable": true, "example": "+79990001122" } }, "additionalProperties": false, "description": "Идентификатор гостя" }, "OrganizationIdentityType": { "enum": [ "rkObjectId" ], "type": "string", "description": "Тип идентификатора заведения" }, "OrganizationIdentityDto": { "required": [ "id", "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/OrganizationIdentityType" }, "id": { "type": "string", "description": "Идентификатор", "example": "4174244" } }, "additionalProperties": false, "description": "Идентификатор заведения" }, "DiscountsByCodeDto": { "required": [ "code", "total" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код товара (артикул)" }, "total": { "type": "number", "description": "Общая сумма скидки для товара", "format": "double" } }, "additionalProperties": false, "description": "Общая сумма скидки в разрезе товара" }, "DiscountsDto": { "required": [ "total", "totalByCode" ], "type": "object", "properties": { "total": { "type": "number", "description": "Общая сумма скидки в валюте заказа (например, в рублях)", "format": "double", "example": 112 }, "totalByCode": { "type": "array", "items": { "$ref": "#/components/schemas/DiscountsByCodeDto" }, "description": "Общая сумма скидки в разрезе товара в валюте заказа (например, в рублях)" } }, "additionalProperties": false, "description": "Скидки для заказа" }, "LoyaltyResultSummaryDto": { "required": [ "discounts" ], "type": "object", "properties": { "discounts": { "$ref": "#/components/schemas/DiscountsDto" }, "bonuses": { "$ref": "#/components/schemas/BonusesResultSummaryDto" } }, "additionalProperties": false, "description": "Сводка расчета лояльности для заказа" }, "NotificationDto": { "required": [ "primary", "secondary" ], "type": "object", "properties": { "primary": { "type": "string", "description": "Главное уведомление", "example": "Вы получили 50.00 бонусных баллов по акции \"Промобонусы в подарок за первый заказ\"." }, "secondary": { "type": "string", "description": "Дополнительное уведомление", "example": "Вы сможете воспользоваться специальным предложением по акции \"Промобонусы в подарок за первый заказ\" еще 3 раза." } }, "additionalProperties": false, "description": "Уведомление о деталях срабатывания акции" }, "BonusesDto": { "type": "object", "properties": { "payment": { "type": "number", "description": "(OBSOLETE!!!) Сумма оплаты в бонусных баллах", "format": "double", "example": 33, "deprecated": true }, "accrual": { "type": "number", "description": "(OBSOLETE!!!) Сумма начисления в бонусных баллах", "format": "double", "example": 17, "deprecated": true }, "payments": { "$ref": "#/components/schemas/BonusesPaymentsDto" }, "accruals": { "$ref": "#/components/schemas/BonusesAccrualsDto" } }, "additionalProperties": false, "description": "Оплата/начисление бонусных баллов" }, "BonusesPaymentsByCodeDto": { "required": [ "code", "total" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код товара (артикул)" }, "total": { "type": "number", "description": "Общая сумма оплаты бонусными баллами товара", "format": "double" } }, "additionalProperties": false, "description": "Общая сумма оплаты бонусными баллами в разрезе товара" }, "BonusesPaymentsDto": { "required": [ "total", "totalByCode" ], "type": "object", "properties": { "total": { "type": "number", "description": "Общая сумма оплаты бонусными баллами", "format": "double", "example": 33 }, "totalByCode": { "type": "array", "items": { "$ref": "#/components/schemas/BonusesPaymentsByCodeDto" }, "description": "Общая сумма оплаты бонусными баллами в разрезе товара" } }, "additionalProperties": false, "description": "Оплата бонусными баллами для заказа" }, "BonusesAccrualsDto": { "required": [ "total" ], "type": "object", "properties": { "total": { "type": "number", "description": "Сумма начисления в бонусных баллах", "format": "double", "example": 17 } }, "additionalProperties": false, "description": "Начисление бонусных баллов для заказа" }, "BonusesResultSummaryDto": { "required": [ "max", "min" ], "type": "object", "properties": { "min": { "$ref": "#/components/schemas/BonusesDto" }, "max": { "$ref": "#/components/schemas/BonusesDto" } }, "additionalProperties": false, "description": "Сводка оплаты/начисления бонусных баллов для заказа" }, "RankProgressDto": { "required": [ "cashbackPercentage", "index", "name" ], "type": "object", "properties": { "name": { "type": "string", "description": "Название ранга" }, "index": { "type": "integer", "description": "Индекс текущего ранга (в списке рангов, отсчет с 0)", "format": "int32" }, "cashbackPercentage": { "type": "number", "description": "Процент бонусов\r\n<example>12.5</example>", "format": "double" }, "confirmation": { "$ref": "#/components/schemas/RankConfirmationDto" } }, "additionalProperties": false, "description": "Описывает специфичную информацию о текущем бонусном ранге пользователя" }, "RankConfirmationDto": { "required": [ "hoursLeft", "sumLeft" ], "type": "object", "properties": { "sumLeft": { "type": "number", "description": "Сумма которую необходимо потратить для подтверждения ранга", "format": "double" }, "hoursLeft": { "type": "integer", "description": "Количество часов за которые необходимо потратить сумму подтверждения", "format": "int32" } }, "additionalProperties": false, "description": "Описание требования подтверждения ранга" }, "BonusesProgramProgressDto": { "required": [ "balance", "rank" ], "type": "object", "properties": { "balance": { "type": "number", "description": "Количество бонусов в кошельке", "format": "double" }, "rank": { "$ref": "#/components/schemas/RankProgressDto" } }, "additionalProperties": false, "description": "Прогресс гостя в рамках болнусной программы" }, "CampaignResultDto": { "required": [ "notifications", "program" ], "type": "object", "properties": { "program": { "$ref": "#/components/schemas/CampaignDto" }, "discounts": { "$ref": "#/components/schemas/DiscountsDto" }, "notifications": { "type": "array", "items": { "$ref": "#/components/schemas/NotificationDto" }, "description": "Уведомления о деталях срабатывания акции" } }, "additionalProperties": false, "description": "Расчет акции для заказа" }, "CampaignDto": { "required": [ "id", "name" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор акции", "format": "uuid", "example": "1de9a2d7-2ce7-4845-960b-988df56872ce" }, "name": { "type": "string", "description": "Название акции", "example": "Промобонусы в подарок за первый заказ" } }, "additionalProperties": false, "description": "Данные о акции" }, "CalculateOrderRequestDto": { "required": [ "order", "organization" ], "type": "object", "properties": { "order": { "$ref": "#/components/schemas/OrderDto" }, "organization": { "$ref": "#/components/schemas/OrganizationIdentityDto" }, "guest": { "$ref": "#/components/schemas/GuestIdentityDto" }, "delivery": { "$ref": "#/components/schemas/DeliveryDto" }, "promocodes": { "type": "array", "items": { "$ref": "#/components/schemas/PromocodeDto" }, "description": "Промокоды для применения к заказу", "nullable": true } }, "additionalProperties": false, "description": "Аргументы операции предрасчета лояльности для заказа" } } } }

В ответе вернется информация о скидке на напиток и лимит оплаты на горячее.

Теперь оплату бонусами необходимо зафиксировать. Подтвердите заказ с использованием скидок, используя запрос:

{ "openapi": "3.0.1", "paths": { "/b2b/v1/loyalty/orders/confirm": { "post": { "tags": [ "Подтвердить заказ" ], "summary": "Подтвердить заказ", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConfirmOrderRequestDto" } } } }, "responses": { "200": { "description": "Результат успешной операции", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConfirmOrderResponseDto" } } } }, "400": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } }, "500": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } } } } } }, "components": { "schemas": { "ErrorResponseDto": { "required": [ "error" ], "type": "object", "properties": { "error": { "$ref": "#/components/schemas/ErrorDto" } }, "additionalProperties": false, "description": "Результат операции, завершившейся ошибкой" }, "ErrorDto": { "required": [ "code", "message" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код ошибки", "example": "6666" }, "message": { "type": "string", "description": "Сообщение о ошибке", "example": "Some error description." } }, "additionalProperties": false, "description": "Ошибка" }, "LoyaltyConfirmationPatternDto": { "enum": [ "fingerprint" ], "type": "string", "description": "Тип подтверждения лояльности" }, "ConfirmOrderRequestDto": { "required": [ "id", "order", "organization" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор заказа", "format": "uuid", "example": "46b7c469-d99c-4499-acc7-8ca26ea2117d" }, "order": { "$ref": "#/components/schemas/OrderDto" }, "organization": { "$ref": "#/components/schemas/OrganizationIdentityDto" }, "guest": { "$ref": "#/components/schemas/GuestIdentityDto" }, "delivery": { "$ref": "#/components/schemas/DeliveryDto" }, "loyalty": { "$ref": "#/components/schemas/LoyaltyConfirmationDto" } }, "additionalProperties": false, "description": "Аргументы операции подтверждения заказа" }, "LoyaltyConfirmationPatternDto": { "enum": [ "fingerprint" ], "type": "string", "description": "Тип подтверждения лояльности" }, "FingerprintConfirmationBonusesOptionDto": { "required": [ "payment" ], "type": "object", "properties": { "payment": { "type": "number", "description": "Сумма оплаты в бонусых баллах", "format": "double", "example": 37 } }, "additionalProperties": false, "description": "Подтверждение оплаты бонусами для заказа" }, "FingerprintConfirmationOptionsDto": { "type": "object", "properties": { "hold": { "type": "boolean", "description": "(Obsolete!!!) Выполнять ли холдирование? Поле необходимо для обратной совместимости" }, "bonuses": { "$ref": "#/components/schemas/FingerprintConfirmationBonusesOptionDto" } }, "additionalProperties": false, "description": "Конфигурация подтверждения по отпечатку рассчета лояльности" }, "FingerprintConfirmationDto": { "required": [ "value" ], "type": "object", "properties": { "value": { "type": "string", "description": "Отпечаток расчета", "example": "UGVyc29uYWxpemVk" }, "options": { "$ref": "#/components/schemas/FingerprintConfirmationOptionsDto" } }, "additionalProperties": false, "description": "Подтверждение по отпечатку расчета лояльности" }, "LoyaltyConfirmationDto": { "required": [ "pattern" ], "type": "object", "properties": { "pattern": { "$ref": "#/components/schemas/LoyaltyConfirmationPatternDto" }, "fingerprint": { "$ref": "#/components/schemas/FingerprintConfirmationDto" } }, "additionalProperties": false, "description": "Подтверждение лояльности для заказа" }, "ExpeditionTypeDto": { "enum": [ "delivery", "pickup" ], "type": "string", "description": "Способ получения заказа" }, "ExpeditionDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/ExpeditionTypeDto" } }, "additionalProperties": false, "description": "Данные о способе получения заказа" }, "DeliveryDto": { "required": [ "expedition" ], "type": "object", "properties": { "expedition": { "$ref": "#/components/schemas/ExpeditionDto" } }, "additionalProperties": false, "description": "Данные о доставке заказа" }, "GuestIdentityType": { "enum": [ "phone" ], "type": "string", "description": "Тип идентификатора гостя" }, "GuestIdentityDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/GuestIdentityType" }, "phone": { "type": "string", "description": "Номер телефона", "nullable": true, "example": "+79990001122" } }, "additionalProperties": false, "description": "Идентификатор гостя" }, "OrganizationIdentityDto": { "required": [ "id", "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/OrganizationIdentityType" }, "id": { "type": "string", "description": "Идентификатор", "example": "4174244" } }, "additionalProperties": false, "description": "Идентификатор заведения" }, "OrganizationIdentityType": { "enum": [ "rkObjectId" ], "type": "string", "description": "Тип идентификатора заведения" }, "OrderDto": { "required": [ "items", "openedAt" ], "type": "object", "properties": { "openedAt": { "type": "string", "description": "Дата/время открытия заказа", "format": "date-time" }, "items": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemDto" }, "description": "Позиции заказа" } }, "additionalProperties": false, "description": "Данные о заказе" }, "OrderItemDto": { "required": [ "cost", "price", "product", "quantity" ], "type": "object", "properties": { "product": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость позиции по прайсу", "format": "double", "example": 170 }, "cost": { "type": "number", "description": "Полная стоимость позиции с учетом внеших скидок и наценок", "format": "double", "example": 140 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки (справочная информация, необходимая для отчетов)", "format": "double", "example": 30 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки (справочная информация, необходимая для отчетов)", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц товара в позиции", "format": "double", "example": 4 }, "modifiers": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemModifierDto" }, "description": "Модификаторы позиции", "nullable": true } }, "additionalProperties": false, "description": "Данные о позиции заказа" }, "OrderItemModifierDto": { "required": [ "cost", "discount", "modifier", "price", "quantity" ], "type": "object", "properties": { "modifier": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость модификатора по прайсу", "format": "double", "example": 50 }, "cost": { "type": "number", "description": "Полная стоимость модификатора с учетом внеших скидок и наценок", "format": "double", "example": 30 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки", "format": "double", "example": 20 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц модификатора", "format": "double", "example": 4 } }, "additionalProperties": false, "description": "Данные о модификаторе" }, "OrderItemDto": { "required": [ "cost", "price", "product", "quantity" ], "type": "object", "properties": { "product": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость позиции по прайсу", "format": "double", "example": 170 }, "cost": { "type": "number", "description": "Полная стоимость позиции с учетом внеших скидок и наценок", "format": "double", "example": 140 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки (справочная информация, необходимая для отчетов)", "format": "double", "example": 30 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки (справочная информация, необходимая для отчетов)", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц товара в позиции", "format": "double", "example": 4 }, "modifiers": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemModifierDto" }, "description": "Модификаторы позиции", "nullable": true } }, "additionalProperties": false, "description": "Данные о позиции заказа" }, "OrderItemModifierDto": { "required": [ "cost", "discount", "modifier", "price", "quantity" ], "type": "object", "properties": { "modifier": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость модификатора по прайсу", "format": "double", "example": 50 }, "cost": { "type": "number", "description": "Полная стоимость модификатора с учетом внеших скидок и наценок", "format": "double", "example": 30 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки", "format": "double", "example": 20 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц модификатора", "format": "double", "example": 4 } }, "additionalProperties": false, "description": "Данные о модификаторе" }, "ProductDto": { "required": [ "code", "name" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код товара (артикул)", "example": "12345" }, "name": { "type": "string", "description": "Название товара", "example": "Пирог с малиной" }, "group": { "type": "string", "description": "Группа товара", "nullable": true, "example": "Мучное" }, "categories": { "type": "array", "items": { "type": "string" }, "description": "Категории товара", "nullable": true } }, "additionalProperties": false, "description": "Данные о товаре" }, "ConfirmOrderResponseDto": { "required": [ "id" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор заказа", "format": "uuid", "example": "46b7c469-d99c-4499-acc7-8ca26ea2117d" } }, "additionalProperties": false, "description": "Результат операции подтверждения заказа" } } } }

В какой-то момент гость решил заказать еще десерт. Для корректной работы системы лояльности необходимо сбросить заказ и примененные скидки. Для этого используйте запрос:

{ "openapi": "3.0.1", "paths": { "/b2b/v1/loyalty/orders/reset": { "post": { "tags": [ "Сбросить заказ" ], "summary": "Сбросить заказ.", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ResetOrderRequestDto" } } } }, "responses": { "200": { "description": "Результат успешной операции", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ResetOrderRequestDto" } } } }, "400": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } }, "500": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } } } } } }, "components": { "schemas": { "ErrorResponseDto": { "required": [ "error" ], "type": "object", "properties": { "error": { "$ref": "#/components/schemas/ErrorDto" } }, "additionalProperties": false, "description": "Результат операции, завершившейся ошибкой" }, "ErrorDto": { "required": [ "code", "message" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код ошибки", "example": "6666" }, "message": { "type": "string", "description": "Сообщение о ошибке", "example": "Some error description." } }, "additionalProperties": false, "description": "Ошибка" }, "ResetOrderRequestDto": { "required": [ "id", "resetAt" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор заказа", "format": "uuid", "example": "46b7c469-d99c-4499-acc7-8ca26ea2117d" }, "resetAt": { "type": "string", "description": "Дата/время сброса заказа", "format": "date-time" } }, "additionalProperties": false, "description": "Аргументы операции сброса заказа" } } } }

После добавления нового блюда пересчитайте лояльность на заказ

{ "openapi": "3.0.1", "paths": {"/b2b/v1/loyalty/orders/calculate": { "post": { "tags": [ "Подсчет лояльности для заказа" ], "summary": "Посчитать лояльность для заказа", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CalculateOrderRequestDto" } } } }, "responses": { "200": { "description": "Результат успешной операции", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CalculateOrderResponseDto" } } } }, "400": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } }, "500": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } } } } } }, "components": { "schemas": { "ErrorResponseDto": { "required": [ "error" ], "type": "object", "properties": { "error": { "$ref": "#/components/schemas/ErrorDto" } }, "additionalProperties": false, "description": "Результат операции, завершившейся ошибкой" }, "ErrorDto": { "required": [ "code", "message" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код ошибки", "example": "6666" }, "message": { "type": "string", "description": "Сообщение о ошибке", "example": "Some error description." } }, "additionalProperties": false, "description": "Ошибка" }, "ProductDto": { "required": [ "code", "name" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код товара (артикул)", "example": "12345" }, "name": { "type": "string", "description": "Название товара", "example": "Пирог с малиной" }, "group": { "type": "string", "description": "Группа товара", "nullable": true, "example": "Мучное" }, "categories": { "type": "array", "items": { "type": "string" }, "description": "Категории товара", "nullable": true } }, "additionalProperties": false, "description": "Данные о товаре" }, "OrderItemModifierDto": { "required": [ "cost", "discount", "modifier", "price", "quantity" ], "type": "object", "properties": { "modifier": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость модификатора по прайсу", "format": "double", "example": 50 }, "cost": { "type": "number", "description": "Полная стоимость модификатора с учетом внеших скидок и наценок", "format": "double", "example": 30 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки", "format": "double", "example": 20 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц модификатора", "format": "double", "example": 4 } }, "additionalProperties": false, "description": "Данные о модификаторе" }, "OrderItemDto": { "required": [ "cost", "price", "product", "quantity" ], "type": "object", "properties": { "product": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость позиции по прайсу", "format": "double", "example": 170 }, "cost": { "type": "number", "description": "Полная стоимость позиции с учетом внеших скидок и наценок", "format": "double", "example": 140 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки (справочная информация, необходимая для отчетов)", "format": "double", "example": 30 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки (справочная информация, необходимая для отчетов)", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц товара в позиции", "format": "double", "example": 4 }, "modifiers": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemModifierDto" }, "description": "Модификаторы позиции", "nullable": true } }, "additionalProperties": false, "description": "Данные о позиции заказа" }, "OrderDto": { "required": [ "items", "openedAt" ], "type": "object", "properties": { "openedAt": { "type": "string", "description": "Дата/время открытия заказа", "format": "date-time" }, "items": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemDto" }, "description": "Позиции заказа" } }, "additionalProperties": false, "description": "Данные о заказе" }, "ExpeditionTypeDto": { "enum": [ "delivery", "pickup" ], "type": "string", "description": "Способ получения заказа" }, "ExpeditionDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/ExpeditionTypeDto" } }, "additionalProperties": false, "description": "Данные о способе получения заказа" }, "DeliveryDto": { "required": [ "expedition" ], "type": "object", "properties": { "expedition": { "$ref": "#/components/schemas/ExpeditionDto" } }, "additionalProperties": false, "description": "Данные о доставке заказа" }, "PromocodeDto": { "required": [ "value" ], "type": "object", "properties": { "value": { "type": "string", "description": "Промокод" } }, "additionalProperties": false, "description": "Данные по промокоду" }, "BonusesProgramResultDto": { "required": [ "max", "min", "notifications", "progress" ], "type": "object", "properties": { "progress": { "$ref": "#/components/schemas/BonusesProgramProgressDto" }, "min": { "$ref": "#/components/schemas/BonusesDto" }, "max": { "$ref": "#/components/schemas/BonusesDto" }, "notifications": { "type": "array", "items": { "$ref": "#/components/schemas/NotificationDto" }, "description": "Уведомления о деталях срабатывания бонусной программы" } }, "additionalProperties": false, "description": "Расчет бонусной программы для заказа" }, "LoyaltyResultDetailsDto": { "required": [ "programs" ], "type": "object", "properties": { "programs": { "type": "array", "items": { "$ref": "#/components/schemas/CampaignResultDto" }, "description": "Акции" }, "bonuses": { "$ref": "#/components/schemas/BonusesProgramResultDto" } }, "additionalProperties": false, "description": "Детали расчета лояльности для заказа" }, "LoyaltyResultDto": { "required": [ "details", "fingerprint", "summary" ], "type": "object", "properties": { "fingerprint": { "type": "string", "description": "Отпечаток (хранит метаинформацию о расчете для подтверждения заказа)", "example": "UGVyc29uYWxpemVk" }, "summary": { "$ref": "#/components/schemas/LoyaltyResultSummaryDto" }, "details": { "$ref": "#/components/schemas/LoyaltyResultDetailsDto" } }, "additionalProperties": false, "description": "Расчет лояльности для заказа" }, "CalculateOrderResponseDto": { "required": [ "loyalty" ], "type": "object", "properties": { "loyalty": { "$ref": "#/components/schemas/LoyaltyResultDto" } }, "additionalProperties": false, "description": "Результат операции расчета лояльности для заказа" }, "GuestIdentityType": { "enum": [ "phone" ], "type": "string", "description": "Тип идентификатора гостя" }, "GuestIdentityDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/GuestIdentityType" }, "phone": { "type": "string", "description": "Номер телефона", "nullable": true, "example": "+79990001122" } }, "additionalProperties": false, "description": "Идентификатор гостя" }, "OrganizationIdentityType": { "enum": [ "rkObjectId" ], "type": "string", "description": "Тип идентификатора заведения" }, "OrganizationIdentityDto": { "required": [ "id", "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/OrganizationIdentityType" }, "id": { "type": "string", "description": "Идентификатор", "example": "4174244" } }, "additionalProperties": false, "description": "Идентификатор заведения" }, "DiscountsByCodeDto": { "required": [ "code", "total" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код товара (артикул)" }, "total": { "type": "number", "description": "Общая сумма скидки для товара", "format": "double" } }, "additionalProperties": false, "description": "Общая сумма скидки в разрезе товара" }, "DiscountsDto": { "required": [ "total", "totalByCode" ], "type": "object", "properties": { "total": { "type": "number", "description": "Общая сумма скидки в валюте заказа (например, в рублях)", "format": "double", "example": 112 }, "totalByCode": { "type": "array", "items": { "$ref": "#/components/schemas/DiscountsByCodeDto" }, "description": "Общая сумма скидки в разрезе товара в валюте заказа (например, в рублях)" } }, "additionalProperties": false, "description": "Скидки для заказа" }, "LoyaltyResultSummaryDto": { "required": [ "discounts" ], "type": "object", "properties": { "discounts": { "$ref": "#/components/schemas/DiscountsDto" }, "bonuses": { "$ref": "#/components/schemas/BonusesResultSummaryDto" } }, "additionalProperties": false, "description": "Сводка расчета лояльности для заказа" }, "NotificationDto": { "required": [ "primary", "secondary" ], "type": "object", "properties": { "primary": { "type": "string", "description": "Главное уведомление", "example": "Вы получили 50.00 бонусных баллов по акции \"Промобонусы в подарок за первый заказ\"." }, "secondary": { "type": "string", "description": "Дополнительное уведомление", "example": "Вы сможете воспользоваться специальным предложением по акции \"Промобонусы в подарок за первый заказ\" еще 3 раза." } }, "additionalProperties": false, "description": "Уведомление о деталях срабатывания акции" }, "BonusesDto": { "type": "object", "properties": { "payment": { "type": "number", "description": "(OBSOLETE!!!) Сумма оплаты в бонусных баллах", "format": "double", "example": 33, "deprecated": true }, "accrual": { "type": "number", "description": "(OBSOLETE!!!) Сумма начисления в бонусных баллах", "format": "double", "example": 17, "deprecated": true }, "payments": { "$ref": "#/components/schemas/BonusesPaymentsDto" }, "accruals": { "$ref": "#/components/schemas/BonusesAccrualsDto" } }, "additionalProperties": false, "description": "Оплата/начисление бонусных баллов" }, "BonusesPaymentsByCodeDto": { "required": [ "code", "total" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код товара (артикул)" }, "total": { "type": "number", "description": "Общая сумма оплаты бонусными баллами товара", "format": "double" } }, "additionalProperties": false, "description": "Общая сумма оплаты бонусными баллами в разрезе товара" }, "BonusesPaymentsDto": { "required": [ "total", "totalByCode" ], "type": "object", "properties": { "total": { "type": "number", "description": "Общая сумма оплаты бонусными баллами", "format": "double", "example": 33 }, "totalByCode": { "type": "array", "items": { "$ref": "#/components/schemas/BonusesPaymentsByCodeDto" }, "description": "Общая сумма оплаты бонусными баллами в разрезе товара" } }, "additionalProperties": false, "description": "Оплата бонусными баллами для заказа" }, "BonusesAccrualsDto": { "required": [ "total" ], "type": "object", "properties": { "total": { "type": "number", "description": "Сумма начисления в бонусных баллах", "format": "double", "example": 17 } }, "additionalProperties": false, "description": "Начисление бонусных баллов для заказа" }, "BonusesResultSummaryDto": { "required": [ "max", "min" ], "type": "object", "properties": { "min": { "$ref": "#/components/schemas/BonusesDto" }, "max": { "$ref": "#/components/schemas/BonusesDto" } }, "additionalProperties": false, "description": "Сводка оплаты/начисления бонусных баллов для заказа" }, "RankProgressDto": { "required": [ "cashbackPercentage", "index", "name" ], "type": "object", "properties": { "name": { "type": "string", "description": "Название ранга" }, "index": { "type": "integer", "description": "Индекс текущего ранга (в списке рангов, отсчет с 0)", "format": "int32" }, "cashbackPercentage": { "type": "number", "description": "Процент бонусов\r\n<example>12.5</example>", "format": "double" }, "confirmation": { "$ref": "#/components/schemas/RankConfirmationDto" } }, "additionalProperties": false, "description": "Описывает специфичную информацию о текущем бонусном ранге пользователя" }, "RankConfirmationDto": { "required": [ "hoursLeft", "sumLeft" ], "type": "object", "properties": { "sumLeft": { "type": "number", "description": "Сумма которую необходимо потратить для подтверждения ранга", "format": "double" }, "hoursLeft": { "type": "integer", "description": "Количество часов за которые необходимо потратить сумму подтверждения", "format": "int32" } }, "additionalProperties": false, "description": "Описание требования подтверждения ранга" }, "BonusesProgramProgressDto": { "required": [ "balance", "rank" ], "type": "object", "properties": { "balance": { "type": "number", "description": "Количество бонусов в кошельке", "format": "double" }, "rank": { "$ref": "#/components/schemas/RankProgressDto" } }, "additionalProperties": false, "description": "Прогресс гостя в рамках болнусной программы" }, "CampaignResultDto": { "required": [ "notifications", "program" ], "type": "object", "properties": { "program": { "$ref": "#/components/schemas/CampaignDto" }, "discounts": { "$ref": "#/components/schemas/DiscountsDto" }, "notifications": { "type": "array", "items": { "$ref": "#/components/schemas/NotificationDto" }, "description": "Уведомления о деталях срабатывания акции" } }, "additionalProperties": false, "description": "Расчет акции для заказа" }, "CampaignDto": { "required": [ "id", "name" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор акции", "format": "uuid", "example": "1de9a2d7-2ce7-4845-960b-988df56872ce" }, "name": { "type": "string", "description": "Название акции", "example": "Промобонусы в подарок за первый заказ" } }, "additionalProperties": false, "description": "Данные о акции" }, "CalculateOrderRequestDto": { "required": [ "order", "organization" ], "type": "object", "properties": { "order": { "$ref": "#/components/schemas/OrderDto" }, "organization": { "$ref": "#/components/schemas/OrganizationIdentityDto" }, "guest": { "$ref": "#/components/schemas/GuestIdentityDto" }, "delivery": { "$ref": "#/components/schemas/DeliveryDto" }, "promocodes": { "type": "array", "items": { "$ref": "#/components/schemas/PromocodeDto" }, "description": "Промокоды для применения к заказу", "nullable": true } }, "additionalProperties": false, "description": "Аргументы операции предрасчета лояльности для заказа" } } } }

В ответе вернется информация о скидке на напиток лимитах на оплату десерта и горячего. Лояльность снова необходимо зафиксировать. Подтвердите заказ с использованием скидок, используя запрос:

{ "openapi": "3.0.1", "paths": { "/b2b/v1/loyalty/orders/confirm": { "post": { "tags": [ "Подтвердить заказ" ], "summary": "Подтвердить заказ", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConfirmOrderRequestDto" } } } }, "responses": { "200": { "description": "Результат успешной операции", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConfirmOrderResponseDto" } } } }, "400": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } }, "500": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } } } } } }, "components": { "schemas": { "ErrorResponseDto": { "required": [ "error" ], "type": "object", "properties": { "error": { "$ref": "#/components/schemas/ErrorDto" } }, "additionalProperties": false, "description": "Результат операции, завершившейся ошибкой" }, "ErrorDto": { "required": [ "code", "message" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код ошибки", "example": "6666" }, "message": { "type": "string", "description": "Сообщение о ошибке", "example": "Some error description." } }, "additionalProperties": false, "description": "Ошибка" }, "LoyaltyConfirmationPatternDto": { "enum": [ "fingerprint" ], "type": "string", "description": "Тип подтверждения лояльности" }, "ConfirmOrderRequestDto": { "required": [ "id", "order", "organization" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор заказа", "format": "uuid", "example": "46b7c469-d99c-4499-acc7-8ca26ea2117d" }, "order": { "$ref": "#/components/schemas/OrderDto" }, "organization": { "$ref": "#/components/schemas/OrganizationIdentityDto" }, "guest": { "$ref": "#/components/schemas/GuestIdentityDto" }, "delivery": { "$ref": "#/components/schemas/DeliveryDto" }, "loyalty": { "$ref": "#/components/schemas/LoyaltyConfirmationDto" } }, "additionalProperties": false, "description": "Аргументы операции подтверждения заказа" }, "LoyaltyConfirmationPatternDto": { "enum": [ "fingerprint" ], "type": "string", "description": "Тип подтверждения лояльности" }, "FingerprintConfirmationBonusesOptionDto": { "required": [ "payment" ], "type": "object", "properties": { "payment": { "type": "number", "description": "Сумма оплаты в бонусых баллах", "format": "double", "example": 37 } }, "additionalProperties": false, "description": "Подтверждение оплаты бонусами для заказа" }, "FingerprintConfirmationOptionsDto": { "type": "object", "properties": { "hold": { "type": "boolean", "description": "(Obsolete!!!) Выполнять ли холдирование? Поле необходимо для обратной совместимости" }, "bonuses": { "$ref": "#/components/schemas/FingerprintConfirmationBonusesOptionDto" } }, "additionalProperties": false, "description": "Конфигурация подтверждения по отпечатку рассчета лояльности" }, "FingerprintConfirmationDto": { "required": [ "value" ], "type": "object", "properties": { "value": { "type": "string", "description": "Отпечаток расчета", "example": "UGVyc29uYWxpemVk" }, "options": { "$ref": "#/components/schemas/FingerprintConfirmationOptionsDto" } }, "additionalProperties": false, "description": "Подтверждение по отпечатку расчета лояльности" }, "LoyaltyConfirmationDto": { "required": [ "pattern" ], "type": "object", "properties": { "pattern": { "$ref": "#/components/schemas/LoyaltyConfirmationPatternDto" }, "fingerprint": { "$ref": "#/components/schemas/FingerprintConfirmationDto" } }, "additionalProperties": false, "description": "Подтверждение лояльности для заказа" }, "ExpeditionTypeDto": { "enum": [ "delivery", "pickup" ], "type": "string", "description": "Способ получения заказа" }, "ExpeditionDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/ExpeditionTypeDto" } }, "additionalProperties": false, "description": "Данные о способе получения заказа" }, "DeliveryDto": { "required": [ "expedition" ], "type": "object", "properties": { "expedition": { "$ref": "#/components/schemas/ExpeditionDto" } }, "additionalProperties": false, "description": "Данные о доставке заказа" }, "GuestIdentityType": { "enum": [ "phone" ], "type": "string", "description": "Тип идентификатора гостя" }, "GuestIdentityDto": { "required": [ "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/GuestIdentityType" }, "phone": { "type": "string", "description": "Номер телефона", "nullable": true, "example": "+79990001122" } }, "additionalProperties": false, "description": "Идентификатор гостя" }, "OrganizationIdentityDto": { "required": [ "id", "type" ], "type": "object", "properties": { "type": { "$ref": "#/components/schemas/OrganizationIdentityType" }, "id": { "type": "string", "description": "Идентификатор", "example": "4174244" } }, "additionalProperties": false, "description": "Идентификатор заведения" }, "OrganizationIdentityType": { "enum": [ "rkObjectId" ], "type": "string", "description": "Тип идентификатора заведения" }, "OrderDto": { "required": [ "items", "openedAt" ], "type": "object", "properties": { "openedAt": { "type": "string", "description": "Дата/время открытия заказа", "format": "date-time" }, "items": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemDto" }, "description": "Позиции заказа" } }, "additionalProperties": false, "description": "Данные о заказе" }, "OrderItemDto": { "required": [ "cost", "price", "product", "quantity" ], "type": "object", "properties": { "product": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость позиции по прайсу", "format": "double", "example": 170 }, "cost": { "type": "number", "description": "Полная стоимость позиции с учетом внеших скидок и наценок", "format": "double", "example": 140 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки (справочная информация, необходимая для отчетов)", "format": "double", "example": 30 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки (справочная информация, необходимая для отчетов)", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц товара в позиции", "format": "double", "example": 4 }, "modifiers": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemModifierDto" }, "description": "Модификаторы позиции", "nullable": true } }, "additionalProperties": false, "description": "Данные о позиции заказа" }, "OrderItemModifierDto": { "required": [ "cost", "discount", "modifier", "price", "quantity" ], "type": "object", "properties": { "modifier": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость модификатора по прайсу", "format": "double", "example": 50 }, "cost": { "type": "number", "description": "Полная стоимость модификатора с учетом внеших скидок и наценок", "format": "double", "example": 30 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки", "format": "double", "example": 20 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц модификатора", "format": "double", "example": 4 } }, "additionalProperties": false, "description": "Данные о модификаторе" }, "OrderItemDto": { "required": [ "cost", "price", "product", "quantity" ], "type": "object", "properties": { "product": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость позиции по прайсу", "format": "double", "example": 170 }, "cost": { "type": "number", "description": "Полная стоимость позиции с учетом внеших скидок и наценок", "format": "double", "example": 140 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки (справочная информация, необходимая для отчетов)", "format": "double", "example": 30 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки (справочная информация, необходимая для отчетов)", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц товара в позиции", "format": "double", "example": 4 }, "modifiers": { "type": "array", "items": { "$ref": "#/components/schemas/OrderItemModifierDto" }, "description": "Модификаторы позиции", "nullable": true } }, "additionalProperties": false, "description": "Данные о позиции заказа" }, "OrderItemModifierDto": { "required": [ "cost", "discount", "modifier", "price", "quantity" ], "type": "object", "properties": { "modifier": { "$ref": "#/components/schemas/ProductDto" }, "price": { "type": "number", "description": "Полная стоимость модификатора по прайсу", "format": "double", "example": 50 }, "cost": { "type": "number", "description": "Полная стоимость модификатора с учетом внеших скидок и наценок", "format": "double", "example": 30 }, "discount": { "type": "number", "description": "Общая сумма внешней скидки", "format": "double", "example": 20 }, "extraCharge": { "type": "number", "description": "Общая сумма наценки", "format": "double", "example": 0 }, "quantity": { "type": "number", "description": "Количество единиц модификатора", "format": "double", "example": 4 } }, "additionalProperties": false, "description": "Данные о модификаторе" }, "ProductDto": { "required": [ "code", "name" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код товара (артикул)", "example": "12345" }, "name": { "type": "string", "description": "Название товара", "example": "Пирог с малиной" }, "group": { "type": "string", "description": "Группа товара", "nullable": true, "example": "Мучное" }, "categories": { "type": "array", "items": { "type": "string" }, "description": "Категории товара", "nullable": true } }, "additionalProperties": false, "description": "Данные о товаре" }, "ConfirmOrderResponseDto": { "required": [ "id" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор заказа", "format": "uuid", "example": "46b7c469-d99c-4499-acc7-8ca26ea2117d" } }, "additionalProperties": false, "description": "Результат операции подтверждения заказа" } } } }

Осталось закрыть заказ с примененными бонусами. Для этого используйте запрос:

{ "openapi": "3.0.1", "paths": { "/b2b/v1/loyalty/orders/close": { "post": { "tags": [ "Закрыть заказ" ], "summary": "Закрыть заказ.", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CloseOrderRequestDto" } } } }, "responses": { "200": { "description": "Результат успешной операции", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CloseOrderResponseDto" } } } }, "400": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } }, "500": { "description": "Ответ с информацией об ошибке", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponseDto" } } } } } } } }, "components": { "schemas": { "ErrorResponseDto": { "required": [ "error" ], "type": "object", "properties": { "error": { "$ref": "#/components/schemas/ErrorDto" } }, "additionalProperties": false, "description": "Результат операции, завершившейся ошибкой" }, "ErrorDto": { "required": [ "code", "message" ], "type": "object", "properties": { "code": { "type": "string", "description": "Код ошибки", "example": "6666" }, "message": { "type": "string", "description": "Сообщение о ошибке", "example": "Some error description." } }, "additionalProperties": false, "description": "Ошибка" }, "CloseOrderRequestDto": { "required": [ "closedAt", "id" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор заказа", "format": "uuid", "example": "46b7c469-d99c-4499-acc7-8ca26ea2117d" }, "closedAt": { "type": "string", "description": "Дата/время закрытия заказа", "format": "date-time" } }, "additionalProperties": false, "description": "Аргументы операции закрытия заказа" }, "CloseOrderResponseDto": { "required": [ "id" ], "type": "object", "properties": { "id": { "type": "string", "description": "Идентификатор заказа", "format": "uuid", "example": "46b7c469-d99c-4499-acc7-8ca26ea2117d" } }, "additionalProperties": false, "description": "Результат операции закрытия заказа" } } } }

Готово, заказ закрыт с учетом скидки и оплаты бонусами.