diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f302fdbe..8822090ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - name: Install dependencies - run: composer install -o + run: composer install -o --no-security-blocking - name: Configure matchers uses: mheap/phpunit-matcher-action@v1 diff --git a/src/Model/Entity/Loyalty/Loyalty.php b/src/Model/Entity/Loyalty/Loyalty.php index 134169cd3..7e8d544d0 100644 --- a/src/Model/Entity/Loyalty/Loyalty.php +++ b/src/Model/Entity/Loyalty/Loyalty.php @@ -30,6 +30,22 @@ class Loyalty */ public $levels; + /** + * @var string + * + * @JMS\Type("string") + * @JMS\SerializedName("expirePeriod") + */ + public $expirePeriod; + + /** + * @var \RetailCrm\Api\Model\Entity\Loyalty\LoyaltyBurnSetting[] + * + * @JMS\Type("array") + * @JMS\SerializedName("burnSettings") + */ + public $burnSettings; + /** * @var bool * @@ -70,6 +86,14 @@ class Loyalty */ public $name; + /** + * @var int + * + * @JMS\Type("int") + * @JMS\SerializedName("burnType") + */ + public $burnType; + /** * @var bool * @@ -86,6 +110,30 @@ class Loyalty */ public $confirmSmsRegistration; + /** + * @var int + * + * @JMS\Type("int") + * @JMS\SerializedName("maxChargePercent") + */ + public $maxChargePercent; + + /** + * @var float + * + * @JMS\Type("float") + * @JMS\SerializedName("minResidualCost") + */ + public $minResidualCost; + + /** + * @var \RetailCrm\Api\Model\Entity\Loyalty\LoyaltyEvent[] + * + * @JMS\Type("array") + * @JMS\SerializedName("events") + */ + public $events; + /** * @var DateTime * diff --git a/src/Model/Entity/Loyalty/LoyaltyBurnSetting.php b/src/Model/Entity/Loyalty/LoyaltyBurnSetting.php new file mode 100644 index 000000000..aacb8415b --- /dev/null +++ b/src/Model/Entity/Loyalty/LoyaltyBurnSetting.php @@ -0,0 +1,45 @@ +") + * @JMS\SerializedName("activatedAt") + */ + public $activatedAt; + + /** + * @var string + * + * @JMS\Type("string") + * @JMS\SerializedName("type") + */ + public $type; + + /** + * @var bool + * + * @JMS\Type("bool") + * @JMS\SerializedName("afterFirstOrder") + */ + public $afterFirstOrder; + + /** + * @var string + * + * @JMS\Type("string") + * @JMS\SerializedName("beforePeriod") + */ + public $beforePeriod; +} diff --git a/src/Model/Entity/Loyalty/LoyaltyEventDiscount.php b/src/Model/Entity/Loyalty/LoyaltyEventDiscount.php index 1f3216206..6adbfb063 100644 --- a/src/Model/Entity/Loyalty/LoyaltyEventDiscount.php +++ b/src/Model/Entity/Loyalty/LoyaltyEventDiscount.php @@ -26,4 +26,12 @@ class LoyaltyEventDiscount * @JMS\SerializedName("id") */ public $id; + + /** + * @var \RetailCrm\Api\Model\Entity\Loyalty\LoyaltyEvent + * + * @JMS\Type("RetailCrm\Api\Model\Entity\Loyalty\LoyaltyEvent") + * @JMS\SerializedName("loyaltyEvent") + */ + public $loyaltyEvent; } diff --git a/src/Model/Entity/Loyalty/LoyaltyLevel.php b/src/Model/Entity/Loyalty/LoyaltyLevel.php index fc56e2fce..d4098b179 100644 --- a/src/Model/Entity/Loyalty/LoyaltyLevel.php +++ b/src/Model/Entity/Loyalty/LoyaltyLevel.php @@ -66,4 +66,12 @@ class LoyaltyLevel * @JMS\SerializedName("privilegeSizePromo") */ public $privilegeSizePromo; + + /** + * @var \RetailCrm\Api\Model\Entity\Loyalty\LoyaltyLevelCondition[] + * + * @JMS\Type("array") + * @JMS\SerializedName("creditConditions") + */ + public $creditConditions; } diff --git a/src/Model/Entity/Loyalty/LoyaltyLevelCondition.php b/src/Model/Entity/Loyalty/LoyaltyLevelCondition.php new file mode 100644 index 000000000..ee9d74cd4 --- /dev/null +++ b/src/Model/Entity/Loyalty/LoyaltyLevelCondition.php @@ -0,0 +1,53 @@ +") + * @JMS\SerializedName("items") + */ + public $items; +} diff --git a/src/Model/Entity/Loyalty/LoyaltyLevelConditionItem.php b/src/Model/Entity/Loyalty/LoyaltyLevelConditionItem.php new file mode 100644 index 000000000..b86b6dcec --- /dev/null +++ b/src/Model/Entity/Loyalty/LoyaltyLevelConditionItem.php @@ -0,0 +1,61 @@ +") + * @JMS\SerializedName("expireDate") + */ + public $expireDate; } diff --git a/src/Model/Entity/Loyalty/OrderProduct.php b/src/Model/Entity/Loyalty/OrderProduct.php index e5aba1a9e..ac0a56c8b 100644 --- a/src/Model/Entity/Loyalty/OrderProduct.php +++ b/src/Model/Entity/Loyalty/OrderProduct.php @@ -67,6 +67,14 @@ class OrderProduct */ public $initialPrice; + /** + * @var \RetailCrm\Api\Model\Entity\Orders\Items\AbstractDiscount[] + * + * @JMS\Type("array") + * @JMS\SerializedName("discounts") + */ + public $discounts; + /** * @var float * diff --git a/src/Model/Entity/Loyalty/SerializedLoyalty.php b/src/Model/Entity/Loyalty/SerializedLoyalty.php index 72e2ccf50..4a50fbc4a 100644 --- a/src/Model/Entity/Loyalty/SerializedLoyalty.php +++ b/src/Model/Entity/Loyalty/SerializedLoyalty.php @@ -19,6 +19,14 @@ */ class SerializedLoyalty { + /** + * @var string + * + * @JMS\Type("string") + * @JMS\SerializedName("currency") + */ + public $currency; + /** * @var string * diff --git a/src/Model/Entity/Orders/Items/Offer.php b/src/Model/Entity/Orders/Items/Offer.php index 7f086e8cc..afdd2e773 100644 --- a/src/Model/Entity/Orders/Items/Offer.php +++ b/src/Model/Entity/Orders/Items/Offer.php @@ -99,6 +99,13 @@ class Offer */ public $properties; + /** + * @var bool + * + * @JMS\Type("bool") + * @JMS\SerializedName("active") + */ + public $active; /** * @var float diff --git a/tests/src/ResourceGroup/LoyaltyTest.php b/tests/src/ResourceGroup/LoyaltyTest.php index a281a8d56..63f093c2c 100644 --- a/tests/src/ResourceGroup/LoyaltyTest.php +++ b/tests/src/ResourceGroup/LoyaltyTest.php @@ -203,8 +203,10 @@ public function testAccountBonusOperations(): void "externalId": "10" }, "bonus": { - "activationDate": "2020-11-27" - } + "activationDate": "2020-11-27", + "expireDate": "2021-11-27" + }, + "comment": "Начисление бонусов за заказ" }, { "type": "charge_for_order", @@ -302,6 +304,11 @@ public function testAccounts(): void { "active": true, "id": 162, + "loyalty": { + "id": 5, + "currency": "RUB", + "minResidualCost": 1 + }, "customer": { "id": 5141, "externalId": "1", @@ -643,7 +650,8 @@ public function testAccountGet(): void "id": 168, "loyalty": { "id": 1, - "currency": "RUB" + "currency": "RUB", + "minResidualCost": 1 }, "customer": { "id": 5260, @@ -701,14 +709,16 @@ public function testBonusOperations(): void "externalId": "9" }, "bonus": { - "activationDate": "2020-11-27" + "activationDate": "2020-11-27", + "expireDate": "2021-11-27" }, "loyaltyAccount": { "id": 147 }, "loyalty": { "id": 3 - } + }, + "comment": "Начисление бонусов за заказ" }, { "type": "charge_for_order", @@ -1035,8 +1045,25 @@ public function testCalculate(): void "order": { "bonusesCreditTotal": 0, "bonusesChargeTotal": 0, + "currency": "RUB", "privilegeType": "none", "totalSumm": 100, + "loyaltyEventDiscount": { + "id": 15, + "loyaltyEvent": { + "id": 7, + "privilegeType": "discount", + "privilegeSize": 10, + "privilegeSizePromo": 5, + "expirePeriod": "P30D", + "activatePeriod": 0, + "discountOneOrderOnly": true, + "discountForAllProducts": false, + "activatedAt": "2021-08-01 12:00:00", + "type": "birthday", + "beforePeriod": "P7D" + } + }, "customer": { "personalDiscount": 0 }, @@ -1049,6 +1076,12 @@ public function testCalculate(): void "bonusesChargeTotal": 0, "bonusesCreditTotal": 0, "initialPrice": 0, + "discounts": [ + { + "type": "loyalty_event", + "amount": 10 + } + ], "discountTotal": 0, "prices": [ { @@ -1068,7 +1101,12 @@ public function testCalculate(): void "maxChargeBonuses": 0, "maximum": true } - ] + ], + "loyalty": { + "currency": "RUB", + "name": "Основная программа", + "chargeRate": 1 + } } EOF; $item = new SerializedOrderProduct(); @@ -1128,6 +1166,7 @@ public function testLoyalties(): void "name": "Новая программа", "confirmSmsCharge": false, "confirmSmsRegistration": false, + "minResidualCost": 1, "createdAt": "2020-11-26 06:58:02", "activatedAt": "2020-11-26 06:59:52" }, @@ -1180,15 +1219,117 @@ public function testLoyaltiesGet(): void { "success": true, "loyalty": { + "levels": [ + { + "type": "bonus_percent", + "id": 21, + "name": "Базовый уровень", + "sum": 0, + "privilegeSize": 5, + "privilegeSizePromo": 3, + "creditConditions": [ + { + "id": 31, + "privilegeSize": 7.5, + "privilegeSizePromo": 4.5, + "items": [ + { + "id": 101, + "offer": { + "displayName": "Футболка, размер M", + "id": 1001, + "externalId": "offer-1", + "xmlId": "offer-xml-1", + "name": "Футболка", + "article": "T-SHIRT-M", + "vatRate": "20", + "properties": [], + "active": true, + "unit": { + "code": "pc", + "name": "Штука", + "sym": "шт." + }, + "barcode": "1234567890123" + } + }, + { + "id": 102, + "product": { + "id": 2001, + "name": "Футболка", + "externalId": "product-1", + "active": true + } + }, + { + "id": 103, + "productGroup": { + "id": 3001, + "name": "Одежда", + "externalId": "group-1", + "active": true + } + }, + { + "id": 104, + "manufacturer": "RetailCRM" + } + ] + } + ] + } + ], + "expirePeriod": "P180D", + "burnSettings": [ + { + "id": 41, + "period": "P365D", + "percent": 50 + } + ], "active": true, "blocked": false, "currency": "RUB", "id": 4, "name": "Битрикс новый", + "burnType": 2, "confirmSmsCharge": false, "confirmSmsRegistration": false, + "maxChargePercent": 30, + "minResidualCost": 1, + "events": [ + { + "id": 51, + "privilegeType": "bonus", + "privilegeSize": 500, + "privilegeSizePromo": 500, + "expirePeriod": "P30D", + "activatePeriod": 0, + "discountOneOrderOnly": false, + "discountForAllProducts": true, + "activatedAt": "2021-03-17 18:09:43", + "type": "welcome", + "afterFirstOrder": true + }, + { + "id": 52, + "privilegeType": "discount", + "privilegeSize": 15, + "privilegeSizePromo": 10, + "expirePeriod": "P7D", + "activatePeriod": 1, + "discountOneOrderOnly": true, + "discountForAllProducts": false, + "activatedAt": "2021-03-18 10:00:00", + "type": "birthday", + "beforePeriod": "P3D" + } + ], "createdAt": "2021-03-17 18:08:02", - "activatedAt": "2021-03-17 18:09:43" + "activatedAt": "2021-03-17 18:09:43", + "deactivatedAt": "2022-03-17 18:09:43", + "blockedAt": "2022-03-18 18:09:43" }, "requiredFields": [] }