From 5f69051859c187e01158d1a7cbca44bded7e88cf Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Tue, 16 Nov 2021 10:48:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=BC=D0=B0=20=D0=BB=D0=BE=D1=8F=D0=BB=D1=8C=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * New module structure (refactoring) * Simple serializer and deserializer with models, new architecture * Move logic to strategies * Partial api client facade implementation (full implementation is not necessary for now) * Loyalty feature installer * Sms verification order (#167) * Make updater self-sufficient * Fix for order submit & fix for incorrect component rendering in the constructor * Fix for loyalty personal area error handling * Fix for cart component identity * Fix for softlock when customer cannot be registered in loyalty Co-authored-by: Сергей Чазов <45812598+Chazovs@users.noreply.github.com> Co-authored-by: Sergey Chazov --- CHANGELOG.md | 3 + bin/build | 3 +- bin/build-release | 4 +- composer.json | 2 + composer.lock | 573 +- helpers/release/ModifiedFile.php | 42 +- .../RetailcrmClasspathBuilder.php | 307 + .../classes/general/ApiClient_v4.php | 13 +- .../classes/general/ApiClient_v5.php | 217 +- intaro.retailcrm/classes/general/Logger.php | 15 +- .../classes/general/RCrmActions.php | 48 +- .../classes/general/Response/ApiResponse.php | 8 + .../general/RetailcrmConfigProvider.php | 840 +- .../classes/general/RetailcrmConstants.php | 63 +- .../general/RetailcrmDependencyLoader.php | 78 +- .../classes/general/events/RetailCrmEvent.php | 358 +- .../general/history/FastOrderHistory.php | 2 +- .../general/history/RetailCrmHistory_v4.php | 6 +- .../general/history/RetailCrmHistory_v5.php | 95 +- .../classes/general/history/RetailUser.php | 47 +- .../general/order/RetailCrmOrder_v4.php | 2 +- .../general/order/RetailCrmOrder_v5.php | 97 +- .../general/services/RetailCrmService.php | 3 +- .../classes/general/user/RetailCrmUser.php | 2 +- intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/export/export_setup.php | 6 +- intaro.retailcrm/include.php | 90 +- .../install/export/bitrix/js/intaro/sms.js | 59 + .../include/catalog_export}/retailcrm_run.php | 0 .../catalog_export}/retailcrm_setup.php | 0 .../intaro/lp.register/.description.php | 16 + .../intaro/lp.register/.parameters.php | 4 + .../intaro/lp.register/component.php | 6 + .../lp.register/lang/ru/.description.php | 4 + .../lp.register/lang/ru/result_modifier.php | 3 + .../templates/.default/.parameters.php | 6 + .../.default/lang/ru/.parameters.php | 2 + .../templates/.default/lang/ru/template.php | 27 + .../templates/.default/result_modifier.php | 69 + .../lp.register/templates/.default/script.js | 229 + .../templates/.default/template.php | 227 + .../intaro/lp.score/.description.php | 16 + .../intaro/lp.score/.parameters.php | 4 + .../components/intaro/lp.score/component.php | 79 + .../intaro/lp.score/lang/ru/.description.php | 4 + .../intaro/lp.score/lang/ru/component.php | 11 + .../components/intaro/lp.score/register.php | 5 + .../templates/.default/.parameters.php | 6 + .../.default/lang/ru/.parameters.php | 2 + .../templates/.default/lang/ru/template.php | 43 + .../lp.score/templates/.default/template.php | 96 + .../intaro/main.register/.description.php | 16 + .../intaro/main.register/.parameters.php | 123 + .../intaro/main.register/component.php | 384 + .../main.register/images/user_register.gif | Bin 0 -> 507 bytes .../main.register/lang/ru/.description.php | 4 + .../main.register/lang/ru/.parameters.php | 48 + .../main.register/lang/ru/component.php | 9 + .../main.register/lang/ru/help/.tooltips.php | 11 + .../templates/.default/.parameters.php | 10 + .../.default/images/sec-unlocked.png | Bin 0 -> 574 bytes .../templates/.default/images/sec.png | Bin 0 -> 566 bytes .../.default/lang/ru/.parameters.php | 3 + .../.default/lang/ru/result_modifier.php | 3 + .../templates/.default/lang/ru/template.php | 82 + .../templates/.default/result_modifier.php | 69 + .../templates/.default/script.js | 256 + .../templates/.default/style.css | 8 + .../templates/.default/style.min.css | 1 + .../templates/.default/template.php | 556 + .../sale.basket.basket/.description.php | 16 + .../intaro/sale.basket.basket/.parameters.php | 455 + .../intaro/sale.basket.basket/ajax.php | 60 + .../intaro/sale.basket.basket/class.php | 4283 ++++ .../sale.basket.basket/help/en/index.php | 2 + .../sale.basket.basket/help/ru/index.php | 227 + .../sale.basket.basket/images/sale_basket.gif | Bin 0 -> 471 bytes .../lang/en/.description.php | 4 + .../lang/en/.parameters.php | 75 + .../sale.basket.basket/lang/en/class.php | 10 + .../sale.basket.basket/lang/en/component.php | 8 + .../lang/ru/.description.php | 4 + .../lang/ru/.parameters.php | 75 + .../sale.basket.basket/lang/ru/class.php | 10 + .../sale.basket.basket/lang/ru/component.php | 8 + .../settings/dragdrop_order/script.js | 141 + .../settings/dragdrop_order/script.map.js | 1 + .../settings/dragdrop_order/script.min.js | 1 + .../settings/dragdrop_order/style.css | 58 + .../settings/dragdrop_order/style.min.css | 1 + .../settings/position/script.js | 105 + .../settings/position/script.map.js | 1 + .../settings/position/script.min.js | 1 + .../settings/position/style.css | 295 + .../settings/position/style.min.css | 1 + .../templates/.default/.parameters.php | 379 + .../templates/.default/basket_items.php | 581 + .../templates/.default/basket_items_delay.php | 85 + .../.default/basket_items_delayed.php | 339 + .../.default/basket_items_not_available.php | 325 + .../.default/basket_items_notavail.php | 81 + .../.default/basket_items_subscribe.php | 56 + .../.default/basket_items_subscribed.php | 308 + .../templates/.default/empty.php | 27 + .../templates/.default/functions.php | 18 + .../templates/.default/images/arr_left.png | Bin 0 -> 3034 bytes .../templates/.default/images/arr_right.png | Bin 0 -> 3036 bytes .../templates/.default/images/arrows.png | Bin 0 -> 431 bytes .../templates/.default/images/empty_cart.svg | 11 + .../templates/.default/images/fade_left.png | Bin 0 -> 959 bytes .../templates/.default/images/fade_right.png | Bin 0 -> 2835 bytes .../templates/.default/images/loader.gif | Bin 0 -> 17119 bytes .../templates/.default/images/no_photo.png | Bin 0 -> 5636 bytes .../templates/.default/images/paypal.gif | Bin 0 -> 3091 bytes .../templates/.default/images/table_head.gif | Bin 0 -> 1342 bytes .../templates/.default/images/x2border.png | Bin 0 -> 2811 bytes .../.default/images/x2border_active.png | Bin 0 -> 2809 bytes .../.default/images/x2borderactive.png | Bin 0 -> 2809 bytes .../.default/js-templates/basket-item.php | 471 + .../.default/js-templates/basket-total.php | 132 + .../templates/.default/js/action-pool.js | 286 + .../templates/.default/js/action-pool.map.js | 1 + .../templates/.default/js/action-pool.min.js | 1 + .../templates/.default/js/component.js | 2487 +++ .../templates/.default/js/component.map.js | 1 + .../templates/.default/js/filter.js | 588 + .../templates/.default/js/filter.map.js | 1 + .../templates/.default/js/filter.min.js | 1 + .../templates/.default/js/mustache.js | 636 + .../templates/.default/js/mustache.map.js | 1 + .../templates/.default/js/mustache.min.js | 1 + .../.default/lang/en/.parameters.php | 38 + .../templates/.default/lang/en/mutator.php | 7 + .../templates/.default/lang/en/template.php | 42 + .../.default/lang/ru/.parameters.php | 40 + .../templates/.default/lang/ru/mutator.php | 7 + .../.default/lang/ru/result_modifier.php | 4 + .../templates/.default/lang/ru/template.php | 45 + .../templates/.default/mutator.php | 445 + .../templates/.default/result_modifier.php | 81 + .../templates/.default/script.js | 1423 ++ .../templates/.default/script.map.js | 1 + .../templates/.default/style.css | 2225 ++ .../templates/.default/style.min.css | 1 + .../templates/.default/template.php | 336 + .../themes/black/images/x2border_active.png | Bin 0 -> 2809 bytes .../templates/.default/themes/black/style.css | 48 + .../.default/themes/black/style.min.css | 1 + .../themes/blue/images/x2border_active.png | Bin 0 -> 2809 bytes .../templates/.default/themes/blue/style.css | 29 + .../.default/themes/blue/style.min.css | 1 + .../themes/green/images/x2border_active.png | Bin 0 -> 2809 bytes .../templates/.default/themes/green/style.css | 29 + .../.default/themes/green/style.min.css | 1 + .../themes/red/images/x2border_active.png | Bin 0 -> 2809 bytes .../templates/.default/themes/red/style.css | 29 + .../.default/themes/red/style.min.css | 1 + .../themes/wood/images/x2border_active.png | Bin 0 -> 2809 bytes .../templates/.default/themes/wood/style.css | 48 + .../.default/themes/wood/style.min.css | 1 + .../themes/yellow/images/x2border_active.png | Bin 0 -> 2811 bytes .../.default/themes/yellow/style.css | 29 + .../.default/themes/yellow/style.min.css | 1 + .../intaro/sale.order.ajax/.description.php | 17 + .../intaro/sale.order.ajax/.parameters.php | 406 + .../intaro/sale.order.ajax/ajax.php | 48 + .../intaro/sale.order.ajax/class.php | 6255 ++++++ .../components/intaro/sale.order.ajax/get.php | 99 + .../images/sale_order_full.gif | Bin 0 -> 487 bytes .../sale.order.ajax/lang/en/.description.php | 4 + .../sale.order.ajax/lang/en/.parameters.php | 71 + .../intaro/sale.order.ajax/lang/en/class.php | 59 + .../intaro/sale.order.ajax/lang/en/map.php | 8 + .../sale.order.ajax/lang/ru/.description.php | 4 + .../sale.order.ajax/lang/ru/.parameters.php | 72 + .../intaro/sale.order.ajax/lang/ru/class.php | 58 + .../intaro/sale.order.ajax/lang/ru/map.php | 8 + .../templates/.default/.parameters.php | 786 + .../templates/.default/confirm.php | 172 + .../templates/.default/empty.php | 27 + .../templates/.default/hide/order_ajax.min.js | 2 + .../templates/.default/images/alert.png | Bin 0 -> 3729 bytes .../templates/.default/images/calendar.svg | 11 + .../.default/images/delivery_logo.png | Bin 0 -> 5127 bytes .../templates/.default/images/empty_cart.svg | 11 + .../templates/.default/images/loader.gif | Bin 0 -> 17119 bytes .../.default/images/pay_system_logo.png | Bin 0 -> 8776 bytes .../templates/.default/images/pickup_logo.png | Bin 0 -> 1827 bytes .../.default/images/product_logo.png | Bin 0 -> 3814 bytes .../templates/.default/images/sprite.png | Bin 0 -> 17135 bytes .../.default/lang/en/.parameters.php | 150 + .../templates/.default/lang/en/template.php | 138 + .../.default/lang/ru/.parameters.php | 152 + .../.default/lang/ru/result_modifier.php | 8 + .../templates/.default/lang/ru/template.php | 153 + .../templates/.default/order_ajax.js | 8387 ++++++++ .../templates/.default/order_ajax.map.js | 1 + .../templates/.default/result_modifier.php | 65 + .../templates/.default/script.js | 444 + .../templates/.default/script.map.js | 1 + .../templates/.default/script.min.js | 2 + .../templates/.default/scripts/google_maps.js | 264 + .../.default/scripts/google_maps.map.js | 1 + .../.default/scripts/google_maps.min.js | 1 + .../templates/.default/scripts/intaro.js | 98 + .../templates/.default/scripts/lodash.js | 17108 ++++++++++++++++ .../templates/.default/scripts/yandex_maps.js | 334 + .../.default/scripts/yandex_maps.map.js | 1 + .../.default/scripts/yandex_maps.min.js | 2 + .../templates/.default/style.css | 1526 ++ .../templates/.default/style.min.css | 1 + .../templates/.default/style_cart.css | 444 + .../templates/.default/template.php | 737 + .../install/export/lp-register/index.php | 21 + .../install/export/lp-score/index.php | 13 + intaro.retailcrm/install/index.php | 705 +- intaro.retailcrm/install/version.php | 4 +- intaro.retailcrm/lang/ru/install/index.php | 57 +- intaro.retailcrm/lang/ru/install/step6.php | 2 +- intaro.retailcrm/lang/ru/options.php | 38 +- intaro.retailcrm/lib/component/agent.php | 4 +- .../lib/component/apiclient/clientadapter.php | 146 + .../apiclient/traits/baseclienttrait.php | 39 + .../traits/customerscorporatetrait.php | 391 + .../apiclient/traits/customerstrait.php | 186 + .../apiclient/traits/loyaltytrait.php | 163 + .../component/apiclient/traits/ordertrait.php | 62 + .../builder/api/corporatecustomerbuilder.php | 347 + .../component/builder/api/customerbuilder.php | 269 + .../builder/bitrix/customerbuilder.php | 238 + .../builder/bitrix/loyaltydatabuilder.php | 196 + .../component/builder/builderinterface.php | 44 + .../builder/exception/builderexception.php | 23 + .../lib/component/configprovider.php | 1095 + intaro.retailcrm/lib/component/constants.php | 103 + .../component/converter/datetimeconverter.php | 56 + .../lib/component/dependencyloader.php | 100 + intaro.retailcrm/lib/component/events.php | 51 + .../lib/component/factory/clientfactory.php | 41 + .../lib/component/handlers/eventshandlers.php | 269 + .../installer/loyaltyinstallertrait.php | 251 + .../lib/component/json/deserializer.php | 91 + .../exception/invalidannotationexception.php | 23 + .../lib/component/json/mapping/accessor.php | 47 + .../component/json/mapping/bitrixboolean.php | 28 + .../component/json/mapping/notransform.php | 28 + .../json/mapping/postdeserialize.php | 28 + .../component/json/mapping/postserialize.php | 28 + .../component/json/mapping/serializedname.php | 39 + .../lib/component/json/mapping/type.php | 39 + .../component/json/propertyannotations.php | 77 + .../lib/component/json/serializer.php | 95 + .../json/strategy/annotationreadertrait.php | 33 + .../strategy/deserialize/datetimestrategy.php | 42 + .../deserializestrategyinterface.php | 42 + .../strategy/deserialize/entitystrategy.php | 100 + .../strategy/deserialize/innertypetrait.php | 38 + .../deserialize/simpletypestrategy.php | 63 + .../deserialize/typedarraystrategy.php | 67 + .../json/strategy/isnotransformtrait.php | 40 + .../strategy/serialize/datetimestrategy.php | 38 + .../strategy/serialize/entitystrategy.php | 89 + .../strategy/serialize/innertypetrait.php | 38 + .../serialize/serializestrategyinterface.php | 43 + .../strategy/serialize/simpletypestrategy.php | 66 + .../strategy/serialize/typedarraystrategy.php | 59 + .../json/strategy/strategyfactory.php | 176 + .../json/strategy/typedarraytrait.php | 46 + .../lib/component/servicelocator.php | 120 + .../lib/controller/adminpanel.php | 146 + .../lib/controller/loyalty/basket.php | 60 + .../lib/controller/loyalty/order.php | 153 + .../lib/controller/loyalty/register.php | 510 + .../lib/dataprovider/currentuserprovider.php | 45 + intaro.retailcrm/lib/icml/settingsservice.php | 16 +- .../en/service/orderloyaltydataservice.php | 14 + .../ru/component/handlers/eventshandlers.php | 4 + .../lib/lang/ru/controller/loyalty/order.php | 3 + .../lang/ru/controller/loyalty/register.php | 14 + .../lang/ru/service/loyaltyaccountservice.php | 8 + .../lib/lang/ru/service/loyaltyservice.php | 20 + .../ru/service/orderloyaltydataservice.php | 14 + .../lib/model/api/abstractapimodel.php | 72 + .../lib/model/api/abstractloyaltyevent.php | 34 + intaro.retailcrm/lib/model/api/address.php | 210 + .../lib/model/api/apimodelinterface.php | 26 + .../lib/model/api/codevaluemodel.php | 40 + intaro.retailcrm/lib/model/api/company.php | 144 + intaro.retailcrm/lib/model/api/contragent.php | 174 + intaro.retailcrm/lib/model/api/customer.php | 314 + .../lib/model/api/customercontact.php | 74 + .../lib/model/api/customernote.php | 68 + .../lib/model/api/dictionaryelements.php | 38 + intaro.retailcrm/lib/model/api/history.php | 205 + .../lib/model/api/identifierspair.php | 40 + intaro.retailcrm/lib/model/api/item.php | 65 + intaro.retailcrm/lib/model/api/loyalty.php | 124 + .../lib/model/api/loyaltyaccount.php | 176 + .../model/api/loyaltyaccountapifiltertype.php | 183 + .../lib/model/api/loyaltycalculation.php | 74 + .../lib/model/api/loyaltylevel.php | 79 + .../lib/model/api/order/createorder.php | 24 + .../lib/model/api/order/order.php | 170 + .../lib/model/api/order/orderdeliverydata.php | 72 + .../lib/model/api/order/orderproduct.php | 115 + .../model/api/order/orderproductpriceitem.php | 44 + .../lib/model/api/order/package.php | 72 + .../lib/model/api/order/packageitem.php | 40 + .../api/order/packageitemorderproduct.php | 48 + .../api/order/serializeddeliveryservice.php | 56 + .../api/order/serializedorderdelivery.php | 84 + .../lib/model/api/orderproduct.php | 94 + .../lib/model/api/paginationresponse.php | 63 + intaro.retailcrm/lib/model/api/payment.php | 54 + intaro.retailcrm/lib/model/api/phone.php | 41 + intaro.retailcrm/lib/model/api/pricetype.php | 34 + .../lib/model/api/request/bytrait.php | 32 + ...stomerscorporateaddressescreaterequest.php | 43 + ...customerscorporateaddresseseditrequest.php | 45 + .../customerscorporateaddressesrequest.php | 45 + ...stomerscorporatecompaniescreaterequest.php | 43 + ...customerscorporatecompanieseditrequest.php | 45 + .../customerscorporatecompaniesrequest.php | 45 + ...ustomerscorporatecontactscreaterequest.php | 43 + .../customerscorporatecontactseditrequest.php | 45 + .../customerscorporatecontactsrequest.php | 45 + .../customerscorporatecreaterequest.php | 36 + ...ustomerscorporatefixexternalidsrequest.php | 33 + .../customerscorporatelistrequest.php | 36 + .../customerscorporateuploadrequest.php | 36 + .../customers/customerscreaterequest.php | 36 + .../customers/customerseditrequest.php | 38 + .../customersfixexternalidsrequest.php | 33 + .../request/customers/customersgetrequest.php | 41 + .../customers/customershistoryrequest.php | 37 + .../customers/customerslistrequest.php | 36 + .../customers/customersnotescreaterequest.php | 36 + .../customers/customersnotesrequest.php | 36 + .../customers/customersuploadrequest.php | 36 + .../lib/model/api/request/entitybytrait.php | 32 + .../api/request/filter/companyfilter.php | 41 + .../request/filter/customercontactfilter.php | 49 + .../api/request/filter/customerfilter.php | 497 + .../filter/customerhistoryfilterv4type.php | 65 + .../customerscorporateaddressesfilter.php | 57 + .../filter/customerscorporatefilter.php | 361 + .../request/filter/customersnotesfilter.php | 81 + .../account/loyaltyaccountactivaterequest.php | 35 + .../account/loyaltyaccountcreaterequest.php | 43 + .../account/loyaltyaccounteditrequest.php | 43 + .../loyalty/account/loyaltyaccountrequest.php | 53 + .../loyalty/loyaltycalculaterequest.php | 51 + .../loyalty/orderloyaltyapplyrequest.php | 53 + .../lib/model/api/request/paginatedtrait.php | 40 + .../lib/model/api/request/sitescopedtrait.php | 32 + .../smsverificationconfirmrequest.php | 33 + .../smsverificationstatusrequest.php | 35 + .../lib/model/api/requiredfields.php | 79 + .../api/response/abstractapiresponsemodel.php | 41 + .../model/api/response/companiesresponse.php | 32 + .../lib/model/api/response/createresponse.php | 32 + .../api/response/customerchangeresponse.php | 32 + .../response/customercorporateresponse.php | 32 + .../model/api/response/customerresponse.php | 32 + .../customerscorporateaddressesresponse.php | 32 + .../customerscorporatecontactsresponse.php | 32 + .../response/customerscorporateresponse.php | 32 + .../api/response/customersnotesresponse.php | 32 + .../model/api/response/customersresponse.php | 32 + .../api/response/customersuploadresponse.php | 32 + .../model/api/response/historyresponse.php | 32 + .../loyaltyaccountactivateresponse.php | 51 + .../account/loyaltyaccountcreateresponse.php | 51 + .../account/loyaltyaccounteditresponse.php | 51 + .../account/loyaltyaccountresponse.php | 51 + .../loyalty/loyaltycalculateresponse.php | 63 + .../loyalty/loyaltyloyaltiesresponse.php | 39 + .../loyalty/loyaltyloyaltyresponse.php | 39 + .../model/api/response/operationresponse.php | 48 + .../loyalty/orderloyaltyapplyresponse.php | 51 + .../api/response/orderscreateresponse.php | 48 + .../model/api/response/orderseditresponse.php | 39 + .../model/api/response/ordersgetresponse.php | 39 + .../model/api/response/paginationresponse.php | 56 + .../response/settings/credentialsresponse.php | 59 + .../smsverificationconfirmresponse.php | 41 + .../smsverificationstatusresponse.php | 43 + .../api/serializedcreateloyaltyaccount.php | 64 + .../lib/model/api/serializedloyalty.php | 44 + .../lib/model/api/serializedloyaltyorder.php | 124 + .../lib/model/api/serializedorder.php | 70 + .../lib/model/api/serializedorderdelivery.php | 34 + .../lib/model/api/serializedorderproduct.php | 94 + .../model/api/serializedorderproductoffer.php | 54 + .../model/api/serializedorderreference.php | 54 + .../model/api/serializedrelationcustomer.php | 44 + .../lib/model/api/smsverification.php | 74 + .../lib/model/api/smsverificationconfirm.php | 43 + .../lib/model/api/timeinterval.php | 49 + intaro.retailcrm/lib/model/api/user.php | 34 + .../lib/model/bitrix/abstractmodelproxy.php | 240 + .../bitrix/abstractserializablemodel.php | 374 + .../lib/model/bitrix/agreement.php | 59 + .../lib/model/bitrix/buyerprofile.php | 165 + intaro.retailcrm/lib/model/bitrix/fuser.php | 49 + .../lib/model/bitrix/orderloyaltydata.php | 143 + .../lib/model/bitrix/orderprops.php | 94 + .../lib/model/bitrix/orm/tomodule.php | 199 + .../lib/model/bitrix/orm/utsuser.php | 77 + .../lib/model/bitrix/paysystemaction.php | 94 + .../lib/model/bitrix/smscookie.php | 73 + .../lib/model/bitrix/tomodule.php | 61 + intaro.retailcrm/lib/model/bitrix/user.php | 1733 ++ .../lib/model/bitrix/userloyaltydata.php | 183 + .../lib/repository/abstractrepository.php | 36 + .../lib/repository/agreementrepository.php | 68 + .../lib/repository/buyerprofilerepository.php | 84 + .../lib/repository/currencyrepository.php | 52 + .../lib/repository/fuserrepository.php | 53 + .../lib/repository/managerrepository.php | 8 +- .../repository/orderloyaltydatarepository.php | 210 + .../lib/repository/orderpropsrepository.php | 69 + .../repository/paysystemactionrepository.php | 40 + .../lib/repository/persontyperepository.php | 41 + .../lib/repository/templaterepository.php | 61 + .../lib/repository/tomodulerepository.php | 58 + .../repository/userloyaltydatarepository.php | 57 + .../lib/repository/userrepository.php | 93 + .../lib/service/cookieservice.php | 106 + .../lib/service/customerservice.php | 168 + .../lpaccountsavailableexception.php | 25 + .../lib/service/loyaltyaccountservice.php | 620 + .../lib/service/loyaltyservice.php | 550 + .../lib/service/orderloyaltydataservice.php | 578 + intaro.retailcrm/lib/service/utils.php | 261 + .../common/annotations/annotation.php | 79 + .../annotations/annotation/attribute.php | 47 + .../annotations/annotation/attributes.php | 37 + .../common/annotations/annotation/enum.php | 84 + .../annotation/ignoreannotation.php | 54 + .../annotations/annotation/required.php | 33 + .../common/annotations/annotation/target.php | 107 + .../annotations/annotationexception.php | 197 + .../common/annotations/annotationreader.php | 418 + .../common/annotations/annotationregistry.php | 180 + .../doctrine/common/annotations/doclexer.php | 147 + .../doctrine/common/annotations/docparser.php | 1221 ++ .../doctrine/common/annotations/phpparser.php | 91 + .../doctrine/common/annotations/reader.php | 89 + .../common/annotations/tokenparser.php | 194 + .../doctrine/common/lexer/abstractlexer.php | 350 + intaro.retailcrm/options.php | 2442 ++- intaro.retailcrm/updater.php | 879 +- phpdoc.dist.xml | 22 + tests/BitrixTestCase.php | 1 + tests/bootstrap.php | 9 +- tests/classes/general/AddressBuilderTest.php | 0 tests/classes/general/CustomerBuilderTest.php | 0 .../general/events/RetailCrmEventTest.php | 2 +- .../general/order/RetailCrmOrder_v5Test.php | 0 .../general/services/RetailCrmServiceTest.php | 0 tests/helpers/Helpers.php | 53 + .../api/CorporateCustomerBuilderTest.php | 97 + .../builder/api/CustomerBuilderTest.php | 128 + .../builder/bitrix/CustomerBuilderTest.php | 100 + .../converter/DateTimeConverterTest.php | 42 + .../component/factory/ClientFactoryTest.php | 22 + 467 files changed, 87501 insertions(+), 2793 deletions(-) create mode 100644 intaro.retailcrm/RetailcrmClasspathBuilder.php create mode 100644 intaro.retailcrm/install/export/bitrix/js/intaro/sms.js rename intaro.retailcrm/install/export/{ => bitrix/php_interface/include/catalog_export}/retailcrm_run.php (100%) rename intaro.retailcrm/install/export/{ => bitrix/php_interface/include/catalog_export}/retailcrm_setup.php (100%) create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/component.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/lang/ru/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/lang/ru/result_modifier.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/templates/.default/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/templates/.default/lang/ru/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/templates/.default/lang/ru/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/templates/.default/result_modifier.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/templates/.default/script.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.register/templates/.default/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/component.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/lang/ru/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/lang/ru/component.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/register.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/templates/.default/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/templates/.default/lang/ru/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/templates/.default/lang/ru/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/lp.score/templates/.default/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/component.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/images/user_register.gif create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/lang/ru/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/lang/ru/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/lang/ru/component.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/lang/ru/help/.tooltips.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/images/sec-unlocked.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/images/sec.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/lang/ru/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/lang/ru/result_modifier.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/lang/ru/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/result_modifier.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/script.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/ajax.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/class.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/help/en/index.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/help/ru/index.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/images/sale_basket.gif create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/lang/en/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/lang/en/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/lang/en/class.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/lang/en/component.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/lang/ru/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/lang/ru/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/lang/ru/class.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/lang/ru/component.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/dragdrop_order/script.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/dragdrop_order/script.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/dragdrop_order/script.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/dragdrop_order/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/dragdrop_order/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/position/script.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/position/script.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/position/script.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/position/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/settings/position/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/basket_items.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/basket_items_delay.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/basket_items_delayed.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/basket_items_not_available.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/basket_items_notavail.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/basket_items_subscribe.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/basket_items_subscribed.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/empty.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/functions.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/arr_left.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/arr_right.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/arrows.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/empty_cart.svg create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/fade_left.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/fade_right.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/loader.gif create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/no_photo.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/paypal.gif create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/table_head.gif create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/x2border.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/x2border_active.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/images/x2borderactive.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js-templates/basket-item.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js-templates/basket-total.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/action-pool.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/action-pool.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/action-pool.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/component.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/component.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/filter.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/filter.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/filter.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/mustache.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/mustache.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/js/mustache.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/lang/en/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/lang/en/mutator.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/lang/en/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/lang/ru/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/lang/ru/mutator.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/lang/ru/result_modifier.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/lang/ru/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/mutator.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/result_modifier.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/script.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/script.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/black/images/x2border_active.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/black/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/black/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/blue/images/x2border_active.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/blue/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/blue/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/green/images/x2border_active.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/green/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/green/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/red/images/x2border_active.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/red/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/red/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/wood/images/x2border_active.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/wood/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/wood/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/yellow/images/x2border_active.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/yellow/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.basket.basket/templates/.default/themes/yellow/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/ajax.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/class.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/get.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/images/sale_order_full.gif create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/lang/en/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/lang/en/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/lang/en/class.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/lang/en/map.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/lang/ru/.description.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/lang/ru/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/lang/ru/class.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/lang/ru/map.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/confirm.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/empty.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/hide/order_ajax.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/alert.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/calendar.svg create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/delivery_logo.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/empty_cart.svg create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/loader.gif create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/pay_system_logo.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/pickup_logo.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/product_logo.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/images/sprite.png create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/lang/en/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/lang/en/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/lang/ru/.parameters.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/lang/ru/result_modifier.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/lang/ru/template.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/order_ajax.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/order_ajax.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/result_modifier.php create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/script.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/script.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/script.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/scripts/google_maps.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/scripts/google_maps.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/scripts/google_maps.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/scripts/intaro.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/scripts/lodash.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/scripts/yandex_maps.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/scripts/yandex_maps.map.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/scripts/yandex_maps.min.js create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/style.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/style.min.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/style_cart.css create mode 100644 intaro.retailcrm/install/export/local/components/intaro/sale.order.ajax/templates/.default/template.php create mode 100644 intaro.retailcrm/install/export/lp-register/index.php create mode 100644 intaro.retailcrm/install/export/lp-score/index.php create mode 100644 intaro.retailcrm/lib/component/apiclient/clientadapter.php create mode 100644 intaro.retailcrm/lib/component/apiclient/traits/baseclienttrait.php create mode 100644 intaro.retailcrm/lib/component/apiclient/traits/customerscorporatetrait.php create mode 100644 intaro.retailcrm/lib/component/apiclient/traits/customerstrait.php create mode 100644 intaro.retailcrm/lib/component/apiclient/traits/loyaltytrait.php create mode 100644 intaro.retailcrm/lib/component/apiclient/traits/ordertrait.php create mode 100644 intaro.retailcrm/lib/component/builder/api/corporatecustomerbuilder.php create mode 100644 intaro.retailcrm/lib/component/builder/api/customerbuilder.php create mode 100644 intaro.retailcrm/lib/component/builder/bitrix/customerbuilder.php create mode 100644 intaro.retailcrm/lib/component/builder/bitrix/loyaltydatabuilder.php create mode 100644 intaro.retailcrm/lib/component/builder/builderinterface.php create mode 100644 intaro.retailcrm/lib/component/builder/exception/builderexception.php create mode 100644 intaro.retailcrm/lib/component/configprovider.php create mode 100644 intaro.retailcrm/lib/component/constants.php create mode 100644 intaro.retailcrm/lib/component/converter/datetimeconverter.php create mode 100644 intaro.retailcrm/lib/component/dependencyloader.php create mode 100644 intaro.retailcrm/lib/component/events.php create mode 100644 intaro.retailcrm/lib/component/factory/clientfactory.php create mode 100644 intaro.retailcrm/lib/component/handlers/eventshandlers.php create mode 100644 intaro.retailcrm/lib/component/installer/loyaltyinstallertrait.php create mode 100644 intaro.retailcrm/lib/component/json/deserializer.php create mode 100644 intaro.retailcrm/lib/component/json/exception/invalidannotationexception.php create mode 100644 intaro.retailcrm/lib/component/json/mapping/accessor.php create mode 100644 intaro.retailcrm/lib/component/json/mapping/bitrixboolean.php create mode 100644 intaro.retailcrm/lib/component/json/mapping/notransform.php create mode 100644 intaro.retailcrm/lib/component/json/mapping/postdeserialize.php create mode 100644 intaro.retailcrm/lib/component/json/mapping/postserialize.php create mode 100644 intaro.retailcrm/lib/component/json/mapping/serializedname.php create mode 100644 intaro.retailcrm/lib/component/json/mapping/type.php create mode 100644 intaro.retailcrm/lib/component/json/propertyannotations.php create mode 100644 intaro.retailcrm/lib/component/json/serializer.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/annotationreadertrait.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/deserialize/datetimestrategy.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/deserialize/deserializestrategyinterface.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/deserialize/entitystrategy.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/deserialize/innertypetrait.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/deserialize/simpletypestrategy.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/deserialize/typedarraystrategy.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/isnotransformtrait.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/serialize/datetimestrategy.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/serialize/entitystrategy.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/serialize/innertypetrait.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/serialize/serializestrategyinterface.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/serialize/simpletypestrategy.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/serialize/typedarraystrategy.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/strategyfactory.php create mode 100644 intaro.retailcrm/lib/component/json/strategy/typedarraytrait.php create mode 100644 intaro.retailcrm/lib/component/servicelocator.php create mode 100644 intaro.retailcrm/lib/controller/adminpanel.php create mode 100644 intaro.retailcrm/lib/controller/loyalty/basket.php create mode 100644 intaro.retailcrm/lib/controller/loyalty/order.php create mode 100644 intaro.retailcrm/lib/controller/loyalty/register.php create mode 100644 intaro.retailcrm/lib/dataprovider/currentuserprovider.php create mode 100644 intaro.retailcrm/lib/lang/en/service/orderloyaltydataservice.php create mode 100644 intaro.retailcrm/lib/lang/ru/component/handlers/eventshandlers.php create mode 100644 intaro.retailcrm/lib/lang/ru/controller/loyalty/order.php create mode 100644 intaro.retailcrm/lib/lang/ru/controller/loyalty/register.php create mode 100644 intaro.retailcrm/lib/lang/ru/service/loyaltyaccountservice.php create mode 100644 intaro.retailcrm/lib/lang/ru/service/loyaltyservice.php create mode 100644 intaro.retailcrm/lib/lang/ru/service/orderloyaltydataservice.php create mode 100644 intaro.retailcrm/lib/model/api/abstractapimodel.php create mode 100644 intaro.retailcrm/lib/model/api/abstractloyaltyevent.php create mode 100644 intaro.retailcrm/lib/model/api/address.php create mode 100644 intaro.retailcrm/lib/model/api/apimodelinterface.php create mode 100644 intaro.retailcrm/lib/model/api/codevaluemodel.php create mode 100644 intaro.retailcrm/lib/model/api/company.php create mode 100644 intaro.retailcrm/lib/model/api/contragent.php create mode 100644 intaro.retailcrm/lib/model/api/customer.php create mode 100644 intaro.retailcrm/lib/model/api/customercontact.php create mode 100644 intaro.retailcrm/lib/model/api/customernote.php create mode 100644 intaro.retailcrm/lib/model/api/dictionaryelements.php create mode 100644 intaro.retailcrm/lib/model/api/history.php create mode 100644 intaro.retailcrm/lib/model/api/identifierspair.php create mode 100644 intaro.retailcrm/lib/model/api/item.php create mode 100644 intaro.retailcrm/lib/model/api/loyalty.php create mode 100644 intaro.retailcrm/lib/model/api/loyaltyaccount.php create mode 100644 intaro.retailcrm/lib/model/api/loyaltyaccountapifiltertype.php create mode 100644 intaro.retailcrm/lib/model/api/loyaltycalculation.php create mode 100644 intaro.retailcrm/lib/model/api/loyaltylevel.php create mode 100644 intaro.retailcrm/lib/model/api/order/createorder.php create mode 100644 intaro.retailcrm/lib/model/api/order/order.php create mode 100644 intaro.retailcrm/lib/model/api/order/orderdeliverydata.php create mode 100644 intaro.retailcrm/lib/model/api/order/orderproduct.php create mode 100644 intaro.retailcrm/lib/model/api/order/orderproductpriceitem.php create mode 100644 intaro.retailcrm/lib/model/api/order/package.php create mode 100644 intaro.retailcrm/lib/model/api/order/packageitem.php create mode 100644 intaro.retailcrm/lib/model/api/order/packageitemorderproduct.php create mode 100644 intaro.retailcrm/lib/model/api/order/serializeddeliveryservice.php create mode 100644 intaro.retailcrm/lib/model/api/order/serializedorderdelivery.php create mode 100644 intaro.retailcrm/lib/model/api/orderproduct.php create mode 100644 intaro.retailcrm/lib/model/api/paginationresponse.php create mode 100644 intaro.retailcrm/lib/model/api/payment.php create mode 100644 intaro.retailcrm/lib/model/api/phone.php create mode 100644 intaro.retailcrm/lib/model/api/pricetype.php create mode 100644 intaro.retailcrm/lib/model/api/request/bytrait.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporateaddressescreaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporateaddresseseditrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporateaddressesrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatecompaniescreaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatecompanieseditrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatecompaniesrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatecontactscreaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatecontactseditrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatecontactsrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatecreaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatefixexternalidsrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporatelistrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscorporateuploadrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerscreaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerseditrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customersfixexternalidsrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customersgetrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customershistoryrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customerslistrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customersnotescreaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customersnotesrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/customers/customersuploadrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/entitybytrait.php create mode 100644 intaro.retailcrm/lib/model/api/request/filter/companyfilter.php create mode 100644 intaro.retailcrm/lib/model/api/request/filter/customercontactfilter.php create mode 100644 intaro.retailcrm/lib/model/api/request/filter/customerfilter.php create mode 100644 intaro.retailcrm/lib/model/api/request/filter/customerhistoryfilterv4type.php create mode 100644 intaro.retailcrm/lib/model/api/request/filter/customerscorporateaddressesfilter.php create mode 100644 intaro.retailcrm/lib/model/api/request/filter/customerscorporatefilter.php create mode 100644 intaro.retailcrm/lib/model/api/request/filter/customersnotesfilter.php create mode 100644 intaro.retailcrm/lib/model/api/request/loyalty/account/loyaltyaccountactivaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/loyalty/account/loyaltyaccountcreaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/loyalty/account/loyaltyaccounteditrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/loyalty/account/loyaltyaccountrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/loyalty/loyaltycalculaterequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/order/loyalty/orderloyaltyapplyrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/paginatedtrait.php create mode 100644 intaro.retailcrm/lib/model/api/request/sitescopedtrait.php create mode 100644 intaro.retailcrm/lib/model/api/request/smsverification/smsverificationconfirmrequest.php create mode 100644 intaro.retailcrm/lib/model/api/request/smsverification/smsverificationstatusrequest.php create mode 100644 intaro.retailcrm/lib/model/api/requiredfields.php create mode 100644 intaro.retailcrm/lib/model/api/response/abstractapiresponsemodel.php create mode 100644 intaro.retailcrm/lib/model/api/response/companiesresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/createresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customerchangeresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customercorporateresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customerresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customerscorporateaddressesresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customerscorporatecontactsresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customerscorporateresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customersnotesresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customersresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/customersuploadresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/historyresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/loyalty/account/loyaltyaccountactivateresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/loyalty/account/loyaltyaccountcreateresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/loyalty/account/loyaltyaccounteditresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/loyalty/account/loyaltyaccountresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/loyalty/loyaltycalculateresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/loyalty/loyaltyloyaltiesresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/loyalty/loyaltyloyaltyresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/operationresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/order/loyalty/orderloyaltyapplyresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/orderscreateresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/orderseditresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/ordersgetresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/paginationresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/settings/credentialsresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/smsverification/smsverificationconfirmresponse.php create mode 100644 intaro.retailcrm/lib/model/api/response/smsverification/smsverificationstatusresponse.php create mode 100644 intaro.retailcrm/lib/model/api/serializedcreateloyaltyaccount.php create mode 100644 intaro.retailcrm/lib/model/api/serializedloyalty.php create mode 100644 intaro.retailcrm/lib/model/api/serializedloyaltyorder.php create mode 100644 intaro.retailcrm/lib/model/api/serializedorder.php create mode 100644 intaro.retailcrm/lib/model/api/serializedorderdelivery.php create mode 100644 intaro.retailcrm/lib/model/api/serializedorderproduct.php create mode 100644 intaro.retailcrm/lib/model/api/serializedorderproductoffer.php create mode 100644 intaro.retailcrm/lib/model/api/serializedorderreference.php create mode 100644 intaro.retailcrm/lib/model/api/serializedrelationcustomer.php create mode 100644 intaro.retailcrm/lib/model/api/smsverification.php create mode 100644 intaro.retailcrm/lib/model/api/smsverificationconfirm.php create mode 100644 intaro.retailcrm/lib/model/api/timeinterval.php create mode 100644 intaro.retailcrm/lib/model/api/user.php create mode 100644 intaro.retailcrm/lib/model/bitrix/abstractmodelproxy.php create mode 100644 intaro.retailcrm/lib/model/bitrix/abstractserializablemodel.php create mode 100644 intaro.retailcrm/lib/model/bitrix/agreement.php create mode 100644 intaro.retailcrm/lib/model/bitrix/buyerprofile.php create mode 100644 intaro.retailcrm/lib/model/bitrix/fuser.php create mode 100644 intaro.retailcrm/lib/model/bitrix/orderloyaltydata.php create mode 100644 intaro.retailcrm/lib/model/bitrix/orderprops.php create mode 100644 intaro.retailcrm/lib/model/bitrix/orm/tomodule.php create mode 100644 intaro.retailcrm/lib/model/bitrix/orm/utsuser.php create mode 100644 intaro.retailcrm/lib/model/bitrix/paysystemaction.php create mode 100644 intaro.retailcrm/lib/model/bitrix/smscookie.php create mode 100644 intaro.retailcrm/lib/model/bitrix/tomodule.php create mode 100644 intaro.retailcrm/lib/model/bitrix/user.php create mode 100644 intaro.retailcrm/lib/model/bitrix/userloyaltydata.php create mode 100644 intaro.retailcrm/lib/repository/abstractrepository.php create mode 100644 intaro.retailcrm/lib/repository/agreementrepository.php create mode 100644 intaro.retailcrm/lib/repository/buyerprofilerepository.php create mode 100644 intaro.retailcrm/lib/repository/currencyrepository.php create mode 100644 intaro.retailcrm/lib/repository/fuserrepository.php create mode 100644 intaro.retailcrm/lib/repository/orderloyaltydatarepository.php create mode 100644 intaro.retailcrm/lib/repository/orderpropsrepository.php create mode 100644 intaro.retailcrm/lib/repository/paysystemactionrepository.php create mode 100644 intaro.retailcrm/lib/repository/persontyperepository.php create mode 100644 intaro.retailcrm/lib/repository/templaterepository.php create mode 100644 intaro.retailcrm/lib/repository/tomodulerepository.php create mode 100644 intaro.retailcrm/lib/repository/userloyaltydatarepository.php create mode 100644 intaro.retailcrm/lib/repository/userrepository.php create mode 100644 intaro.retailcrm/lib/service/cookieservice.php create mode 100644 intaro.retailcrm/lib/service/customerservice.php create mode 100644 intaro.retailcrm/lib/service/exception/lpaccountsavailableexception.php create mode 100644 intaro.retailcrm/lib/service/loyaltyaccountservice.php create mode 100644 intaro.retailcrm/lib/service/loyaltyservice.php create mode 100644 intaro.retailcrm/lib/service/orderloyaltydataservice.php create mode 100644 intaro.retailcrm/lib/service/utils.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotation.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotation/attribute.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotation/attributes.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotation/enum.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotation/ignoreannotation.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotation/required.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotation/target.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotationexception.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotationreader.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/annotationregistry.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/doclexer.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/docparser.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/phpparser.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/reader.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/annotations/tokenparser.php create mode 100644 intaro.retailcrm/lib/vendor/doctrine/common/lexer/abstractlexer.php create mode 100644 phpdoc.dist.xml mode change 100644 => 100755 tests/BitrixTestCase.php mode change 100644 => 100755 tests/classes/general/AddressBuilderTest.php mode change 100644 => 100755 tests/classes/general/CustomerBuilderTest.php mode change 100644 => 100755 tests/classes/general/order/RetailCrmOrder_v5Test.php mode change 100644 => 100755 tests/classes/general/services/RetailCrmServiceTest.php create mode 100755 tests/helpers/Helpers.php create mode 100755 tests/lib/component/builder/api/CorporateCustomerBuilderTest.php create mode 100755 tests/lib/component/builder/api/CustomerBuilderTest.php create mode 100755 tests/lib/component/builder/bitrix/CustomerBuilderTest.php create mode 100755 tests/lib/component/converter/DateTimeConverterTest.php create mode 100755 tests/lib/component/factory/ClientFactoryTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index a9652650..3c03408e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2021-11-12 v.6.0.0 +* Добавлена поддержка программы лояльности + ## 2021-10-15 v.5.8.4 * Исправление некорректной генерации каталога при повторных запусках генерации diff --git a/bin/build b/bin/build index 949fefae..4631ec6f 100644 --- a/bin/build +++ b/bin/build @@ -29,7 +29,8 @@ echo "Update version and date in the file \"version.php\"" for i in `find ./"$version" -type f -name '*.*'`; do encoding=`file -b --mime-encoding "$i"` - if [ "$encoding" != "iso-8859-1" ] && [ "$encoding" != "binary" ]; then + if [ "$encoding" != "iso-8859-1" ] && [ "$encoding" != "us-ascii" ] && [ "$encoding" != "binary" ]; then + echo "$i: converting from $encoding to cp1251" result=$(iconv -f $encoding -t "cp1251" $i -o $i.cp1251 2>&1 > /dev/null) if [ ! -z "$result" ]; then echo "Errors in file $i" diff --git a/bin/build-release b/bin/build-release index 46f17bc7..7c8af5cb 100644 --- a/bin/build-release +++ b/bin/build-release @@ -24,9 +24,7 @@ if (!$handle) { $modifiedFiles = []; while (($buffer = fgets($handle)) !== false) { - $file = explode("\t", trim($buffer)); - $modifiedFile = new ModifiedFile($file[1], $file[0]{0}); - $modifiedFiles[] = $modifiedFile; + $modifiedFiles[] = new ModifiedFile($buffer); } try { diff --git a/composer.json b/composer.json index 52b2760c..991265a3 100755 --- a/composer.json +++ b/composer.json @@ -5,6 +5,7 @@ "tests": "php vendor/bin/phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm" }, "description": "Integration module for Bitrix & RetailCRM", + "license": "MIT", "type": "bitrix-module", "authors": [ { @@ -15,6 +16,7 @@ "require": { "ext-json": "*", "ext-mbstring": "*", + "ext-tokenizer": "*", "ext-xmlwriter": "*" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 66b54f40..3120278b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,41 +4,36 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "72c54dce7daa3cd6c40577578128091a", + "content-hash": "a51135dfd806a9758965d7dd91cb8b2a", "packages": [], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^8.0", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" @@ -52,7 +47,7 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "homepage": "https://ocramius.github.io/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", @@ -61,20 +56,38 @@ "constructor", "instantiate" ], - "time": "2019-10-21T16:45:58+00:00" + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-11-10T18:47:58+00:00" }, { "name": "fzaninotto/faker", - "version": "v1.9.1", + "version": "v1.9.2", "source": { "type": "git", "url": "https://github.com/fzaninotto/Faker.git", - "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f" + "reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f", - "reference": "fc10d778e4b84d5bd315dad194661e091d307c6f", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/848d8125239d7dbf8ab25cb7f054f1a630e68c2e", + "reference": "848d8125239d7dbf8ab25cb7f054f1a630e68c2e", "shasum": "" }, "require": { @@ -111,7 +124,12 @@ "faker", "fixtures" ], - "time": "2019-12-12T13:22:17+00:00" + "support": { + "issues": "https://github.com/fzaninotto/Faker/issues", + "source": "https://github.com/fzaninotto/Faker/tree/v1.9.2" + }, + "abandoned": true, + "time": "2020-12-11T09:56:16+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -158,6 +176,10 @@ "keywords": [ "test" ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, "time": "2020-07-09T08:09:16+00:00" }, { @@ -223,24 +245,28 @@ "test double", "testing" ], + "support": { + "issues": "https://github.com/mockery/mockery/issues", + "source": "https://github.com/mockery/mockery/tree/1.3.3" + }, "time": "2020-08-11T18:10:21+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.5", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -271,7 +297,17 @@ "object", "object graph" ], - "time": "2020-01-17T21:11:47+00:00" + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" }, { "name": "phar-io/manifest", @@ -326,6 +362,10 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/master" + }, "time": "2018-07-08T19:23:20+00:00" }, { @@ -373,28 +413,29 @@ } ], "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/master" + }, "time": "2018-07-08T19:19:57+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", "shasum": "" }, "require": { "php": ">=7.1" }, - "require-dev": { - "phpunit/phpunit": "~6" - }, "type": "library", "extra": { "branch-alias": { @@ -425,7 +466,11 @@ "reflection", "static analysis" ], - "time": "2018-08-07T13:53:10+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master" + }, + "time": "2020-04-27T09:25:28+00:00" }, { "name": "phpdocumentor/reflection-docblock", @@ -477,6 +522,10 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/release/4.x" + }, "time": "2019-12-28T18:55:12+00:00" }, { @@ -524,28 +573,32 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/0.7.2" + }, "time": "2019-08-22T18:11:29+00:00" }, { "name": "phpoption/phpoption", - "version": "1.7.2", + "version": "1.7.5", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "77f7c4d2e65413aff5b5a8cc8b3caf7a28d81959" + "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/77f7c4d2e65413aff5b5a8cc8b3caf7a28d81959", - "reference": "77f7c4d2e65413aff5b5a8cc8b3caf7a28d81959", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/994ecccd8f3283ecf5ac33254543eb0ac946d525", + "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525", "shasum": "" }, "require": { - "php": "^5.5.9 || ^7.0" + "php": "^5.5.9 || ^7.0 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.3", - "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0 || ^8.0 || ^9.0" }, "type": "library", "extra": { @@ -579,7 +632,21 @@ "php", "type" ], - "time": "2019-12-15T19:35:24+00:00" + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.7.5" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "time": "2020-07-20T17:29:33+00:00" }, { "name": "phpspec/prophecy", @@ -642,6 +709,10 @@ "spy", "stub" ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" + }, "time": "2020-03-05T15:02:03+00:00" }, { @@ -705,27 +776,31 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/master" + }, "time": "2018-10-31T16:06:48+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "050bedf145a257b1ff02746c31894800e5122946" + "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", - "reference": "050bedf145a257b1ff02746c31894800e5122946", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/4b49fb70f067272b659ef0174ff9ca40fdaa6357", + "reference": "4b49fb70f067272b659ef0174ff9ca40fdaa6357", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { @@ -755,7 +830,17 @@ "filesystem", "iterator" ], - "time": "2018-09-13T20:33:42+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:25:21+00:00" }, { "name": "phpunit/php-text-template", @@ -796,27 +881,31 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" + }, "time": "2015-06-21T13:50:34+00:00" }, { "name": "phpunit/php-timer", - "version": "2.1.2", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" + "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/2454ae1765516d20c4ffe103d85a58a9a3bd5662", + "reference": "2454ae1765516d20c4ffe103d85a58a9a3bd5662", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { @@ -845,25 +934,35 @@ "keywords": [ "timer" ], - "time": "2019-06-07T04:22:29+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/2.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:20:02+00:00" }, { "name": "phpunit/php-token-stream", - "version": "3.1.1", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" + "reference": "472b687829041c24b25f475e14c2f38a09edf1c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/472b687829041c24b25f475e14c2f38a09edf1c2", + "reference": "472b687829041c24b25f475e14c2f38a09edf1c2", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.1" + "php": ">=7.1" }, "require-dev": { "phpunit/phpunit": "^7.0" @@ -894,7 +993,18 @@ "keywords": [ "tokenizer" ], - "time": "2019-09-17T06:23:10+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/3.1.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "abandoned": true, + "time": "2020-11-30T08:38:46+00:00" }, { "name": "phpunit/phpunit", @@ -978,27 +1088,31 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/7.5.20" + }, "time": "2020-01-08T08:45:45+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", + "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { @@ -1023,29 +1137,39 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:15:22+00:00" }, { "name": "sebastian/comparator", - "version": "3.0.2", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" + "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", + "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", "shasum": "" }, "require": { - "php": "^7.1", + "php": ">=7.1", "sebastian/diff": "^3.0", "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^8.5" }, "type": "library", "extra": { @@ -1063,6 +1187,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1074,10 +1202,6 @@ { "name": "Bernhard Schussek", "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" } ], "description": "Provides the functionality to compare PHP values for equality", @@ -1087,24 +1211,34 @@ "compare", "equality" ], - "time": "2018-07-12T15:12:46+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T08:04:30+00:00" }, { "name": "sebastian/diff", - "version": "3.0.2", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" + "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/14f72dd46eaf2f2293cbe79c93cc0bc43161a211", + "reference": "14f72dd46eaf2f2293cbe79c93cc0bc43161a211", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.1" }, "require-dev": { "phpunit/phpunit": "^7.5 || ^8.0", @@ -1126,13 +1260,13 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" } ], "description": "Diff implementation", @@ -1143,24 +1277,34 @@ "unidiff", "unified diff" ], - "time": "2019-02-04T06:01:07+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:59:04+00:00" }, { "name": "sebastian/environment", - "version": "4.2.3", + "version": "4.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" + "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", + "reference": "d47bbbad83711771f167c72d4e3f25f7fcc1f8b0", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.1" }, "require-dev": { "phpunit/phpunit": "^7.5" @@ -1196,24 +1340,34 @@ "environment", "hhvm" ], - "time": "2019-11-20T08:46:58+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/4.2.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:53:42+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.2", + "version": "3.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" + "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/6b853149eab67d4da22291d36f5b0631c0fd856e", + "reference": "6b853149eab67d4da22291d36f5b0631c0fd856e", "shasum": "" }, "require": { - "php": "^7.0", + "php": ">=7.0", "sebastian/recursion-context": "^3.0" }, "require-dev": { @@ -1263,7 +1417,17 @@ "export", "exporter" ], - "time": "2019-09-14T09:02:43+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:47:53+00:00" }, { "name": "sebastian/global-state", @@ -1314,24 +1478,28 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/2.0.0" + }, "time": "2017-04-27T15:39:26+00:00" }, { "name": "sebastian/object-enumerator", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", + "reference": "e67f6d32ebd0c749cf9d1dbd9f226c727043cdf2", "shasum": "" }, "require": { - "php": "^7.0", + "php": ">=7.0", "sebastian/object-reflector": "^1.1.1", "sebastian/recursion-context": "^3.0" }, @@ -1361,24 +1529,34 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:40:27+00:00" }, { "name": "sebastian/object-reflector", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", + "reference": "9b8772b9cbd456ab45d4a598d2dd1a1bced6363d", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" @@ -1406,24 +1584,34 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:37:18+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/367dcba38d6e1977be014dc4b22f47a484dac7fb", + "reference": "367dcba38d6e1977be014dc4b22f47a484dac7fb", "shasum": "" }, "require": { - "php": "^7.0" + "php": ">=7.0" }, "require-dev": { "phpunit/phpunit": "^6.0" @@ -1444,14 +1632,14 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, { "name": "Adam Harvey", "email": "aharvey@php.net" @@ -1459,24 +1647,34 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:34:24+00:00" }, { "name": "sebastian/resource-operations", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" + "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/31d35ca87926450c44eae7e2611d45a7a65ea8b3", + "reference": "31d35ca87926450c44eae7e2611d45a7a65ea8b3", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=7.1" }, "type": "library", "extra": { @@ -1501,7 +1699,17 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2018-10-04T04:07:39+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-30T07:30:19+00:00" }, { "name": "sebastian/version", @@ -1544,24 +1752,28 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/master" + }, "time": "2016-10-03T07:35:21+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.14.0", + "version": "v1.22.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38" + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", - "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-ctype": "For best performance" @@ -1569,7 +1781,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.14-dev" + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1602,7 +1818,24 @@ "polyfill", "portable" ], - "time": "2020-01-13T11:15:53+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-01-07T16:49:33+00:00" }, { "name": "theseer/tokenizer", @@ -1642,33 +1875,39 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/master" + }, "time": "2019-06-13T22:48:21+00:00" }, { "name": "vlucas/phpdotenv", - "version": "v3.6.1", + "version": "v3.6.7", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "8f7961f7b9deb3b432452c18093cf16f88205902" + "reference": "2065beda6cbe75e2603686907b2e45f6f3a5ad82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8f7961f7b9deb3b432452c18093cf16f88205902", - "reference": "8f7961f7b9deb3b432452c18093cf16f88205902", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2065beda6cbe75e2603686907b2e45f6f3a5ad82", + "reference": "2065beda6cbe75e2603686907b2e45f6f3a5ad82", "shasum": "" }, "require": { - "php": "^5.4 || ^7.0", - "phpoption/phpoption": "^1.5", - "symfony/polyfill-ctype": "^1.9" + "php": "^5.4 || ^7.0 || ^8.0", + "phpoption/phpoption": "^1.5.2", + "symfony/polyfill-ctype": "^1.17" }, "require-dev": { "ext-filter": "*", - "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" + "ext-pcre": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0" }, "suggest": { - "ext-filter": "Required to use the boolean validator." + "ext-filter": "Required to use the boolean validator.", + "ext-pcre": "Required to use most of the library." }, "type": "library", "extra": { @@ -1703,28 +1942,43 @@ "env", "environment" ], - "time": "2020-03-12T13:44:00+00:00" + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v3.6.7" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "time": "2020-07-14T19:04:52+00:00" }, { "name": "webmozart/assert", - "version": "1.7.0", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "aed98a490f9a8f78468232db345ab9cf606cf598" + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598", - "reference": "aed98a490f9a8f78468232db345ab9cf606cf598", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "vimeo/psalm": "<3.6.0" + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<3.9.1" }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^7.5.13" @@ -1751,7 +2005,11 @@ "check", "validate" ], - "time": "2020-02-14T12:15:55+00:00" + "support": { + "issues": "https://github.com/webmozart/assert/issues", + "source": "https://github.com/webmozart/assert/tree/master" + }, + "time": "2020-07-08T17:02:28+00:00" } ], "aliases": [], @@ -1762,6 +2020,7 @@ "platform": { "ext-json": "*", "ext-mbstring": "*", + "ext-tokenizer": "*", "ext-xmlwriter": "*" }, "platform-dev": [], diff --git a/helpers/release/ModifiedFile.php b/helpers/release/ModifiedFile.php index 6885950e..1c91fb94 100644 --- a/helpers/release/ModifiedFile.php +++ b/helpers/release/ModifiedFile.php @@ -29,18 +29,34 @@ class ModifiedFile /** @var string */ protected $filename; + /** @var string */ + protected $oldFilename; + /** @var string */ protected $modificator; + /** @var int */ + protected $percent; + /** * ModifiedFile constructor. - * @param string $filename - * @param string $modificator + * @param string $source */ - public function __construct($filename, $modificator = self::Modified) + public function __construct($source) { - $this->filename = $filename; - $this->modificator = $modificator; + $params = explode("\t", trim($source)); + + $this->filename = $params[1]; + $this->modificator = $params[0][0]; + + if (strlen($params[0]) > 1) { + $this->percent = (int) substr($params[0], 1); + } + + if (count($params) >= 3) { + $this->filename = $params[2]; + $this->oldFilename = $params[1]; + } } /** @@ -90,4 +106,20 @@ class ModifiedFile { return $this->filename; } + + /** + * @return string + */ + public function getOldFilename() + { + return $this->oldFilename; + } + + /** + * @return int + */ + public function getPercent() + { + return $this->percent; + } } diff --git a/intaro.retailcrm/RetailcrmClasspathBuilder.php b/intaro.retailcrm/RetailcrmClasspathBuilder.php new file mode 100644 index 00000000..117611db --- /dev/null +++ b/intaro.retailcrm/RetailcrmClasspathBuilder.php @@ -0,0 +1,307 @@ +/bitrix/php_interface/retailcrm + * + * Array format: + * [ + * 'class path with namespace' => 'file name' + * ] + */ + protected static $customizableClasses = [ + 'RestNormalizer' => 'RestNormalizer.php', + 'Logger' => 'Logger.php', + 'RetailCrm\ApiClient' => 'ApiClient_v5.php', + 'RetailCrm\Http\Client' => 'Client.php', + 'RCrmActions' => 'RCrmActions.php', + 'RetailCrmUser' => 'RetailCrmUser.php', + 'RetailCrmICML' => 'RetailCrmICML.php', + 'RetailCrmInventories' => 'RetailCrmInventories.php', + 'RetailCrmPrices' => 'RetailCrmPrices.php', + 'RetailCrmCollector' => 'RetailCrmCollector.php', + 'RetailCrmUa' => 'RetailCrmUa.php', + 'RetailCrmEvent' => 'RetailCrmEvent.php', + 'RetailCrmCorporateClient' => 'RetailCrmCorporateClient.php' + ]; + + /** + * These classes can be customized, in which case they would be replaced with files from + * directory /bitrix/php_interface/retailcrm + * Customized versions have fixed name, and original versions name depends on API version + * + * Array format: + * [ + * 'class path with namespace' => ['customized file name', 'original file name with %s for API version'] + * ] + */ + protected static $versionedClasses = [ + 'RetailCrm\ApiClient' => ['ApiClient.php', 'ApiClient_%s.php'], + 'RetailCrmOrder' => ['RetailCrmOrder.php', 'RetailCrmOrder_%s.php'], + 'RetailCrmHistory' => ['RetailCrmHistory.php', 'RetailCrmHistory_%s.php'] + ]; + + /** + * These classes will be ignored while loading from original files + */ + protected static $ignoredClasses = [ + 'ApiClient_v4.php', + 'ApiClient_v5.php', + 'RetailCrmOrder_v4.php', + 'RetailCrmOrder_v5.php', + 'RetailCrmHistory_v4.php', + 'RetailCrmHistory_v5.php', + ]; + + /** + * These namespaces are hardcoded. + */ + protected static $hardcodedNamespaces = [ + 'RetailCrm\Response\ApiResponse' => 'ApiResponse.php', + 'RetailCrm\Exception\InvalidJsonException' => 'InvalidJsonException.php', + 'RetailCrm\Exception\CurlException' => 'CurlException.php' + ]; + + protected function buildCustomizableClasspath() + { + foreach (static::$customizableClasses as $className => $fileName) { + $customizedFile = $this->documentRoot . '/bitrix/php_interface/retailcrm/' . $fileName; + + if (file_exists($customizedFile)) { + $this->result[$className] = $customizedFile; + } else { + $this->notIncluded[$className] = $fileName; + } + } + } + + protected function buildVersionedClasspath() + { + foreach (static::$versionedClasses as $className => $fileNames) { + $customizedFile = $this->documentRoot . '/bitrix/php_interface/retailcrm/' . $fileNames[0]; + + if (file_exists($customizedFile)) { + $this->result[$className] = $customizedFile; + } else { + $this->notIncluded[$className] = sprintf($fileNames[1], $this->version); + } + } + } + + /** + * Traverse through directories, build include paths + * @return $this + */ + public function build(): self + { + $directory = new RecursiveDirectoryIterator( + $this->getSearchPath(), + RecursiveDirectoryIterator::SKIP_DOTS + ); + $fileIterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::LEAVES_ONLY); + + $this->buildCustomizableClasspath(); + $this->buildVersionedClasspath(); + $notIncludedClasses = array_flip($this->notIncluded); + $hardcodedNamespaces = array_flip(static::$hardcodedNamespaces); + + /** @var \SplFileObject $file */ + foreach ($fileIterator as $file) { + $fileNameWithoutExt = str_ireplace('.' . $this->fileExt, '', $file->getFilename()); + + if ($file->getExtension() !== $this->fileExt) { + continue; + } + + if (in_array($file->getFilename(), static::$customizableClasses) + || in_array($file->getFilename(), static::$ignoredClasses) + ) { + if (in_array($file->getFilename(), $this->notIncluded)) { + $this->result[$notIncludedClasses[$file->getFilename()]] = $this->getImportPath($file->getPathname()); + } + + continue; + } + + if (in_array($file->getFilename(), static::$hardcodedNamespaces)) { + $this->result[$hardcodedNamespaces[$file->getFilename()]] = $this->getImportPath($file->getPathname()); + } else { + $this->result[$this->getImportClass($fileNameWithoutExt, $file->getPath())] = $this->getImportPath($file->getPathname()); + } + } + + return $this; + } + + /** + * Sets the $fileExt property + * + * @param string $fileExt The file extension used for class files. Default is "php". + * + * @return \RetailcrmClasspathBuilder + */ + public function setFileExt($fileExt) + { + $this->fileExt = $fileExt; + return $this; + } + + /** + * @param string $documentRoot + * + * @return RetailcrmClasspathBuilder + */ + public function setDocumentRoot(string $documentRoot): RetailcrmClasspathBuilder + { + $this->documentRoot = $documentRoot; + return $this; + } + + /** + * Sets the $path property + * + * @param string $path Top path to load files + * + * @return \RetailcrmClasspathBuilder + */ + public function setPath(string $path) + { + $this->path = $path; + return $this; + } + + /** + * @param mixed $disableNamespaces + * + * @return RetailcrmClasspathBuilder + */ + public function setDisableNamespaces($disableNamespaces) + { + $this->disableNamespaces = $disableNamespaces; + return $this; + } + + /** + * @param string $moduleId + * + * @return RetailcrmClasspathBuilder + */ + public function setModuleId(string $moduleId): RetailcrmClasspathBuilder + { + $this->moduleId = $moduleId; + return $this; + } + + /** + * @param string $version + * + * @return RetailcrmClasspathBuilder + */ + public function setVersion(string $version): RetailcrmClasspathBuilder + { + $this->version = $version; + return $this; + } + + /** + * @return array + */ + public function getResult(): array + { + return $this->result; + } + + /** + * @return string + */ + protected function getSearchPath(): string + { + return __DIR__ . DIRECTORY_SEPARATOR . $this->path; + } + + /** + * @param string $filePath + * + * @return string + */ + protected function getImportPath(string $filePath): string + { + return (string) str_ireplace(implode(DIRECTORY_SEPARATOR, [ + $this->documentRoot, + 'bitrix', + 'modules', + $this->moduleId + ]) . DIRECTORY_SEPARATOR, '', $filePath); + } + + /** + * @param string $fileNameWithoutExt + * @param string $filePath + * + * @return string + */ + protected function getImportClass(string $fileNameWithoutExt, string $filePath): string + { + if ($this->disableNamespaces) { + return $fileNameWithoutExt; + } + + $importClass = str_ireplace($this->getSearchPath(), '', $filePath). '\\' . $fileNameWithoutExt; + + if (strlen($importClass) > 0 && $importClass[0] === '/') { + $importClass = '\\' . substr($importClass, 1); + } + + return (string) str_replace(DIRECTORY_SEPARATOR, '\\', $importClass); + } +} diff --git a/intaro.retailcrm/classes/general/ApiClient_v4.php b/intaro.retailcrm/classes/general/ApiClient_v4.php index 8fb2d8dc..27492edb 100644 --- a/intaro.retailcrm/classes/general/ApiClient_v4.php +++ b/intaro.retailcrm/classes/general/ApiClient_v4.php @@ -1814,7 +1814,18 @@ class ApiClient { $this->siteCode = $site; } - + + /** + * @return \RetailCrm\Response\ApiResponse + */ + public function getCredentials(): ApiResponse + { + return $this->client->makeRequest( + '/credentials', + Client::METHOD_GET + ); + } + /** * Check ID parameter * diff --git a/intaro.retailcrm/classes/general/ApiClient_v5.php b/intaro.retailcrm/classes/general/ApiClient_v5.php index ae58d925..0cf6afd6 100644 --- a/intaro.retailcrm/classes/general/ApiClient_v5.php +++ b/intaro.retailcrm/classes/general/ApiClient_v5.php @@ -29,6 +29,7 @@ class ApiClient const VERSION = 'v5'; protected $client; + protected $unversionedClient; /** * Site code @@ -50,10 +51,13 @@ class ApiClient $url .= '/'; } - $url = $url . 'api/' . self::VERSION; + $versionedUrl = $url . 'api/' . self::VERSION; + $unversionedUrl = $url . 'api'; - $this->client = new Client($url, array('apiKey' => $apiKey)); + $this->client = new Client($versionedUrl, array('apiKey' => $apiKey)); $this->siteCode = $site; + + $this->unversionedClient = new Client($unversionedUrl, ['apiKey' => $apiKey]); } /** @@ -240,11 +244,11 @@ class ApiClient return $this->client->makeRequest( '/customers-corporate/fix-external-ids', Client::METHOD_POST, - array('customerCorporate' => json_encode($ids)) + array('customersCorporate' => json_encode($ids)) ); } - /* + /** * Upload array of the customers corporate * * @param array $customers array of customers @@ -608,20 +612,15 @@ class ApiClient /** * Create corporate customer address * - * @param string $id corporate customer identifier - * @param array $address (default: array()) - * @param string $by (default: 'externalId') - * @param string $site (default: null) - * - * @throws \InvalidArgumentException - * @throws \RetailCrm\Exception\CurlException - * @throws \RetailCrm\Exception\InvalidJsonException + * @param string $id corporate customer identifier + * @param array $address (default: array()) + * @param string $by (default: 'externalId') + * @param null $site (default: null) * * @return \RetailCrm\Response\ApiResponse */ - public function customersCorporateAddressesCreate($id, array $address = [], $by = 'externalId', $site = null) + public function customersCorporateAddressesCreate($id, array $address = [], $by = 'externalId', $site = null): ApiResponse { - /* @noinspection PhpUndefinedMethodInspection */ return $this->client->makeRequest( "/customers-corporate/$id/addresses/create", Client::METHOD_POST, @@ -830,7 +829,7 @@ class ApiClient * * @return ApiResponse */ - public function ordersCreate(array $order, $site = null) + public function ordersCreate(array $order, $site = null): ApiResponse { if (!count($order)) { throw new InvalidArgumentException( @@ -841,7 +840,7 @@ class ApiClient return $this->client->makeRequest( '/orders/create', Client::METHOD_POST, - $this->fillSite($site, array('order' => json_encode($order))) + $this->fillSite($site, ['order' => json_encode($order)]) ); } @@ -966,7 +965,7 @@ class ApiClient * * @return ApiResponse */ - public function ordersEdit(array $order, $by = 'externalId', $site = null) + public function ordersEdit(array $order, $by = 'externalId', $site = null): ApiResponse { if (!count($order)) { throw new InvalidArgumentException( @@ -987,7 +986,7 @@ class ApiClient Client::METHOD_POST, $this->fillSite( $site, - array('order' => json_encode($order), 'by' => $by) + ['order' => json_encode($order), 'by' => $by] ) ); } @@ -2932,4 +2931,186 @@ class ApiClient return $params; } + + /** + * @param array $request + * @param int $checkId + * @return \RetailCrm\Response\ApiResponse + */ + public function checkStatusPlVerification(array $request, int $checkId): ApiResponse + { + return $this->client->makeRequest( + "/verification/sms/$checkId/status", + Client::METHOD_GET, + $request + ); + } + + /** + * @param array $request + * @return \RetailCrm\Response\ApiResponse + */ + public function loyaltyOrderApply(array $request): ApiResponse + { + return $this->client->makeRequest( + "/orders/loyalty/apply", + Client::METHOD_POST, + [ + 'site' => $request['site'], + 'order' => json_encode($request['order']), + 'bonuses' => $request['bonuses'], + ] + ); + } + + /** + * @param array $request + * @return \RetailCrm\Response\ApiResponse + */ + public function loyaltyOrderCalculate(array $request): ApiResponse + { + return $this->client->makeRequest( + "/loyalty/calculate", + Client::METHOD_POST, + [ + 'site' => json_encode($request['site']), + 'order' => json_encode($request['order']), + 'bonuses' => $request['bonuses'] + ] + ); + } + + /** + * @return \RetailCrm\Response\ApiResponse + */ + public function getCredentials(): ApiResponse + { + return $this->unversionedClient->makeRequest( + "/credentials", + Client::METHOD_GET + ); + } + + /** + * @param array $request + * @return \RetailCrm\Response\ApiResponse + */ + public function createLoyaltyAccount(array $request): ApiResponse + { + return $this->client->makeRequest( + "/loyalty/account/create", + Client::METHOD_POST, + [ + 'loyaltyAccount' => json_encode($request['loyaltyAccount']), + 'site' => $request['site'], + ] + ); + } + + /** + * @param int $loyaltyId + * @return \RetailCrm\Response\ApiResponse + */ + public function activateLoyaltyAccount(int $loyaltyId): ApiResponse + { + return $this->client->makeRequest( + "/loyalty/account/".$loyaltyId."/activate", + Client::METHOD_POST + ); + } + + /** + * @param array $request + * @return \RetailCrm\Response\ApiResponse + */ + public function sendVerificationCode(array $request): ApiResponse + { + return $this->client->makeRequest( + "/verification/sms/confirm", + Client::METHOD_POST, + [ + 'verification'=> json_encode($request['verification']) + ] + ); + } + + /** + * @param array $request + * @return \RetailCrm\Response\ApiResponse + */ + public function getLoyaltyAccounts(array $request): ApiResponse + { + return $this->client->makeRequest( + "/loyalty/accounts", + Client::METHOD_GET, + $request + ); + } + + /** + * @param int $loyaltyId + * @return \RetailCrm\Response\ApiResponse + */ + public function getLoyaltyLoyalty(int $loyaltyId): ApiResponse + { + return $this->client->makeRequest( + '/loyalty/loyalties/' . $loyaltyId, + Client::METHOD_GET + ); + } + + /** + * @return \RetailCrm\Response\ApiResponse + */ + public function getLoyaltyLoyalties(): ApiResponse + { + return $this->client->makeRequest( + '/loyalty/loyalties', + Client::METHOD_GET + ); + } + + /** + * @param array $request + * @param int $accountId + * + * @return \RetailCrm\Response\ApiResponse + */ + public function editLoyaltyAccount(array $request, int $accountId): ApiResponse + { + return $this->client->makeRequest( + '/loyalty/account/' . $accountId . '/edit', + Client::METHOD_POST, + [ + 'loyaltyAccount'=> json_encode($request['loyaltyAccount']), + 'id' => $request['id'] + ] + ); + } + + /** + * @param array $request + * @return \RetailCrm\Response\ApiResponse + */ + protected function confirmLpVerificationBySMS(array $request): ApiResponse + { + return $this->client->makeRequest( + '/verification/sms/confirm', + Client::METHOD_POST, + $request + ); + } + + /** + * @param array $request + * @return \RetailCrm\Response\ApiResponse + */ + public function sendSmsForLpVerification(array $request): ApiResponse + { + return $this->client->makeRequest( + '/verification/sms/send', + Client::METHOD_POST, + $request + ); + } } diff --git a/intaro.retailcrm/classes/general/Logger.php b/intaro.retailcrm/classes/general/Logger.php index 6db51421..f8febc7b 100644 --- a/intaro.retailcrm/classes/general/Logger.php +++ b/intaro.retailcrm/classes/general/Logger.php @@ -25,8 +25,8 @@ class Logger public static function getInstance($logPath = '/bitrix/modules/intaro.retailcrm/log', $files = 3) { if (empty(self::$instance) - || self::$instance instanceof Logger - && (self::$instance->logPath != $logPath || self::$instance->files != $files) + || (self::$instance instanceof self + && (self::$instance->logPath !== $logPath || self::$instance->files !== $files)) ) { self::$instance = new Logger($logPath, $files); } @@ -40,12 +40,12 @@ class Logger * @param string $logPath * @param int $files */ - private function __construct($logPath = '/bitrix/modules/intaro.retailcrm/log', $files = 3) + public function __construct($logPath = '/bitrix/modules/intaro.retailcrm/log', $files = 3) { $this->logPath = $logPath; $this->files = $files; } - + public function write($dump, $file = 'info') { $rsSites = CSite::GetList($by, $sort, array('DEF' => 'Y')); @@ -53,19 +53,19 @@ class Logger if (!is_dir($ar['ABS_DOC_ROOT'] . $this->logPath . '/')) { mkdir($ar['ABS_DOC_ROOT'] . $this->logPath . '/'); } - $file = $ar['ABS_DOC_ROOT'] . $this->logPath . '/' . $file . '.log'; + $file = $ar['ABS_DOC_ROOT'] . $this->logPath . '/' . $file . '.log'; $data['TIME'] = date('Y-m-d H:i:s'); $data['DATA'] = $dump; $f = fopen($file, "a+"); fwrite($f, print_r($data, true)); - fclose($f); + fclose($f); // if filesize more than 5 Mb rotate it if (filesize($file) > 5242880) { $this->rotate($file); - } + } } private function rotate($file) @@ -105,5 +105,4 @@ class Logger { file_put_contents($file, ''); } - } diff --git a/intaro.retailcrm/classes/general/RCrmActions.php b/intaro.retailcrm/classes/general/RCrmActions.php index 2c5f3230..183f4753 100644 --- a/intaro.retailcrm/classes/general/RCrmActions.php +++ b/intaro.retailcrm/classes/general/RCrmActions.php @@ -1,5 +1,6 @@ 'Y']); - + while ($ar = $rsSites->Fetch()) { $arSites[] = $ar; } @@ -183,13 +188,13 @@ class RCrmActions public static function eventLog($auditType, $itemId, $description) { - CEventLog::Add(array( + CEventLog::Add([ 'SEVERITY' => 'SECURITY', 'AUDIT_TYPE_ID' => $auditType, 'MODULE_ID' => self::$MODULE_ID, 'ITEM_ID' => $itemId, 'DESCRIPTION' => $description, - )); + ]); } /** @@ -202,7 +207,7 @@ class RCrmActions { RetailCrmOrder::uploadOrders(); $failedIds = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, 0)); - + if (is_array($failedIds) && !empty($failedIds)) { RetailCrmOrder::uploadOrders(50, true); } @@ -237,23 +242,14 @@ class RCrmActions * working with nested arrs * * @param array $arr + * * @return array */ - public static function clearArr($arr) + public static function clearArr(array $arr): array { - if (is_array($arr) === false) { - return $arr; - } - - $result = array(); - foreach ($arr as $index => $node ) { - $result[ $index ] = is_array($node) === true ? self::clearArr($node) : trim($node); - if ($result[ $index ] == '' || $result[ $index ] === null || count($result[ $index ]) < 1) { - unset($result[ $index ]); - } - } - - return $result; + /** @var \Intaro\RetailCrm\Service\Utils $utils */ + $utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class); + return $utils->clearArray($arr); } /** @@ -261,13 +257,12 @@ class RCrmActions * @param array|bool|\SplFixedArray|string $str in SITE_CHARSET * * @return array|bool|\SplFixedArray|string $str in utf-8 - * @global $APPLICATION */ public static function toJSON($str) { - global $APPLICATION; - - return $APPLICATION->ConvertCharset($str, SITE_CHARSET, 'utf-8'); + /** @var \Intaro\RetailCrm\Service\Utils $utils */ + $utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class); + return $utils->toUTF8($str); } /** @@ -275,13 +270,12 @@ class RCrmActions * @param string|array|\SplFixedArray $str in utf-8 * * @return array|bool|\SplFixedArray|string $str in SITE_CHARSET - * @global $APPLICATION */ public static function fromJSON($str) { - global $APPLICATION; - - return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET); + /** @var \Intaro\RetailCrm\Service\Utils $utils */ + $utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class); + return $utils->fromUTF8($str); } /** diff --git a/intaro.retailcrm/classes/general/Response/ApiResponse.php b/intaro.retailcrm/classes/general/Response/ApiResponse.php index 28855326..24a262bd 100644 --- a/intaro.retailcrm/classes/general/Response/ApiResponse.php +++ b/intaro.retailcrm/classes/general/Response/ApiResponse.php @@ -172,4 +172,12 @@ class ApiResponse implements \ArrayAccess return $this->response[$offset]; } + + /** + * @return array + */ + public function getResponseBody() + { + return $this->response; + } } diff --git a/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php b/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php index 34823b70..971ffbc3 100644 --- a/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php +++ b/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php @@ -9,8 +9,12 @@ * @package RetailCRM */ +use Intaro\RetailCrm\Component\ConfigProvider; + IncludeModuleLangFile(__FILE__); +require_once __DIR__ . '/../../lib/component/configprovider.php'; + /** * PHP version 5.3 * @@ -19,840 +23,6 @@ IncludeModuleLangFile(__FILE__); * @category RetailCRM * @package RetailCRM */ -class RetailcrmConfigProvider +class RetailcrmConfigProvider extends ConfigProvider { - /** @var bool|null|string */ - private static $apiUrl; - - /** @var bool|null|string */ - private static $apiKey; - - /** @var bool|null|string */ - private static $catalogBasePrice; - - /** @var bool|null|string */ - private static $currency; - - /** @var bool|null|string */ - private static $orderDimensions; - - /** @var bool|null|string */ - private static $corporateClientName; - - /** @var bool|null|string */ - private static $corporateClientAddress; - - /** @var bool|null|string */ - private static $corporateClient; - - /** @var bool|null|string $shipmentDeducted */ - private static $shipmentDeducted; - - /** @var array $sitesList */ - private static $sitesList; - - /** @var array $sitesListCorporate */ - private static $sitesListCorporate; - - /** @var bool|null|string $orderNumbers */ - private static $orderNumbers; - - /** @var array $orderTypes */ - private static $orderTypes; - - /** @var array $deliveryTypes */ - private static $deliveryTypes; - - /** @var array $paymentTypes */ - private static $paymentTypes; - - /** @var array $integrationPayment */ - private static $integrationPayment; - - /** @var array $paymentStatuses */ - private static $paymentStatuses; - - /** @var array $payment */ - private static $payment; - - /** @var array $orderProps */ - private static $orderProps; - - /** @var array $legalDetails */ - private static $legalDetails; - - /** @var array $contragentTypes */ - private static $contragentTypes; - - /** @var array $cancellableOrderPaymentStatuses */ - private static $cancellableOrderPaymentStatuses; - - /** @var array $customFields */ - private static $customFields; - - /** @var array $infoblocksInventories */ - private static $infoblocksInventories; - - /** @var array $stores */ - private static $stores; - - /** @var array $shops */ - private static $shops; - - /** - * @return bool|string|null - */ - public static function getApiUrl() - { - if (self::isEmptyNotZero(static::$apiUrl)) { - static::$apiUrl = static::getOption(RetailcrmConstants::CRM_API_HOST_OPTION); - } - - return static::$apiUrl; - } - - /** - * @return bool|string|null - */ - public static function getApiKey() - { - if (self::isEmptyNotZero(static::$apiKey)) { - static::$apiKey = static::getOption(RetailcrmConstants::CRM_API_KEY_OPTION); - } - - return static::$apiKey; - } - - /** - * getCorporateClientName - * - * @return bool|string|null - */ - public static function getCorporateClientName() - { - if (self::isEmptyNotZero(static::$corporateClientName)) { - static::$corporateClientName = static::getUnserializedOption(RetailcrmConstants::CRM_CORP_NAME); - } - - return static::$corporateClientName; - } - - /** - * getCorporateClientAddress - * - * @return bool|string|null - */ - public static function getCorporateClientAddress() - { - if (self::isEmptyNotZero(static::$corporateClientAddress)) { - static::$corporateClientAddress = static::getUnserializedOption(RetailcrmConstants::CRM_CORP_ADDRESS); - } - - return static::$corporateClientAddress; - } - - /** - * getCorporateClient - * - * @return bool|string|null - */ - public static function getCorporateClientStatus() - { - if (self::isEmptyNotZero(static::$corporateClient)) { - static::$corporateClient = static::getOption(RetailcrmConstants::CRM_CC); - } - - return static::$corporateClient; - } - - /** - * getSitesList - * - * @return array - */ - public static function getSitesList() - { - if (self::isEmptyNotZero(static::$sitesList)) { - static::$sitesList = static::getUnserializedOption(RetailcrmConstants::CRM_SITES_LIST); - } - - return static::$sitesList; - } - - /** - * getSitesListCorporate - * - * @return array - */ - public static function getSitesListCorporate() - { - if (self::isEmptyNotZero(static::$sitesListCorporate)) { - static::$sitesListCorporate = static::getUnserializedOption( - RetailcrmConstants::CRM_SITES_LIST_CORPORATE - ); - } - - return static::$sitesListCorporate; - } - - /** - * isOnlineConsultantEnabled - * - * @return bool - */ - public static function isOnlineConsultantEnabled() - { - return static::getOption(RetailcrmConstants::CRM_ONLINE_CONSULTANT) === 'Y'; - } - - /** - * getOnlineConsultantScript - * - * @return string - */ - public static function getOnlineConsultantScript() - { - return trim(static::getOption(RetailcrmConstants::CRM_ONLINE_CONSULTANT_SCRIPT, "")); - } - - /** - * setOnlineConsultant - * - * @param string $value - */ - public static function setOnlineConsultant($value) - { - static::setOption(RetailcrmConstants::CRM_ONLINE_CONSULTANT, $value); - } - - /** - * @return bool|string|null - */ - public static function getCrmPurchasePrice() - { - return static::getOption(RetailcrmConstants::CRM_PURCHASE_PRICE_NULL); - } - - public static function getProtocol() - { - return static::getOption(RetailcrmConstants::PROTOCOL); - } - - /** - * @return string - */ - public static function getSiteName(): string - { - $siteName = COption::GetOptionString('main', 'site_name'); - - if (!$siteName) { - return ''; - } - - return $siteName; - } - - /** - * @return mixed - */ - public static function getUsersMap() - { - return static::getUnserializedOption(RetailcrmConstants::CRM_USERS_MAP); - } - - /** - * @param array|null $userMap - * - * @return bool - */ - public static function setUsersMap(?array $userMap): bool - { - return static::setOption(RetailcrmConstants::CRM_USERS_MAP, serialize($userMap)); - } - - /** - * @param $profileId - * - * @return false|string|null - */ - public static function getCrmBasePrice($profileId) - { - return self::getOption(RetailcrmConstants::CRM_CATALOG_BASE_PRICE . '_' . $profileId, 1); - } - - public static function setProfileBasePrice($profileId, $priceTypes): void - { - self::setOption( - RetailcrmConstants::CRM_CATALOG_BASE_PRICE . '_' . $profileId, - htmlspecialchars(trim($priceTypes)) - ); - } - - /** - * @return string - */ - public static function getDefaultIcmlPath(): string - { - return (COption::GetOptionString( - 'catalog', - 'export_default_path', - '/bitrix/catalog_export/')) - . 'retailcrm.xml'; - } - - /** - * setOnlineConsultantScript - * - * @param string $value - */ - public function setOnlineConsultantScript($value) - { - static::setOption(RetailcrmConstants::CRM_ONLINE_CONSULTANT_SCRIPT, $value); - } - - - /** - * getOrderTypes - * - * @return array - */ - public static function getOrderTypes() - { - if (self::isEmptyNotZero(static::$orderTypes)) { - static::$orderTypes = static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_TYPES_ARR); - } - - return static::$orderTypes; - } - - /** - * setOrderTypes - * - * @param array $orderTypesArr - */ - public static function setOrderTypes($orderTypesArr) - { - static::setOption(RetailcrmConstants::CRM_ORDER_TYPES_ARR, serialize(RCrmActions::clearArr($orderTypesArr))); - } - - /** - * getDeliveryTypes - * - * @return array - */ - public static function getDeliveryTypes() - { - if (self::isEmptyNotZero(static::$deliveryTypes)) { - static::$deliveryTypes = static::getUnserializedOption(RetailcrmConstants::CRM_DELIVERY_TYPES_ARR); - } - - return static::$deliveryTypes; - } - - /** - * setDeliveryTypes - * - * @param array $deliveryTypesArr - */ - public static function setDeliveryTypes($deliveryTypesArr) - { - static::setOption(RetailcrmConstants::CRM_DELIVERY_TYPES_ARR, serialize(RCrmActions::clearArr($deliveryTypesArr))); - } - - /** - * getPaymentTypes - * - * @return array - */ - public static function getPaymentTypes() - { - if (self::isEmptyNotZero(static::$paymentTypes)) { - static::$paymentTypes = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT_TYPES); - } - - return static::$paymentTypes; - } - - /** - * getIntegrationPaymentTypes - * - * @return array - */ - public static function getIntegrationPaymentTypes(): array - { - if (self::isEmptyNotZero(static::$integrationPayment)) { - $option = static::getUnserializedOption(RetailcrmConstants::CRM_INTEGRATION_PAYMENT); - static::$integrationPayment = is_array($option) ? $option : []; - } - - return static::$integrationPayment; - } - - /** - * setIntegrationPaymentTypes - * @param $integrationPayment - */ - public static function setIntegrationPaymentTypes($integrationPayment) - { - static::setOption(RetailcrmConstants::CRM_INTEGRATION_PAYMENT, serialize(RCrmActions::clearArr($integrationPayment))); - } - - /** - * setIntegrationDelivery - * @param $deliveryIntegrationCode - */ - public static function setIntegrationDelivery($deliveryIntegrationCode) - { - static::setOption(RetailcrmConstants::CRM_INTEGRATION_DELIVERY, serialize(RCrmActions::clearArr($deliveryIntegrationCode))); - } - - /** - * setPaymentTypes - * - * @param array $paymentTypesArr - */ - public static function setPaymentTypes($paymentTypesArr) - { - static::setOption(RetailcrmConstants::CRM_PAYMENT_TYPES, serialize(RCrmActions::clearArr($paymentTypesArr))); - } - - /** - * getPaymentStatuses - * - * @return array - */ - public static function getPaymentStatuses() - { - if (self::isEmptyNotZero(static::$paymentStatuses)) { - static::$paymentStatuses = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT_STATUSES); - } - - return static::$paymentStatuses; - } - - /** - * getPaymentStatuses - * - * @param array $paymentStatusesArr - */ - public static function setPaymentStatuses($paymentStatusesArr) - { - static::setOption(RetailcrmConstants::CRM_PAYMENT_STATUSES, serialize(RCrmActions::clearArr($paymentStatusesArr))); - } - - /** - * getPayment - * - * @return array - */ - public static function getPayment() - { - if (self::isEmptyNotZero(static::$payment)) { - static::$payment = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT); - } - - return static::$payment; - } - - /** - * getOrderProps - * - * @return array - */ - public static function getOrderProps() - { - if (self::isEmptyNotZero(static::$orderProps)) { - static::$orderProps = static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_PROPS); - } - - return static::$orderProps; - } - - /** - * getLegalDetails - * - * @return array - */ - public static function getLegalDetails() - { - if (self::isEmptyNotZero(static::$legalDetails)) { - static::$legalDetails = static::getUnserializedOption(RetailcrmConstants::CRM_LEGAL_DETAILS); - } - - return static::$legalDetails; - } - - /** - * getContragentTypes - * - * @return array - */ - public static function getContragentTypes() - { - if (self::isEmptyNotZero(static::$contragentTypes)) { - static::$contragentTypes = static::getUnserializedOption(RetailcrmConstants::CRM_CONTRAGENT_TYPE); - } - - return static::$contragentTypes; - } - - /** - * setContragentTypes - * - * @param array $contragentTypeArr - */ - public static function setContragentTypes($contragentTypeArr) - { - static::setOption(RetailcrmConstants::CRM_CONTRAGENT_TYPE, serialize(RCrmActions::clearArr($contragentTypeArr))); - } - - /** - * getCustomFields - * - * @return array - */ - public static function getCustomFields() - { - if (self::isEmptyNotZero(static::$customFields)) { - static::$customFields = static::getUnserializedOption(RetailcrmConstants::CRM_CUSTOM_FIELDS); - } - - return static::$customFields; - } - - /** - * getCancellableOrderPaymentStatuses - * - * @return array - */ - public static function getCancellableOrderPaymentStatuses() - { - if (self::isEmptyNotZero(static::$cancellableOrderPaymentStatuses)) { - static::$cancellableOrderPaymentStatuses = static::getUnserializedOption( - RetailcrmConstants::CRM_CANCEL_ORDER - ); - } - - return static::$cancellableOrderPaymentStatuses; - } - - /** - * getLastOrderId - * - * @return bool|string|null - */ - public static function getLastOrderId() - { - return static::getOption(RetailcrmConstants::CRM_ORDER_LAST_ID); - } - - /** - * getSendPaymentAmount - * - * @return bool|string|null - */ - public static function getSendPaymentAmount() - { - return static::getOption(RetailcrmConstants::SEND_PAYMENT_AMOUNT); - } - - /** - * setSendPaymentAmount - * - * @param string $value - */ - public static function setSendPaymentAmount($value) - { - static::setOption(RetailcrmConstants::SEND_PAYMENT_AMOUNT, $value); - } - - /** - * Returns true if payment amount should be sent from CMS to RetailCRM. - * - * @return bool|string|null - */ - public static function shouldSendPaymentAmount() - { - return static::getSendPaymentAmount() === 'Y'; - } - - /** - * setLastOrderId - * - * @param $id - */ - public static function setLastOrderId($id) - { - static::setOption(RetailcrmConstants::CRM_ORDER_LAST_ID, $id); - } - - /** - * getFailedOrdersIds - * - * @return array - */ - public static function getFailedOrdersIds() - { - return static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_FAILED_IDS); - } - - /** - * setFailedOrdersIds - * - * @param $ids - */ - public static function setFailedOrdersIds($ids) - { - static::setOption(RetailcrmConstants::CRM_ORDER_FAILED_IDS, serialize($ids)); - } - - /** - * getOrderNumbers - * - * @return bool|string|null - */ - public static function getOrderNumbers() - { - if (self::isEmptyNotZero(self::$orderNumbers)) { - self::$orderNumbers = static::getOption(RetailcrmConstants::CRM_ORDER_NUMBERS); - } - - return self::$orderNumbers; - } - - /** - * getOrderHistoryDate - * - * @return bool|string|null - */ - public static function getOrderHistoryDate() - { - return static::getOption(RetailcrmConstants::CRM_ORDER_HISTORY_DATE); - } - - /** - * Returns customers history since ID - * - * @return int - */ - public static function getCustomersHistorySinceId() - { - return (int) static::getOption(RetailcrmConstants::CRM_CUSTOMERS_HISTORY_SINCE_ID); - } - - /** - * Sets new customers history since ID - * - * @param int $sinceId - */ - public static function setCustomersHistorySinceId($sinceId) - { - static::setOption(RetailcrmConstants::CRM_CUSTOMERS_HISTORY_SINCE_ID, $sinceId); - } - - /** - * getCatalogBasePrice - * - * @return bool|string|null - */ - public static function getCatalogBasePrice() - { - if (self::isEmptyNotZero(static::$catalogBasePrice)) { - static::$catalogBasePrice = static::getOption(RetailcrmConstants::CRM_CATALOG_BASE_PRICE); - } - - return static::$catalogBasePrice; - } - - /** - * @param $profileId - * - * @return false|string|null - */ - public static function getCatalogBasePriceByProfile($profileId) - { - return COption::GetOptionString( - RetailcrmConstants::MODULE_ID, - RetailcrmConstants::CRM_CATALOG_BASE_PRICE . '_' . $profileId, - 0 - ); - } - - - /** - * getOrderDimensions - * - * @return bool|string|null - */ - public static function getOrderDimensions() - { - if (self::isEmptyNotZero(static::$orderDimensions)) { - static::$orderDimensions = static::getOption(RetailcrmConstants::CRM_ORDER_DIMENSIONS, 'N'); - } - - return static::$orderDimensions; - } - - /** - * getCurrency - * - * @return bool|string|null - */ - public static function getCurrency() - { - if (self::isEmptyNotZero(static::$currency)) { - static::$currency = static::getOption(RetailcrmConstants::CRM_CURRENCY); - } - - return static::$currency; - } - - /** - * Returns currency from settings. If it's not set - returns Bitrix base currency. - * - * @return bool|string|null - */ - public static function getCurrencyOrDefault() - { - return self::getCurrency() ? self::getCurrency() : \Bitrix\Currency\CurrencyManager::getBaseCurrency(); - } - - /** - * getInfoblocksInventories - * - * @return array - */ - public static function getInfoblocksInventories() - { - if (self::isEmptyNotZero(static::$infoblocksInventories)) { - static::$infoblocksInventories = static::getUnserializedOption( - RetailcrmConstants::CRM_IBLOCKS_INVENTORIES - ); - } - - return static::$infoblocksInventories; - } - - /** - * getStores - * - * @return array - */ - public static function getStores() - { - if (self::isEmptyNotZero(static::$stores)) { - static::$stores = static::getUnserializedOption(RetailcrmConstants::CRM_STORES); - } - - return static::$stores; - } - - /** - * getShops - * - * @return array - */ - public static function getShops() - { - if (self::isEmptyNotZero(static::$shops)) { - static::$shops = static::getUnserializedOption(RetailcrmConstants::CRM_SHOPS); - } - - return static::$shops; - } - - /** - * getShipmentDeducted - * - * @return bool|string|null - */ - public static function getShipmentDeducted() - { - if (self::isEmptyNotZero(static::$shipmentDeducted)) { - static::$shipmentDeducted = static::getOption(RetailcrmConstants::CRM_SHIPMENT_DEDUCTED); - } - - return static::$shipmentDeducted; - } - - /** - * isPhoneRequired - * - * @return bool|string|null - */ - public static function isPhoneRequired() - { - return COption::GetOptionString("main", "new_user_phone_required") === 'Y'; - } - - /** - * Return integration_delivery option - * - * @return mixed - */ - public static function getCrmIntegrationDelivery() - { - return static::getUnserializedOption(RetailcrmConstants::CRM_INTEGRATION_DELIVERY); - } - - /** - * Wraps Bitrix COption::GetOptionString(...) - * - * @param string $option - * @param int|string $def - * - * @return bool|string|null - */ - private static function getOption($option, $def = 0) - { - return COption::GetOptionString( - RetailcrmConstants::MODULE_ID, - $option, - $def - ); - } - - /** - * setOption - * - * @param $name - * @param string $value - * @param bool $desc - * @param string $site - */ - private static function setOption($name, string $value = '', bool $desc = false, string $site = ''): bool - { - return COption::SetOptionString( - RetailcrmConstants::MODULE_ID, - $name, - $value, - $desc, - $site - ); - } - - /** - * Wraps Bitrix unserialize(COption::GetOptionString(...)) - * - * @param string $option - * @param int|string $def - * - * @return mixed - */ - private static function getUnserializedOption($option, $def = 0) - { - return unserialize(static::getOption($option, $def)); - } - - /** - * Returns true if value is empty and not zero (0 - digit) - * - * @param mixed $value - * - * @return bool - */ - private static function isEmptyNotZero($value) - { - return empty($value) && $value !== 0; - } } diff --git a/intaro.retailcrm/classes/general/RetailcrmConstants.php b/intaro.retailcrm/classes/general/RetailcrmConstants.php index 576888c7..0a354c43 100644 --- a/intaro.retailcrm/classes/general/RetailcrmConstants.php +++ b/intaro.retailcrm/classes/general/RetailcrmConstants.php @@ -9,8 +9,12 @@ * @package RetailCRM */ +use Intaro\RetailCrm\Component\Constants; + IncludeModuleLangFile(__FILE__); +require_once __DIR__ . '/../../lib/component/constants.php'; + /** * PHP version 5.3 * @@ -19,63 +23,6 @@ IncludeModuleLangFile(__FILE__); * @category RetailCRM * @package RetailCRM */ -class RetailcrmConstants +class RetailcrmConstants extends Constants { - public const MODULE_ID = 'intaro.retailcrm'; - public const CRM_API_HOST_OPTION = 'api_host'; - public const CRM_API_KEY_OPTION = 'api_key'; - public const CRM_ORDER_TYPES_ARR = 'order_types_arr'; - public const CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr'; - public const CRM_DELIVERY_SERVICES_ARR = 'deliv_services_arr'; - public const CRM_PAYMENT_TYPES = 'pay_types_arr'; - public const CRM_INTEGRATION_PAYMENT = 'integration_payment'; - public const CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; - public const CRM_PAYMENT = 'payment_arr'; //order payment Y/N - public const CRM_ORDER_LAST_ID = 'order_last_id'; - public const CRM_ORDER_SITES = 'sites_ids'; - public const CRM_ORDER_DISCHARGE = 'order_discharge'; - public const CRM_SITES_LIST = 'sites_list'; - public const CRM_ORDER_PROPS = 'order_props'; - public const CRM_LEGAL_DETAILS = 'legal_details'; - public const CRM_CUSTOM_FIELDS = 'custom_fields'; - public const CRM_CONTRAGENT_TYPE = 'contragent_type'; - public const CRM_SITES_LIST_CORPORATE = 'shops-corporate'; - public const CRM_ORDER_NUMBERS = 'order_numbers'; - public const CRM_CANCEL_ORDER = 'cansel_order'; - public const CRM_INVENTORIES_UPLOAD = 'inventories_upload'; - public const CRM_STORES = 'stores'; - public const CRM_SHOPS = 'shops'; - public const CRM_IBLOCKS_INVENTORIES = 'iblocks_inventories'; - public const CRM_PRICES_UPLOAD = 'prices_upload'; - public const CRM_PRICES = 'prices'; - public const CRM_PRICE_SHOPS = 'price_shops'; - public const CRM_IBLOCKS_PRICES = 'iblock_prices'; - public const CRM_COLLECTOR = 'collector'; - public const CRM_COLL_KEY = 'coll_key'; - public const CRM_UA = 'ua'; - public const CRM_UA_KEYS = 'ua_keys'; - public const CRM_DISCOUNT_ROUND = 'discount_round'; - public const CRM_CC = 'cc'; - public const CRM_CORP_SHOPS = 'shops-corporate'; - public const CRM_CORP_NAME = 'nickName-corporate'; - public const CRM_CORP_ADDRESS = 'adres-corporate'; - public const CRM_API_VERSION = 'api_version'; - public const CRM_CURRENCY = 'currency'; - public const CRM_ADDRESS_OPTIONS = 'address_options'; - public const CRM_DIMENSIONS = 'order_dimensions'; - public const PROTOCOL = 'protocol'; - public const CRM_ORDER_FAILED_IDS = 'order_failed_ids'; - public const CRM_CUSTOMERS_HISTORY_SINCE_ID = 'customer_history'; - public const CRM_ORDER_HISTORY_DATE = 'order_history_date'; - public const CRM_CATALOG_BASE_PRICE = 'catalog_base_price'; - public const CRM_ORDER_DIMENSIONS = 'order_dimensions'; - public const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED'; - public const CRM_INTEGRATION_DELIVERY = 'integration_delivery'; - public const CRM_SHIPMENT_DEDUCTED = 'shipment_deducted'; - public const SEND_PAYMENT_AMOUNT = 'send_payment_amount'; - public const CRM_ONLINE_CONSULTANT = 'online_consultant'; - public const CRM_ONLINE_CONSULTANT_SCRIPT = 'online_consultant_script'; - public const CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; - public const CRM_USERS_MAP = 'crm_users_map'; - public const BITRIX_USER_ID_PREFIX = 'bitrixUserId-'; } diff --git a/intaro.retailcrm/classes/general/RetailcrmDependencyLoader.php b/intaro.retailcrm/classes/general/RetailcrmDependencyLoader.php index 5f85c977..b184dad1 100644 --- a/intaro.retailcrm/classes/general/RetailcrmDependencyLoader.php +++ b/intaro.retailcrm/classes/general/RetailcrmDependencyLoader.php @@ -11,6 +11,8 @@ IncludeModuleLangFile(__FILE__); +require_once __DIR__ . '/../../lib/component/dependencyloader.php'; + /** * PHP version 5.3 * @@ -19,80 +21,6 @@ IncludeModuleLangFile(__FILE__); * @category RetailCRM * @package RetailCRM */ -class RetailcrmDependencyLoader +class RetailcrmDependencyLoader extends \Intaro\RetailCrm\Component\DependencyLoader { - /** @var int */ - const LEGACY_LOADER = 0; - - /** @var int */ - const D7_LOADER = 1; - - /** @var int $loader */ - private static $loader = self::D7_LOADER; - - /** - * Loads dependencies - * - * @return bool - */ - public static function loadDependencies() - { - foreach (self::getDependencies() as $dependency) { - if (self::LEGACY_LOADER == self::$loader) { - if (!CModule::IncludeModule($dependency)) { - RCrmActions::eventLog( - __CLASS__ . '::' . __METHOD__, - $dependency, - 'module not found' - ); - - return false; - } - } else { - try { - if (!\Bitrix\Main\Loader::includeModule($dependency)) { - RCrmActions::eventLog( - __CLASS__ . '::' . __METHOD__, - $dependency, - 'module not found' - ); - - return false; - } - } catch (\Bitrix\Main\LoaderException $exception) { - RCrmActions::eventLog( - __CLASS__ . '::' . __METHOD__, - $dependency, - sprintf('error while trying to load module: %s', $exception->getMessage()) - ); - - return false; - } - } - } - - return true; - } - - /** - * Set loader mode. Use RetailcrmDependencyLoader::LEGACY_LOADER or RetailcrmDependencyLoader::D7_LOADER - * - * @param $loader - */ - public static function setLoader($loader) - { - if (in_array($loader, array(self::LEGACY_LOADER, self::D7_LOADER))) { - self::$loader = $loader; - } - } - - /** - * Returns array of required modules names - * - * @return array - */ - public static function getDependencies() - { - return array("iblock", "sale", "catalog"); - } } diff --git a/intaro.retailcrm/classes/general/events/RetailCrmEvent.php b/intaro.retailcrm/classes/general/events/RetailCrmEvent.php index c91df52b..563d2adf 100644 --- a/intaro.retailcrm/classes/general/events/RetailCrmEvent.php +++ b/intaro.retailcrm/classes/general/events/RetailCrmEvent.php @@ -3,22 +3,36 @@ use Bitrix\Main\Context\Culture; use Intaro\RetailCrm\Service\ManagerService; use Bitrix\Sale\Payment; -use RetailCrm\ApiClient; +use Bitrix\Catalog\Model\Event; +use Bitrix\Main\UserTable; +use Bitrix\Sale\Order; +use Intaro\RetailCrm\Component\ConfigProvider; +use Intaro\RetailCrm\Model\Api\Response\OrdersCreateResponse; +use Intaro\RetailCrm\Model\Api\Response\OrdersEditResponse; /** * Class RetailCrmEvent */ class RetailCrmEvent { - protected static $MODULE_ID = 'intaro.retailcrm'; - protected static $CRM_API_HOST_OPTION = 'api_host'; + protected static $MODULE_ID = 'intaro.retailcrm'; + protected static $CRM_API_HOST_OPTION = 'api_host'; protected static $CRM_API_KEY_OPTION = 'api_key'; - protected static $CRM_PAYMENT_TYPES = 'pay_types_arr'; - protected static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; - protected static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N - protected static $CRM_CUSTOM_FIELDS = 'custom_fields'; - protected static $CRM_CONTRAGENT_TYPE = 'contragent_type'; - protected static $CRM_SITES_LIST = 'sites_list'; + protected static $CRM_ORDER_TYPES_ARR = 'order_types_arr'; + protected static $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr'; + protected static $CRM_PAYMENT_TYPES = 'pay_types_arr'; + protected static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; + protected static $CRM_PAYMENT = 'payment_arr'; + protected static $CRM_ORDER_LAST_ID = 'order_last_id'; + protected static $CRM_ORDER_PROPS = 'order_props'; + protected static $CRM_LEGAL_DETAILS = 'legal_details'; + protected static $CRM_CUSTOM_FIELDS = 'custom_fields'; + protected static $CRM_CONTRAGENT_TYPE = 'contragent_type'; + protected static $CRM_ORDER_FAILED_IDS = 'order_failed_ids'; + protected static $CRM_SITES_LIST = 'sites_list'; + protected static $CRM_CC = 'cc'; + protected static $CRM_CORP_NAME = 'nickName-corporate'; + protected static $CRM_CORP_ADRES = 'adres-corporate'; /** * @param $arFields @@ -31,22 +45,22 @@ class RetailCrmEvent if (isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) { return false; } - + if (!$arFields['RESULT']) { return false; } - + $optionsSitesList = RetailcrmConfigProvider::getSitesList(); $api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey()); $resultOrder = RetailCrmUser::customerEdit($arFields, $api, $optionsSitesList); - + if (!$resultOrder) { RCrmActions::eventLog('RetailCrmEvent::OnAfterUserUpdate', 'RetailCrmUser::customerEdit', 'error update customer'); } - + return true; } - + /** * onUpdateOrder * @@ -59,19 +73,19 @@ class RetailCrmEvent $GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] = false; return; } - + $GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] = true; - + if (($arFields['CANCELED'] === 'Y') && (sizeof($arFields['BASKET_ITEMS']) == 0) && (sizeof($arFields['ORDER_PROP']) == 0) ) { $GLOBALS['ORDER_DELETE_USER_ADMIN'] = true; } - + return; } - + /** * orderDelete * @@ -80,67 +94,28 @@ class RetailCrmEvent public function orderDelete($event) { $GLOBALS['RETAILCRM_ORDER_DELETE'] = true; - + return; } - + /** * @param $event * - * @return bool + * @return array|bool|OrdersCreateResponse|OrdersEditResponse|null + * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ObjectPropertyException * @throws \Bitrix\Main\SystemException - * @throws \Bitrix\Main\ArgumentException + * @throws \Exception */ - public function orderSave($event) + public static function orderSave($event) { - if (true == $GLOBALS['ORDER_DELETE_USER_ADMIN']) { - return false; - } - - if ($GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] === false - && $GLOBALS['RETAILCRM_ORDER_DELETE'] === true - ) { - return false; - } - - if ($GLOBALS['RETAIL_CRM_HISTORY'] === true) { - return false; - } - - if (!CModule::IncludeModule('iblock')) { - RCrmActions::eventLog('RetailCrmEvent::orderSave', 'iblock', 'module not found'); - - return false; - } - - if (!CModule::IncludeModule('sale')) { - RCrmActions::eventLog('RetailCrmEvent::orderSave', 'sale', 'module not found'); - - return false; - } - - if (!CModule::IncludeModule('catalog')) { - RCrmActions::eventLog('RetailCrmEvent::orderSave', 'catalog', 'module not found'); - - return false; - } - - //exists getParameter("ENTITY") - if (method_exists($event, 'getId')) { - $obOrder = $event; - } elseif (method_exists($event, 'getParameter')) { - $obOrder = $event->getParameter('ENTITY'); - } else { - RCrmActions::eventLog('RetailCrmEvent::orderSave', 'events', 'event error'); - - return false; + if (!static::checkConfig()) { + return null; } - $arOrder = RetailCrmOrder::orderObjToArr($obOrder); - + $arOrder = static::getOrderArray($event); $api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey()); - + //params $optionsOrderTypes = RetailcrmConfigProvider::getOrderTypes(); $optionsDelivTypes = RetailcrmConfigProvider::getDeliveryTypes(); @@ -152,10 +127,9 @@ class RetailCrmEvent $optionsLegalDetails = RetailcrmConfigProvider::getLegalDetails(); $optionsContragentType = RetailcrmConfigProvider::getContragentTypes(); $optionsCustomFields = RetailcrmConfigProvider::getCustomFields(); - + //corp cliente swich $optionCorpClient = RetailcrmConfigProvider::getCorporateClientStatus(); - $arParams = RCrmActions::clearArr([ 'optionsOrderTypes' => $optionsOrderTypes, 'optionsDelivTypes' => $optionsDelivTypes, @@ -168,32 +142,35 @@ class RetailCrmEvent 'optionsSitesList' => $optionsSitesList, 'optionsCustomFields' => $optionsCustomFields, ]); - + //many sites? if ($optionsSitesList) { if (array_key_exists($arOrder['LID'], $optionsSitesList) && $optionsSitesList[$arOrder['LID']] !== null) { $site = $optionsSitesList[$arOrder['LID']]; } else { - return false; + return null; } } elseif (!$optionsSitesList) { $site = null; } - + //new order? $orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arOrder['ID'], $site); + if (isset($orderCrm['order'])) { $methodApi = 'ordersEdit'; $arParams['crmOrder'] = $orderCrm['order']; } else { $methodApi = 'ordersCreate'; } - + $orderCompany = null; - if ('Y' === $optionCorpClient) { - if (true === RetailCrmCorporateClient::isCorpTookExternalId((string) $arOrder['USER_ID'], $api)) { - RetailCrmCorporateClient::setPrefixForExternalId((string) $arOrder['USER_ID'], $api); - } + + if ( + ('Y' === $optionCorpClient) + && true === RetailCrmCorporateClient::isCorpTookExternalId((string)$arOrder['USER_ID'], $api) + ) { + RetailCrmCorporateClient::setPrefixForExternalId((string) $arOrder['USER_ID'], $api); } //TODO эта управляющая конструкция по функционалу дублирует RetailCrmOrder::createCustomerForOrder. @@ -207,34 +184,34 @@ class RetailCrmEvent $userCorp = []; $corpName = RetailcrmConfigProvider::getCorporateClientName(); $corpAddress = RetailcrmConfigProvider::getCorporateClientAddress(); - + foreach ($arOrder['PROPS']['properties'] as $prop) { if ($prop['CODE'] === $corpName) { $nickName = $prop['VALUE'][0]; } - + if ($prop['CODE'] === $corpAddress) { $address = $prop['VALUE'][0]; } - + if (!empty($optionsLegalDetails) && $search = array_search($prop['CODE'], $optionsLegalDetails[$arOrder['PERSON_TYPE_ID']]) ) { $contragent[$search] = $prop['VALUE'][0];//legal order data } } - + if (!empty($contragentType)) { $contragent['contragentType'] = $contragentType; } - + $customersCorporate = false; $response = $api->customersCorporateList(['companyName' => $nickName]); - + if ($response && $response->getStatusCode() == 200) { $customersCorporate = $response['customersCorporate']; $singleCorp = reset($customersCorporate); - + if (!empty($singleCorp)) { $userCorp['customerCorporate'] = $singleCorp; $companiesResponse = $api->customersCorporateCompanies( @@ -245,7 +222,7 @@ class RetailCrmEvent 'id', $site ); - + if ($companiesResponse && $companiesResponse->isSuccessful()) { $orderCompany = array_reduce( $companiesResponse['companies'], @@ -253,7 +230,7 @@ class RetailCrmEvent if (is_array($item) && $item['name'] === $nickName) { $carry = $item; } - + return $carry; }, null @@ -266,35 +243,35 @@ class RetailCrmEvent 'ApiClient::customersCorporateList', 'error during fetching corporate customers' ); - - return false; + + return null; } - + //user $userCrm = RCrmActions::apiMethod($api, 'customersGet', __METHOD__, $arOrder['USER_ID'], $site); - + if (!isset($userCrm['customer'])) { - $arUser = Bitrix\Main\UserTable::getById($arOrder['USER_ID'])->fetch(); - + $arUser = UserTable::getById($arOrder['USER_ID'])->fetch(); + if (!empty($address)) { $arUser['PERSONAL_STREET'] = $address; } - + $resultUser = RetailCrmUser::customerSend($arUser, $api, 'individual', true, $site); - + if (!$resultUser) { RCrmActions::eventLog( __CLASS__ . '::' . __METHOD__, 'RetailCrmUser::customerSend', 'error during creating customer' ); - - return false; + + return null; } - + $userCrm = ['customer' => ['externalId' => $arOrder['USER_ID']]]; } - + if (!isset($userCorp['customerCorporate'])) { $resultUserCorp = RetailCrmCorporateClient::clientSend( $arOrder, @@ -304,23 +281,23 @@ class RetailCrmEvent false, $site ); - + Logger::getInstance()->write($resultUserCorp, 'resultUserCorp'); - + if (!$resultUserCorp) { RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmCorporateClient::clientSend', 'error during creating client'); - - return false; + + return null; } - + $arParams['customerCorporate'] = $resultUserCorp; $arParams['orderCompany'] = $resultUserCorp['mainCompany'] ?? null; - + $customerCorporateAddress = []; $customerCorporateCompany = []; $addressResult = null; $companyResult = null; - + if (!empty($address)) { //TODO address builder add $customerCorporateAddress = [ @@ -328,24 +305,24 @@ class RetailCrmEvent 'isMain' => true, 'text' => $address, ]; - + $addressResult = $api->customersCorporateAddressesCreate($resultUserCorp['id'], $customerCorporateAddress, 'id', $site); } - + $customerCorporateCompany = [ 'name' => $nickName, 'isMain' => true, 'contragent' => $contragent, ]; - + if (!empty($addressResult)) { $customerCorporateCompany['address'] = [ 'id' => $addressResult['id'], ]; } - + $companyResult = $api->customersCorporateCompaniesCreate($resultUserCorp['id'], $customerCorporateCompany, 'id', $site); - + $customerCorporateContact = [ 'isMain' => true, 'customer' => [ @@ -353,26 +330,26 @@ class RetailCrmEvent 'site' => $site, ], ]; - + if (!empty($companyResult)) { $orderCompany = [ 'id' => $companyResult['id'], ]; - + $customerCorporateContact['companies'] = [ [ 'company' => $orderCompany, ], ]; } - + $api->customersCorporateContactsCreate( $resultUserCorp['id'], $customerCorporateContact, 'id', $site ); - + $arParams['orderCompany'] = array_merge( $customerCorporateCompany, ['id' => $companyResult['id']] @@ -385,44 +362,61 @@ class RetailCrmEvent $api, $site = null ); - + $arParams['customerCorporate'] = $userCorp['customerCorporate']; - + if (!empty($orderCompany)) { $arParams['orderCompany'] = $orderCompany; } } - + $arParams['contactExId'] = $userCrm['customer']['externalId']; } else { //user $userCrm = RCrmActions::apiMethod($api, 'customersGet', __METHOD__, $arOrder['USER_ID'], $site); + if (!isset($userCrm['customer'])) { $arUser = Bitrix\Main\UserTable::getById($arOrder['USER_ID'])->fetch(); - $resultUser = RetailCrmUser::customerSend($arUser, $api, $optionsContragentType[$arOrder['PERSON_TYPE_ID']], true, $site); + $resultUser = RetailCrmUser::customerSend( + $arUser, + $api, + $optionsContragentType[$arOrder['PERSON_TYPE_ID']], + true, + $site + ); + if (!$resultUser) { - RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmUser::customerSend', 'error during creating customer'); - - return false; - } + RCrmActions::eventLog( + 'RetailCrmEvent::orderSave', + 'RetailCrmUser::customerSend', + 'error during creating customer' + ); + + return null; + }http://localhost/personal/cart/ } } + if (isset($arOrder['RESPONSIBLE_ID']) && !empty($arOrder['RESPONSIBLE_ID'])) { $managerService = ManagerService::getInstance(); $arParams['managerId'] = $managerService->getManagerCrmId($arOrder['RESPONSIBLE_ID']); } //order $resultOrder = RetailCrmOrder::orderSend($arOrder, $api, $arParams, true, $site, $methodApi); - + if (!$resultOrder) { - RCrmActions::eventLog('RetailCrmEvent::orderSave', 'RetailCrmOrder::orderSend', 'error during creating order'); - - return false; + RCrmActions::eventLog( + 'RetailCrmEvent::orderSave', + 'RetailCrmOrder::orderSend', + 'error during creating order' + ); + + return null; } - - return true; + + return $resultOrder; } - + /** * @param \Bitrix\Sale\Payment $event * @@ -433,22 +427,22 @@ class RetailCrmEvent public function paymentSave(Payment $event) { $apiVersion = COption::GetOptionString(self::$MODULE_ID, 'api_version', 0); - + /** @var \Bitrix\Sale\Order $order */ $order = $event->getCollection()->getOrder(); - + if ((isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) || $apiVersion !== 'v5' || $order->isNew() ) { return false; } - - $optionsSitesList = RetailcrmConfigProvider::getSitesList(); + + $optionsSitesList = RetailcrmConfigProvider::getSitesList(); $optionsPaymentTypes = RetailcrmConfigProvider::getPaymentTypes(); $optionsPayStatuses = RetailcrmConfigProvider::getPayment(); $integrationPaymentTypes = RetailcrmConfigProvider::getIntegrationPaymentTypes(); - + $arPayment = [ 'ID' => $event->getId(), 'ORDER_ID' => $event->getField('ORDER_ID'), @@ -458,7 +452,7 @@ class RetailCrmEvent 'LID' => $order->getSiteId(), 'DATE_PAID' => $event->getField('DATE_PAID'), ]; - + if ($optionsSitesList) { if (array_key_exists($arPayment['LID'], $optionsSitesList) && $optionsSitesList[$arPayment['LID']] !== null) { $site = $optionsSitesList[$arPayment['LID']]; @@ -468,14 +462,14 @@ class RetailCrmEvent } elseif (!$optionsSitesList) { $site = null; } - + $api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey()); $orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arPayment['ORDER_ID'], $site); - + if (isset($orderCrm['order'])) { $payments = $orderCrm['order']['payments']; } - + if ($payments) { foreach ($payments as $payment) { if (isset($payment['externalId'])) { @@ -488,16 +482,16 @@ class RetailCrmEvent } } } - + if (!empty($arPayment['PAY_SYSTEM_ID']) && isset($optionsPaymentTypes[$arPayment['PAY_SYSTEM_ID']])) { $paymentToCrm = [ 'type' => $optionsPaymentTypes[$arPayment['PAY_SYSTEM_ID']], ]; - + if (!empty($arPayment['ID'])) { $paymentToCrm['externalId'] = RCrmActions::generatePaymentExternalId($arPayment['ID']); } - + $isIntegrationPayment = RetailCrmService::isIntegrationPayment($arPayment['PAY_SYSTEM_ID'] ?? null); @@ -509,15 +503,15 @@ class RetailCrmEvent $paymentToCrm['paidAt'] = $arPayment['DATE_PAID']; } } - + if (!empty($optionsPayStatuses[$arPayment['PAID']]) && !$isIntegrationPayment) { $paymentToCrm['status'] = $optionsPayStatuses[$arPayment['PAID']]; } - + if (!empty($arPayment['ORDER_ID'])) { $paymentToCrm['order']['externalId'] = $arPayment['ORDER_ID']; } - + if (RetailcrmConfigProvider::shouldSendPaymentAmount()) { $paymentToCrm['amount'] = $arPayment['SUM']; } @@ -525,9 +519,9 @@ class RetailCrmEvent RCrmActions::eventLog('RetailCrmEvent::paymentSave', 'payments', 'OrderID = ' . $arPayment['ID'] . '. Payment not found.'); return false; } - + $arPaymentExtId = RCrmActions::generatePaymentExternalId($arPayment['ID']); - + if (array_key_exists($arPaymentExtId, $paymentsExternalIds)) { $paymentData = $paymentsExternalIds[$arPaymentExtId]; } elseif (array_key_exists($arPayment['ID'], $paymentsExternalIds)) { @@ -535,7 +529,7 @@ class RetailCrmEvent } else { $paymentData = []; } - + if (empty($paymentData)) { RCrmActions::apiMethod($api, 'ordersPaymentCreate', __METHOD__, $paymentToCrm, $site); } elseif ($paymentData['type'] == $optionsPaymentTypes[$arPayment['PAY_SYSTEM_ID']]) { @@ -547,7 +541,7 @@ class RetailCrmEvent ); return false; } - + $paymentToCrm['externalId'] = $paymentData['externalId']; RCrmActions::apiMethod($api, 'paymentEditByExternalId', __METHOD__, $paymentToCrm, $site); } elseif ($paymentData['type'] != $optionsPaymentTypes[$arPayment['PAY_SYSTEM_ID']]) { @@ -559,10 +553,10 @@ class RetailCrmEvent ); RCrmActions::apiMethod($api, 'ordersPaymentCreate', __METHOD__, $paymentToCrm, $site); } - + return true; } - + /** * @param \Bitrix\Sale\Payment $event * @@ -571,22 +565,22 @@ class RetailCrmEvent public function paymentDelete(Payment $event): void { $apiVersion = COption::GetOptionString(self::$MODULE_ID, 'api_version', 0); - + if ((isset($GLOBALS['RETAIL_CRM_HISTORY']) && $GLOBALS['RETAIL_CRM_HISTORY']) - || $apiVersion != 'v5' + || $apiVersion !== 'v5' || !$event->getId() ) { return; } - + $optionsSitesList = RetailcrmConfigProvider::getSitesList(); - + $arPayment = [ 'ID' => $event->getId(), 'ORDER_ID' => $event->getField('ORDER_ID'), 'LID' => $event->getCollection()->getOrder()->getSiteId(), ]; - + if ($optionsSitesList) { if (array_key_exists($arPayment['LID'], $optionsSitesList) && $optionsSitesList[$arPayment['LID']] !== null) { $site = $optionsSitesList[$arPayment['LID']]; @@ -596,12 +590,10 @@ class RetailCrmEvent } elseif (!$optionsSitesList) { $site = null; } - - $api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0); - $api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0); - $api = new ApiClient($api_host, $api_key); + + $api = new RetailCrm\ApiClient(ConfigProvider::getApiUrl(), ConfigProvider::getApiKey()); $orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arPayment['ORDER_ID'], $site); - + if (isset($orderCrm['order']['payments']) && $orderCrm['order']['payments']) { foreach ($orderCrm['order']['payments'] as $payment) { if (isset($payment['externalId']) @@ -613,4 +605,50 @@ class RetailCrmEvent } } } + + /** + * @return bool + */ + private static function checkConfig(): bool + { + if (true == $GLOBALS['ORDER_DELETE_USER_ADMIN']) { + return false; + } + + if ($GLOBALS['RETAILCRM_ORDER_OLD_EVENT'] === false + && $GLOBALS['RETAILCRM_ORDER_DELETE'] === true + ) { + return false; + } + + if ($GLOBALS['RETAIL_CRM_HISTORY'] === true) { + return false; + } + + if (!RetailcrmDependencyLoader::loadDependencies()) { + return false; + } + + return true; + } + + /** + * @param \Bitrix\Sale\Order|\Bitrix\Main\Event $event + * + * @throws \Bitrix\Main\SystemException + */ + private static function getOrderArray($event): ?array + { + if ($event instanceof Order) { + $obOrder = $event; + } elseif ($event instanceof Event) { + $obOrder = $event->getParameter('ENTITY'); + } else { + RCrmActions::eventLog('RetailCrmEvent::orderSave', 'events', 'event error'); + + return null; + } + + return RetailCrmOrder::orderObjToArr($obOrder); + } } diff --git a/intaro.retailcrm/classes/general/history/FastOrderHistory.php b/intaro.retailcrm/classes/general/history/FastOrderHistory.php index 1149acf2..be2b095d 100644 --- a/intaro.retailcrm/classes/general/history/FastOrderHistory.php +++ b/intaro.retailcrm/classes/general/history/FastOrderHistory.php @@ -4,7 +4,7 @@ require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_be $GLOBALS['APPLICATION']->RestartBuffer(); $moduleId = 'intaro.retailcrm'; $historyTime = 'history_time'; -$idOrderCRM = (int)$_REQUEST['idOrderCRM']; +$idOrderCRM = (int) $_REQUEST['idOrderCRM']; if (CModule::IncludeModule($moduleId) && $idOrderCRM && $idOrderCRM > 0) { $timeBd = COption::GetOptionString($moduleId, $historyTime, 0); diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v4.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v4.php index 800301d5..ab2b754c 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v4.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v4.php @@ -9,7 +9,7 @@ class RetailCrmHistory public static $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr'; public static $CRM_PAYMENT_TYPES = 'pay_types_arr'; public static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; - public static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N + public static $CRM_PAYMENT = 'payment_arr'; public static $CRM_ORDER_LAST_ID = 'order_last_id'; public static $CRM_SITES_LIST = 'sites_list'; public static $CRM_ORDER_PROPS = 'order_props'; @@ -751,7 +751,7 @@ class RetailCrmHistory if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) { $objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml'); foreach ($objects->fields->field as $object) { - $fields[(string)$object["group"]][(string)$object["id"]] = (string)$object; + $fields[(string) $object["group"]][(string) $object["id"]] = (string) $object; } } $customers = array(); @@ -804,7 +804,7 @@ class RetailCrmHistory if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) { $objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml'); foreach ($objects->fields->field as $object) { - $fields[(string)$object["group"]][(string)$object["id"]] = (string)$object; + $fields[(string) $object["group"]][(string) $object["id"]] = (string) $object; } } $orders = array(); diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 19a90222..e932b031 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -2,7 +2,10 @@ use Bitrix\Main\ArgumentException; use Bitrix\Main\ArgumentNullException; +use Bitrix\Main\ArgumentOutOfRangeException; use Bitrix\Main\Context; +use Bitrix\Main\NotSupportedException; +use Bitrix\Main\SystemException; use Bitrix\Sale\Basket; use Bitrix\Sale\Delivery\Services\EmptyDeliveryService; use Bitrix\Sale\Delivery\Services\Manager; @@ -11,7 +14,11 @@ use Bitrix\Sale\Internals\PaymentTable; use Bitrix\Sale\Location\Search\Finder; use Bitrix\Sale\Order; use Bitrix\Sale\OrderUserProperties; +use Bitrix\Sale\Payment; use Intaro\RetailCrm\Service\ManagerService; +use Intaro\RetailCrm\Component\ConfigProvider; +use Intaro\RetailCrm\Component\Constants; +use Intaro\RetailCrm\Component\Handlers\EventsHandlers; IncludeModuleLangFile(__FILE__); class RetailCrmHistory @@ -532,7 +539,7 @@ class RetailCrmHistory continue; } - + $site = self::getSite($order['site']); if (null === $site) { @@ -1229,7 +1236,7 @@ class RetailCrmHistory return false; } - + /** * @param string $shopCode * @@ -1238,18 +1245,18 @@ class RetailCrmHistory public static function getSite(string $shopCode): ?string { $optionsSitesList = RetailcrmConfigProvider::getSitesList(); - + if ($optionsSitesList) { $searchResult = array_search($shopCode, $optionsSitesList, true); - + return is_string($searchResult) ? $searchResult : null; } - + $defaultSite = CSite::GetDefSite(); - + return is_string($defaultSite) ? $defaultSite : null; } - + /** * @param $array * @param $value @@ -1493,7 +1500,7 @@ class RetailCrmHistory return $orders; } - + /** * Filters out history by these terms: * - Changes from current API key will be added only if CMS changes are more actual than history. @@ -1512,7 +1519,7 @@ class RetailCrmHistory $history = []; $organizedHistory = []; $notOurChanges = []; - + foreach ($historyEntries as $entry) { if (!isset($entry[$recordType]['externalId'])) { if ($entry['source'] == 'api' @@ -1522,23 +1529,23 @@ class RetailCrmHistory ) { continue; } - + $history[] = $entry; - + continue; } - + $externalId = $entry[$recordType]['externalId']; $field = $entry['field']; - + if (!isset($organizedHistory[$externalId])) { $organizedHistory[$externalId] = []; } - + if (!isset($notOurChanges[$externalId])) { $notOurChanges[$externalId] = []; } - + if ($entry['source'] == 'api' && isset($entry['apiKey']['current']) && $entry['apiKey']['current'] == true @@ -1553,38 +1560,42 @@ class RetailCrmHistory $notOurChanges[$externalId][$field] = true; } } - + unset($notOurChanges); - + foreach ($organizedHistory as $historyChunk) { $history = array_merge($history, $historyChunk); } - + return $history; } - + /** * Update shipment in order * - * @param order object - * @param options delivery types - * @param order from crm + * @param \Bitrix\Sale\Order $bitrixOrder + * @param array $optionsDelivTypes + * @param array $crmOrder * - * @return void + * @return bool|null + * @throws \Bitrix\Main\ArgumentException + * @throws \Bitrix\Main\ArgumentNullException + * @throws \Bitrix\Main\ObjectNotFoundException + * @throws \Bitrix\Main\SystemException */ - public static function deliveryUpdate(Bitrix\Sale\Order $order, $optionsDelivTypes, $orderCrm) + public static function deliveryUpdate(Bitrix\Sale\Order $bitrixOrder, $optionsDelivTypes, $crmOrder) { - if (!$order instanceof Bitrix\Sale\Order) { + if (!$bitrixOrder instanceof Bitrix\Sale\Order) { return false; } - if ($order->getId()) { + if ($bitrixOrder->getId()) { $update = true; } else { $update = false; } - $crmCode = $orderCrm['delivery']['code'] ?? false; + $crmCode = $crmOrder['delivery']['code'] ?? false; $noDeliveryId = EmptyDeliveryService::getEmptyDeliveryServiceId(); if ($crmCode === false || !isset($optionsDelivTypes[$crmCode])) { @@ -1592,9 +1603,9 @@ class RetailCrmHistory } else { $deliveryId = $optionsDelivTypes[$crmCode]; - if (isset($orderCrm['delivery']['service']['code'])) { + if (isset($crmOrder['delivery']['service']['code'])) { $deliveryCode = Manager::getCodeById($deliveryId); - $serviceCode = $orderCrm['delivery']['service']['code']; + $serviceCode = $crmOrder['delivery']['service']['code']; $service = Manager::getService($deliveryId); if (is_object($service)) { @@ -1608,7 +1619,7 @@ class RetailCrmHistory if ($deliveryCode) { try { $deliveryService = Manager::getObjectByCode($deliveryCode . ':' . $serviceCode); - } catch (Bitrix\Main\SystemException $systemException) { + } catch (SystemException $systemException) { RCrmActions::eventLog('RetailCrmHistory::deliveryEdit', '\Bitrix\Sale\Delivery\Services\Manager::getObjectByCode', $systemException->getMessage()); } @@ -1620,31 +1631,33 @@ class RetailCrmHistory } $delivery = Manager::getObjectById($deliveryId); - $shipmentColl = $order->getShipmentCollection(); + $shipmentColl = $bitrixOrder->getShipmentCollection(); if ($delivery) { if (!$update) { $shipment = $shipmentColl->createItem($delivery); $shipment->setFields(array( - 'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'], - 'CURRENCY' => $order->getCurrency(), - 'DELIVERY_NAME' => $delivery->getName(), + 'BASE_PRICE_DELIVERY' => $crmOrder['delivery']['cost'], + 'CURRENCY' => $bitrixOrder->getCurrency(), + 'DELIVERY_NAME' => $delivery->getName(), 'CUSTOM_PRICE_DELIVERY' => 'Y' )); } else { foreach ($shipmentColl as $shipment) { if (!$shipment->isSystem()) { $shipment->setFields(array( - 'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'], - 'CURRENCY' => $order->getCurrency(), - 'DELIVERY_ID' => $deliveryId, - 'DELIVERY_NAME' => $delivery->getName(), + 'BASE_PRICE_DELIVERY' => $crmOrder['delivery']['cost'], + 'CURRENCY' => $bitrixOrder->getCurrency(), + 'DELIVERY_ID' => $deliveryId, + 'DELIVERY_NAME' => $delivery->getName(), 'CUSTOM_PRICE_DELIVERY' => 'Y' )); } } } } + + return true; } /** @@ -1703,11 +1716,11 @@ class RetailCrmHistory if (!$shipment->isSystem()) { try { $shipment->tryUnreserve(); - } catch (Main\ArgumentOutOfRangeException $ArgumentOutOfRangeException) { + } catch (ArgumentOutOfRangeException $ArgumentOutOfRangeException) { RCrmActions::eventLog('RetailCrmHistory::unreserveShipment', '\Bitrix\Sale\Shipment::tryUnreserve()', $ArgumentOutOfRangeException->getMessage()); return false; - } catch (Main\NotSupportedException $NotSupportedException) { + } catch (NotSupportedException $NotSupportedException) { RCrmActions::eventLog('RetailCrmHistory::unreserveShipment', '\Bitrix\Sale\Shipment::tryUnreserve()', $NotSupportedException->getMessage()); return false; @@ -1748,7 +1761,7 @@ class RetailCrmHistory $nowPaymentId = RCrmActions::getFromPaymentExternalId($paymentCrm['externalId']); $nowPayment = $paymentsList[$nowPaymentId]; //update data - if ($nowPayment instanceof \Bitrix\Sale\Payment) { + if ($nowPayment instanceof Payment) { $nowPayment->setField('SUM', $paymentCrm['amount']); if ($optionsPayTypes[$paymentCrm['type']] != $nowPayment->getField('PAY_SYSTEM_ID')) { $nowPayment->setField('PAY_SYSTEM_ID', $optionsPayTypes[$paymentCrm['type']]); diff --git a/intaro.retailcrm/classes/general/history/RetailUser.php b/intaro.retailcrm/classes/general/history/RetailUser.php index 6dc119d9..07df4bd1 100644 --- a/intaro.retailcrm/classes/general/history/RetailUser.php +++ b/intaro.retailcrm/classes/general/history/RetailUser.php @@ -14,30 +14,29 @@ class RetailUser extends CUser if ($arUser = $rsUser->Fetch()) { return $arUser['ID']; - } else { - $retailUser = new CUser; - - $userPassword = uniqid(); - - $arFields = [ - "NAME" => 'retailcrm', - "LAST_NAME" => 'retailcrm', - "EMAIL" => 'retailcrm@retailcrm.com', - "LOGIN" => 'retailcrm', - "LID" => "ru", - "ACTIVE" => "Y", - "GROUP_ID" => [2], - "PASSWORD" => $userPassword, - "CONFIRM_PASSWORD" => $userPassword, - ]; - - $id = $retailUser->Add($arFields); - - if (!$id) { - return null; - } else { - return $id; - } } + + $retailUser = new CUser; + $userPassword = uniqid(); + + $arFields = [ + 'NAME' => 'retailcrm', + 'LAST_NAME' => 'retailcrm', + 'EMAIL' => 'retailcrm@retailcrm.com', + 'LOGIN' => 'retailcrm', + 'LID' => 'ru', + 'ACTIVE' => 'Y', + 'GROUP_ID' => [2], + 'PASSWORD' => $userPassword, + 'CONFIRM_PASSWORD' => $userPassword, + ]; + + $id = $retailUser->Add($arFields); + + if (!$id) { + return null; + } + + return $id; } } diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php index bbd48711..08feda80 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php @@ -9,7 +9,7 @@ class RetailCrmOrder public static $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr'; public static $CRM_PAYMENT_TYPES = 'pay_types_arr'; public static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; - public static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N + public static $CRM_PAYMENT = 'payment_arr'; public static $CRM_ORDER_LAST_ID = 'order_last_id'; public static $CRM_SITES_LIST = 'sites_list'; public static $CRM_ORDER_PROPS = 'order_props'; diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index ad6ef492..08db5ac2 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -8,9 +8,14 @@ use Bitrix\Sale\Internals\Fields; use Bitrix\Sale\Internals\OrderTable; use Bitrix\Sale\Location\LocationTable; use Bitrix\Sale\Order; +use Intaro\RetailCrm\Component\Factory\ClientFactory; +use Intaro\RetailCrm\Component\ServiceLocator; +use Intaro\RetailCrm\Service\LoyaltyService; use RetailCrm\ApiClient; use Intaro\RetailCrm\Service\ManagerService; +use Intaro\RetailCrm\Service\LoyaltyAccountService; use RetailCrm\Response\ApiResponse; +use Intaro\RetailCrm\Component\ConfigProvider; IncludeModuleLangFile(__FILE__); @@ -29,7 +34,7 @@ class RetailCrmOrder * @param null $site * @param string $methodApi * - * @return boolean|array + * @return array|false|\Intaro\RetailCrm\Model\Api\Response\OrdersCreateResponse|\Intaro\RetailCrm\Model\Api\Response\OrdersEditResponse|null * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ObjectPropertyException * @throws \Bitrix\Main\SystemException @@ -43,12 +48,12 @@ class RetailCrmOrder string $methodApi = 'ordersEdit' ) { if (!$api || empty($arParams)) { // add cond to check $arParams - return false; + return null; } if (empty($arOrder)) { RCrmActions::eventLog('RetailCrmOrder::orderSend', 'empty($arFields)', 'incorrect order'); - return false; + return null; } $dimensionsSetting = RetailcrmConfigProvider::getOrderDimensions(); @@ -161,7 +166,7 @@ class RetailCrmOrder //deliverys if (array_key_exists($arOrder['DELIVERYS'][0]['id'], $arParams['optionsDelivTypes'])) { $order['delivery']['code'] = $arParams['optionsDelivTypes'][$arOrder['DELIVERYS'][0]['id']]; - + if (isset($arOrder['DELIVERYS'][0]['service']) && $arOrder['DELIVERYS'][0]['service'] != '') { $order['delivery']['service']['code'] = $arOrder['DELIVERYS'][0]['service']; } @@ -176,7 +181,7 @@ class RetailCrmOrder $response = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $order['externalId']); if (isset($response['order'])) { foreach ($response['order']['items'] as $k => $item) { - $externalId = $k ."_". $item['offer']['externalId']; + $externalId = $k .'_'. $item['offer']['externalId']; $orderItems[$externalId] = $item; } } @@ -192,7 +197,7 @@ class RetailCrmOrder $itemId = $orderItems[$externalId]['id']; $key = array_search('bitrix', array_column($externalIds, 'code')); - + if ($externalIds[$key]['code'] === 'bitrix') { $externalIds[$key] = [ 'code' => 'bitrix', @@ -203,13 +208,31 @@ class RetailCrmOrder 'code' => 'bitrix', 'value' => $externalId, ]; - } + } + + $keyBasketId = array_search('bitrixBasketId', array_column($externalIds, 'code')); + + if ($externalIds[$keyBasketId]['code'] === 'bitrixBasketId') { + $externalIds[$keyBasketId] = [ + 'code' => 'bitrixBasketId', + 'value' => $product['ID'], + ]; + } else { + $externalIds[] = [ + 'code' => 'bitrixBasketId', + 'value' => $product['ID'], + ]; + } } else { //create $externalIds = [ [ 'code' => 'bitrix', 'value' => $externalId, - ] + ], + [ + 'code' => 'bitrixBasketId', + 'value' => $product['ID'], + ], ]; } @@ -228,7 +251,7 @@ class RetailCrmOrder } $catalogProduct = CCatalogProduct::GetByID($product['PRODUCT_ID']); - + if (is_null($catalogProduct['PURCHASING_PRICE']) === false) { if ($catalogProduct['PURCHASING_CURRENCY'] && $currency != $catalogProduct['PURCHASING_CURRENCY']) { $purchasePrice = CCurrencyRates::ConvertCurrency( @@ -243,9 +266,25 @@ class RetailCrmOrder $item['purchasePrice'] = $purchasePrice; } + $discount = (double) $product['DISCOUNT_PRICE']; + $dpItem = $product['BASE_PRICE'] - $product['PRICE']; + + if ( $dpItem > 0 && $discount <= 0) { + $discount = $dpItem; + } + $item['discountManualPercent'] = 0; - - if ($product['BASE_PRICE'] >= $product['PRICE']) { + $item['initialPrice'] = (double) $product['BASE_PRICE']; + + if ( + $product['BASE_PRICE'] >= $product['PRICE'] + && $methodApi === 'ordersEdit' + && ConfigProvider::getLoyaltyProgramStatus() === 'Y' + ) { + /** @var LoyaltyService $service */ + $service = ServiceLocator::get(LoyaltyService::class); + $item['discountManualAmount'] = $service->getInitialDiscount((int) $externalId) ?? $discount; + } elseif ($product['BASE_PRICE'] >= $product['PRICE']) { $item['discountManualAmount'] = self::getDiscountManualAmount($product); $item['initialPrice'] = (double) $product['BASE_PRICE']; } else { @@ -276,7 +315,7 @@ class RetailCrmOrder //payments $payments = []; - + foreach ($arOrder['PAYMENTS'] as $payment) { $isIntegrationPayment = RetailCrmService::isIntegrationPayment($payment['PAY_SYSTEM_ID'] ?? null); @@ -340,8 +379,21 @@ class RetailCrmOrder Logger::getInstance()->write($order, 'orderSend'); - if ($send && !RCrmActions::apiMethod($api, $methodApi, __METHOD__, $order, $site)) { - return false; + if (ConfigProvider::getLoyaltyProgramStatus() === 'Y' && LoyaltyAccountService::getLoyaltyPersonalStatus()) { + $order['privilegeType'] = 'loyalty_level'; + } + + /** @var \Intaro\RetailCrm\Component\ApiClient\ClientAdapter $client */ + $client = ClientFactory::createClientAdapter(); + + if ($send) { + if ($methodApi === 'ordersCreate') { + return $client->createOrder($order, $site); + } + + if ($methodApi === 'ordersEdit') { + return $client->editOrder($order, $site); + } } return $order; @@ -354,7 +406,7 @@ class RetailCrmOrder * @param bool $failed -- flag to export failed orders * @param array|null $orderList * - * @return boolean + * @return bool * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ArgumentNullException * @throws \Bitrix\Main\ObjectPropertyException @@ -381,7 +433,7 @@ class RetailCrmOrder $orderIds = $orderList; } else { $dbOrder = OrderTable::GetList([ - 'order' => ["ID" => "ASC"], + 'order' => ['ID' => 'ASC'], 'filter' => ['>ID' => $lastUpOrderId], 'limit' => $pSize, 'select' => ['ID'], @@ -433,7 +485,6 @@ class RetailCrmOrder $arCustomer = []; $arCustomerCorporate = []; $order = self::orderObjToArr($bitrixOrder); - $user = UserTable::getById($order['USER_ID'])->fetch(); $site = self::getCrmShopCodeByLid($order['LID'], $arParams['optionsSitesList']); if (null === $site && count($arParams['optionsSitesList']) > 0) { @@ -474,7 +525,7 @@ class RetailCrmOrder return false; } - if ('Y' == RetailcrmConfigProvider::getCorporateClientStatus()) { + if ('Y' === RetailcrmConfigProvider::getCorporateClientStatus()) { $cachedCorporateIds = []; foreach ($ordersPack as $lid => $lidOrdersList) { @@ -497,7 +548,7 @@ class RetailCrmOrder if ($failed == true && $failedIds !== false && count($failedIds) > 0) { RetailcrmConfigProvider::setFailedOrdersIds(array_diff($failedIds, $recOrders)); - } elseif ($lastUpOrderId < max($recOrders) && $orderList === false) { + } elseif (count($orderList) === 0 && $lastUpOrderId < max($recOrders)) { RetailcrmConfigProvider::setLastOrderId(max($recOrders)); } } @@ -709,7 +760,7 @@ class RetailCrmOrder foreach ($pack as $key => $itemLoad) { $site = self::getCrmShopCodeByLid($key, $optionsSitesList); - + if (null === $site && count($optionsSitesList) > 0) { continue; } @@ -839,14 +890,14 @@ class RetailCrmOrder $sumDifference = $product->get('BASE_PRICE') - $product->get('PRICE'); return $sumDifference > 0 ? $sumDifference : 0.0; } - + $discount = (double) $product->get('DISCOUNT_PRICE'); $dpItem = $product->get('BASE_PRICE') - $product->get('PRICE'); - + if ($dpItem > 0 && $discount <= 0) { return $dpItem; } - + return $discount; } } diff --git a/intaro.retailcrm/classes/general/services/RetailCrmService.php b/intaro.retailcrm/classes/general/services/RetailCrmService.php index 22f8d973..9a4a87e3 100644 --- a/intaro.retailcrm/classes/general/services/RetailCrmService.php +++ b/intaro.retailcrm/classes/general/services/RetailCrmService.php @@ -12,8 +12,7 @@ class RetailCrmService */ public static function unsetIntegrationDeliveryFields(array $order): array { - $integrationDelivery = RetailcrmConfigProvider::getCrmIntegrationDelivery(); - + $integrationDelivery = RetailcrmConfigProvider::getCrmIntegrationDelivery(); if (isset($order['delivery']['code'])) { $deliveryCode = $order['delivery']['code']; diff --git a/intaro.retailcrm/classes/general/user/RetailCrmUser.php b/intaro.retailcrm/classes/general/user/RetailCrmUser.php index 00dee6d6..61019bdf 100644 --- a/intaro.retailcrm/classes/general/user/RetailCrmUser.php +++ b/intaro.retailcrm/classes/general/user/RetailCrmUser.php @@ -61,7 +61,7 @@ class RetailCrmUser return $customer; } - public static function customerEdit($arFields, $api, $optionsSitesList = array()): bool + public static function customerEdit($arFields, $api, $optionsSitesList = array()) : bool { if (empty($arFields)) { RCrmActions::eventLog('RetailCrmUser::customerEdit', 'empty($arFields)', 'incorrect customer'); diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index f937918a..864624db 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправление некорректной генерации каталога при повторных запусках генерации +- Добавлена поддержка программы лояльности diff --git a/intaro.retailcrm/export/export_setup.php b/intaro.retailcrm/export/export_setup.php index d0eea8cd..02579e8b 100644 --- a/intaro.retailcrm/export/export_setup.php +++ b/intaro.retailcrm/export/export_setup.php @@ -357,7 +357,7 @@ if ($STEP === 1) { $arIBlock['OLD_PROPERTY_SKU_SELECT'], $propertyKey ); - + echo $isSelected ? ' selected' : ''; ?> > @@ -377,7 +377,7 @@ if ($STEP === 1) {