src/Entity/Offer.php line 32

Open in your IDE?
  1. <?php
  2. namespace Slivki\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use JsonSerializable;
  7. use Doctrine\Common\Collections\Criteria;
  8. use Slivki\Entity\Media\GiftCertificatePdfBgMedia;
  9. use Slivki\Entity\Media\OfferAppTeaserMedia;
  10. use Slivki\Entity\Media\OfferDeliveryZoneMedia;
  11. use Slivki\Entity\Media\OfferMailingTeaserMedia;
  12. use Slivki\Entity\Media\OfferMapLogoMedia;
  13. use Slivki\Entity\Media\OfferMobileTeaserMedia;
  14. use Slivki\Entity\Media\OfferTeaserMedia;
  15. use Slivki\Entity\Media\OfferTopBlockMedia;
  16. use Slivki\Entity\Media\OfferTopBlockMobileMedia;
  17. use Slivki\Entity\Media\OnlineOrderPopupLogoMedia;
  18. use Slivki\Enum\Offer\OfferOnlineOrderDevice;
  19. use Slivki\Enum\Offer\OfferOnlineOrderType;
  20. use Slivki\Enum\Offer\OfferStatus;
  21. use Slivki\Enum\Order\PaymentType;
  22. use Slivki\Util\CommonUtil;
  23. use Slivki\Util\Iiko\Dominos;
  24. use function array_key_exists;
  25. use function array_map;
  26. use function in_array;
  27. use function count;
  28. class Offer extends Entity implements JsonSerializable
  29. {
  30.     public const DEFAULT_VIBER '+375295084444';
  31.     public const DEFAULT_TELEGRAM 'slivkislivkiby';
  32.     const TEASER_MEDIA_TYPE "bsns-market-action-teaser-media";
  33.     const TEASER_MEDIA_PATH "/public/znijki-media/initial/default/1009921/";
  34.     const DETAIL_MEDIA_PATH "/public/znijki-media/initial/default/1009921/";
  35.     const SHOP_MEDIA_PATH "/public/znijki-media/initial/default/1009921/";
  36.     const SUPPLIER_MEDIA_PATH "/public/znijki-media/initial/default/1009921/";
  37.     const DESCRIPTION_IMAGES_PATH '/public/ximage/';
  38.     const PETROL_OFFER_ID 142938;
  39.     public const DREAMLAND_OFFER_ID 141563;
  40.     public const DREAMLAND_NEW_OFFER_ID 281797;
  41.     public const WHITE_LOTUS_OFFER_ID 141075;
  42.     public const OBLAKA_SALON_OFFER_ID 139498;
  43.     public const OBLAKA_ULTRASOUND_OFFER_ID 279947;
  44.     public const BLACK_START_BURGER_OFFER_ID 283384;
  45.     public const DOMINOS 168243;
  46.     public const JASMIN_OFFER_ID 247462;
  47.     public const TEST_CERTIFICATE_OFFER_ID 286127;
  48.     const FITNESS_WORLD_OFFER_ID 141207;
  49.     const KFC_OFFER_ID 239232;
  50.     const CAR_SHARING_OFFER_ID 275103;
  51.     const BOOKING_OFFER_ID 275216;
  52.     const SUSHI_HOUSE_OFFER_ID 131201;
  53.     const FREESTYLE_OFFER_ID 137760;
  54.     const HEROPARK_OFFER_ID 142436;
  55.     const TYPE_DEFAULT 0;
  56.     const TYPE_ONLINE_ORDER 1;
  57.     const TYPE_TRIPLE 2;
  58.     const TYPE_ONLINE_ORDER_ONLY 3;
  59.     const TYPE_TIRE 4;
  60.     const TYPE_GIFT_CERTIFICATE 5;
  61.     const TYPE_GIFT_CERTIFICATE_DISABLE_CODE 6;
  62.     const TYPE_DOMINOS 7;
  63.     const TYPE_FREE_PER_DAY 8;
  64.     const BEAUTY_OFFERS = [self::OBLAKA_SALON_OFFER_IDself::OBLAKA_ULTRASOUND_OFFER_ID132400239378245043138907132242138583142192,
  65.         243406135251132690139305141075self::JASMIN_OFFER_IDself::ZHAN_CHAI_OFFER_ID]; // Марсель, Белый лотос.
  66.     const SOSEDI_OFFER_ID 283793;
  67.     const MARSEL_OFFER_ID 141075;
  68.     public const FREESTYLE_CERTIFICATE_OFFER_ID 283213;
  69.     public const FREESTYLE_FLOATING_CERTIFICATE_OFFER_ID 137906;
  70.     public const FREESTYLE_OFFER_IDS = [
  71.         self::FREESTYLE_CERTIFICATE_OFFER_ID,
  72.         self::FREESTYLE_FLOATING_CERTIFICATE_OFFER_ID,
  73.         138755,
  74.         136284,
  75.         296373,
  76.     ];
  77.     public const MINSK_WORLD_CERTIFICATE_OFFER_ID 288763;
  78.     public const FREESTYLE_CERTIFICATE_START_QR_CODES_DATE '2021-03-25';
  79.     public const YANDEX_ALISA_OFFER_ID 290406;
  80.     public const SMART_GOODS_OFFER_ID 290491;
  81.     public const TL24_OFFER_ID 291548;
  82.     public const ROYAL_PLAZA_EVENTS_OFFER_ID 290238;
  83.     public const ROYAL_PLAZA_PSYCHOLOGIST_OFFER_ID 291114;
  84.     public const IZUMI_OFFER_ID 141144;
  85.     public const OUSHEN_OFFER_ID 289105;
  86.     public const OUSHEN2_OFFER_ID 296944;
  87.     public const PLANETA_OFFER_ID 135977;
  88.     public const IDEALMED_OFFER_ID 141086;
  89.     public const PONPUSHKA_OFFER_ID 292879;
  90.     public const MARSEL_MASSAGE_OFFER_ID 140351;
  91.     public const BETERA_OFFER_ID 288763;
  92.     public const BETERA_SALE_NEWS_ID 296012;
  93.     public const ZHAN_CHAI_OFFER_ID 295525;
  94.     public const MEGASUN_OFFER_ID 282591;
  95.     public const MEGASUN_2_OFFER_ID 283587;
  96.     protected $creator;
  97.     protected $title;
  98.     protected ?string $meOnMapName null;
  99.     protected $explanationText;
  100.     protected $regularPrice;
  101.     protected $offerPrice;
  102.     protected $price;
  103.     protected $oldPrice;
  104.     protected $discount;
  105.     protected $activeSince;
  106.     protected $activeTill;
  107.     protected $codeActiveTill;
  108.     protected $active;
  109.     protected $hidden;
  110.     protected $paid;
  111.     protected $free;
  112.     // TODO: null is temporary while cache reloaded
  113.     protected ?bool $withoutCodes;
  114.     protected $showPriceInConditions;
  115.     protected $additionalPercents;
  116.     protected $showAltOffers;
  117.     protected $showCurrencies;
  118.     protected $address;
  119.     protected $searchPosition;
  120.     protected $activeSearchPosition;
  121.     protected $categories;
  122.     protected $medias;
  123.     protected $seo;
  124.     /**
  125.      * @var iterable<EntityDescription>|null
  126.      */
  127.     protected ?iterable $descriptions;
  128.     protected $teaserMedias;
  129.     protected $mobileTeaserMedias;
  130.     protected $appTeaserMedias;
  131.     protected $topBlockMedias;
  132.     protected $topBlockMobileMedias;
  133.     protected $mailingTeaserMedias;
  134.     protected Collection $onlineOrderPopupLogoMedias;
  135.     protected $hotFeedIconMedia;
  136.     protected $detailMeidas;
  137.     protected $shopMedias;
  138.     protected $offerCodePools;
  139.     protected $offerOrders;
  140.     protected ?int $lastCodePoolStartPurchaseCount null;
  141.     protected $usedCodesCount;
  142.     protected $geoLocations;
  143.     protected $phoneNumbers;
  144.     protected $directors;
  145.     protected $directorID;
  146.     protected $captionName;
  147.     protected $captionColor;
  148.     protected $activeCurrencyCalculator;
  149.     protected $bankCurrency;
  150.     protected $bankCurrencyID;
  151.     protected $luceneReindex;
  152.     protected $codeCost;
  153.     protected $codeCostByCount;
  154.     protected $rating;
  155.     protected $lastModified;
  156.     protected $manager;
  157.     protected $defaultCategoryID;
  158.     protected $companyName;
  159.     protected $giftCertificates;
  160.     protected $hint;
  161.     protected $review;
  162.     protected $onReview;
  163.     protected $renewedOn;
  164.     protected $defaultCity;
  165.     protected $teaserLogoWidth;
  166.     protected $teaserLogoHeight;
  167.     protected $hideNoveltyLabel;
  168.     protected $hideBannersInComments;
  169.     protected $extensions;
  170.     protected $sumForFreeDelivery;
  171.     protected $deliveryPrice;
  172.     protected $antitags;
  173.     protected $createdOn;
  174.     protected $allowedBuyOnlyCode;
  175.     protected $buyCodeButtonText;
  176.     protected $buyItemsButtonText;
  177.     protected $freeCodesCount;
  178.     protected $reservedCodesCount;
  179.     protected $shareClick;
  180.     protected $inFreeCategory;
  181.     protected $fakeFreeCodesCount;
  182.     protected $categoriIDs;
  183.     protected $purchaseKoeff;
  184.     protected $giftCertificateOffer;
  185.     protected $supplierPhotoMedias;
  186.     protected $version;
  187.     protected $supplierCategoryData;
  188.     protected $telegramBotShow;
  189.     protected $telegramBotPosition;
  190.     protected $onlineOrderAllowed;
  191.     protected $mobileAppOnlineOrderAllowed;
  192.     protected $buyCodeDisable;
  193.     private $phoneCoverClick;
  194.     private $productFastDelivery;
  195.     private $brandboxEnabled;
  196.     private $offerDeliveryZone;
  197.     private $offerFoodDeliveryZone;
  198.     protected $hideInApp;
  199.     protected ?Collection $onlineOrderSettings;
  200.     protected $giftCertificatePdfBgMedias;
  201.     protected Collection $mapLogoMedias;
  202.     protected Collection $deliveryZoneMedias;
  203.     private $discountDeliveryPopup;
  204.     private $discountPickupPopup;
  205.     private $externalOfferLink;
  206.     private $isShowExternalOfferLink;
  207.     protected $hideFeatures;
  208.     private $deliveryTimeTeaser null;
  209.     private ?\DateTimeImmutable $onlineOrderAllowedRemovedAt null;
  210.     private ?string $regionalCaptionName null;
  211.     private ?string $regionalCaptionColor null;
  212.     private ?string $foodcourtInfoTeaser null;
  213.     private ?string $foodcourtInfoColorTeaser null;
  214.     private bool $isIncludedInBeauty false;
  215.     private bool $qrCodes false;
  216.     private bool $recurrentDisabled false;
  217.     private bool $availableOnFood false;
  218.     private bool $onlineAutoOpened false;
  219.     private bool $foodcourtLogoEnabled false;
  220.     private bool $onlineOrderGiftEnabled false;
  221.     private bool $buyCodeInAppOnly false;
  222.     private bool $showProductsInOfferDescription false;
  223.     private bool $checkAddressInOfferMenu false;
  224.     private bool $showMapIconInApp true;
  225.     private ?array $allowedOnlineOrderTypes null;
  226.     private string $titleFontColor '#000000';
  227.     private bool $separateTabForCertificatesInApp true;
  228.     private ?float $mapPrice null;
  229.     private ?int $mapRating null;
  230.     private ?int $defaultCityId null;
  231.     private ?string $directorName null;
  232.     private ?string $telegram null;
  233.     private ?string $viber null;
  234.     private ?string $messengerCallBack null;
  235.     private ?string $partnerOnlineRegistrationLink null;
  236.     private bool $partnerOnlineRegistrationAllowed false;
  237.     private ?string $yclientAppKey null;
  238.     private ?string $yclientCompanyId null;
  239.     private ?array $allowedPaymentMethodsForCertificate null;
  240.     private bool $festOffer false;
  241.     private bool $useUnusedCodes false;
  242.     public function __construct()
  243.     {
  244.         $this->productFastDelivery = new ArrayCollection();
  245.         $this->offerDeliveryZone = new ArrayCollection();
  246.         $this->offerFoodDeliveryZone = new ArrayCollection();
  247.         $this->categories = new ArrayCollection();
  248.         $this->medias = new ArrayCollection();
  249.         $this->descriptions = new ArrayCollection();
  250.         $this->detailMeidas = [];
  251.         $this->shopMedias = [];
  252.         $this->supplierPhotoMedias = new ArrayCollection();
  253.         $this->offerCodePools = new ArrayCollection();
  254.         $this->geoLocations = new ArrayCollection();
  255.         $this->phoneNumbers = new ArrayCollection();
  256.         $this->directors = new ArrayCollection();
  257.         $this->giftCertificates = new ArrayCollection();
  258.         $this->extensions = new ArrayCollection();
  259.         $this->antitags = new ArrayCollection();
  260.         $this->createdOn = new DateTime();
  261.         $this->renewedOn = new DateTime();
  262.         $this->categoriIDs = [];
  263.         $this->version 0;
  264.         $this->teaserMedias = new ArrayCollection();
  265.         $this->mobileTeaserMedias = new ArrayCollection();
  266.         $this->appTeaserMedias = new ArrayCollection();
  267.         $this->giftCertificatePdfBgMedias = new ArrayCollection();
  268.         $this->mapLogoMedias = new ArrayCollection();
  269.         $this->deliveryZoneMedias = new ArrayCollection();
  270.         $this->mailingTeaserMedias = new ArrayCollection();
  271.         $this->topBlockMedias = new ArrayCollection();
  272.         $this->topBlockMobileMedias = new ArrayCollection();
  273.         $this->onlineOrderPopupLogoMedias = new ArrayCollection();
  274.         $this->onlineOrderSettings = new ArrayCollection();
  275.         $this->rating 0;
  276.     }
  277.     public function getPrice() {
  278.         return $this->price;
  279.     }
  280.     public function setPrice($price) {
  281.         $this->price $price;
  282.     }
  283.     public function getOldPrice() {
  284.         return $this->oldPrice;
  285.     }
  286.     public function setOldPrice($oldPrice) {
  287.         $this->oldPrice $oldPrice;
  288.     }
  289.     /**
  290.      * @return User
  291.      */
  292.     public function getCreator() {
  293.         return $this->creator;
  294.     }
  295.     public function setCreator(User $creator) {
  296.         $this->creator $creator;
  297.     }
  298.     public function getLastModified() {
  299.         return $this->lastModified;
  300.     }
  301.     public function setLastModified($lastModified) {
  302.         $this->lastModified $lastModified;
  303.     }
  304.     public function addCategory(Category $category) {
  305.         if (!$this->categories->contains($category)) {
  306.             $this->categories->add($category);
  307.             if ($category->getID() == Category::NEW_OFFER_CATEGORY_ID) {
  308.                 $this->renewedOn = new \DateTime();
  309.             }
  310.             return true;
  311.         }
  312.         return false;
  313.     }
  314.     public function removeCategory(Category $category) {
  315.         $this->categories->removeElement($category);
  316.     }
  317.     public function hasCategory($categoryID) {
  318.         if ($this->categoriIDs && count($this->categoriIDs) > 0) {
  319.             foreach ($this->categoriIDs as $id) {
  320.                 if ($categoryID == $id) {
  321.                     return true;
  322.                 }
  323.             }
  324.             return false;
  325.         }
  326.         foreach ($this->categories as $categoryItem) {
  327.             if ($categoryID == $categoryItem->getID()) {
  328.                 return true;
  329.             }
  330.         }
  331.         return false;
  332.     }
  333.     public function hasCategoryType($categoryTypeID) {
  334.         foreach ($this->categories as $categoryItem) {
  335.             if ($categoryTypeID == $categoryItem->getTypeID()) {
  336.                 return true;
  337.             }
  338.         }
  339.         return false;
  340.     }
  341.     public function hasNotDefaultCityCategory() {
  342.         foreach ($this->categories as $category) {
  343.             if ($category->getCity() and $category->getCity()->getID() != City::DEFAULT_CITY_ID) {
  344.                 return true;
  345.             }
  346.         }
  347.         return false;
  348.     }
  349.     public function addDescription(EntityDescription $description) {
  350.         if (!$this->descriptions->contains($description)) {
  351.             $this->descriptions->add($description);
  352.         }
  353.     }
  354.     public function getTitle() {
  355.         return $this->title;
  356.     }
  357.     public function setTitle($title) {
  358.         $this->title $title;
  359.     }
  360.     public function getMeOnMapName(): ?string
  361.     {
  362.         return $this->meOnMapName;
  363.     }
  364.     public function setMeOnMapName(?string $meOnMapName): void
  365.     {
  366.         $this->meOnMapName $meOnMapName;
  367.     }
  368.     public function getExplanationText() {
  369.         return $this->explanationText;
  370.     }
  371.     public function setExplanationText($explanationText) {
  372.         $this->explanationText $explanationText;
  373.     }
  374.     public function getRegularPrice() {
  375.         $price $this->regularPrice;
  376.         if ($this->isActiveCurrencyCalculator() && is_numeric($price)) {
  377.             $bankCurrency $this->getBankCurrency();
  378.             $price *= $bankCurrency->getRate();
  379.             $price number_format($price0'.'' ') . ' руб.';
  380.         }
  381.         return $price;
  382.     }
  383.     public function getRawRegularPrice() {
  384.         return $this->regularPrice;
  385.     }
  386.     public function setRegularPrice($regularPrice) {
  387.         $this->regularPrice $regularPrice;
  388.     }
  389.     public function getOfferPrice() {
  390.         $price $this->offerPrice;
  391.         if ($this->isActiveCurrencyCalculator() && is_numeric($price)) {
  392.             $bankCurrency $this->getBankCurrency();
  393.             $price *= $bankCurrency->getRate();
  394.             $price number_format($price0'.'' ') . ' руб.';
  395.         }
  396.         return $price;
  397.     }
  398.     public function getRawOfferPrice() {
  399.         return $this->offerPrice;
  400.     }
  401.     public function setOfferPrice($offerPrice) {
  402.         $this->offerPrice $offerPrice;
  403.     }
  404.     public function getDiscount() {
  405.         return $this->discount;
  406.     }
  407.     public function setDiscount($discount) {
  408.         $this->discount $discount;
  409.     }
  410.     public function getHint() {
  411.         return $this->hint;
  412.     }
  413.     public function setHint($hint) {
  414.         $this->hint $hint;
  415.     }
  416.     public function getDiscountLabelText() {
  417.         if (mb_strlen($this->discount) > && is_numeric(mb_substr($this->discount01))) {
  418.             return '-' $this->discount;
  419.         }
  420.         return $this->discount;
  421.     }
  422.     public function getActiveSince() {
  423.         return $this->activeSince;
  424.     }
  425.     public function setActiveSince($activeSince) {
  426.         $this->activeSince $activeSince;
  427.     }
  428.     /**
  429.      * @return \DateTime
  430.      */
  431.     public function getActiveTill()
  432.     {
  433.         return $this->activeTill;
  434.     }
  435.     public function setActiveTill($activeTill) {
  436.         $this->activeTill $activeTill;
  437.     }
  438.     public function getCodeActiveTill() {
  439.         return $this->codeActiveTill;
  440.     }
  441.     public function setCodeActiveTill($codeActiveTill) {
  442.         $this->codeActiveTill $codeActiveTill;
  443.     }
  444.     public function isActive() {
  445.         return $this->active;
  446.     }
  447.     public function setActive($active) {
  448.         $this->active $active;
  449.     }
  450.     public function isHidden() {
  451.         return $this->hidden;
  452.     }
  453.     public function setHidden($hidden) {
  454.         $this->hidden $hidden;
  455.     }
  456.     public function isPaid() {
  457.         return $this->paid;
  458.     }
  459.     public function setPaid($paid) {
  460.         $this->paid $paid;
  461.     }
  462.     public function isFree() {
  463.         return $this->free;
  464.     }
  465.     public function setFree($free) {
  466.         $this->free $free;
  467.     }
  468.     public function getCaptionName() {
  469.         return $this->captionName;
  470.     }
  471.     public function setCaptionName($captionName) {
  472.         $this->captionName $captionName;
  473.     }
  474.     public function getCaptionColor() {
  475.         return $this->captionColor;
  476.     }
  477.     public function setCaptionColor($captionColor) {
  478.         $this->captionColor $captionColor;
  479.     }
  480.     public function getRegionalCaptionName(): ?string
  481.     {
  482.         return $this->regionalCaptionName;
  483.     }
  484.     public function setRegionalCaptionName(?string $regionalCaptionName): void
  485.     {
  486.         $this->regionalCaptionName $regionalCaptionName;
  487.     }
  488.     public function getRegionalCaptionColor(): ?string
  489.     {
  490.         return $this->regionalCaptionColor;
  491.     }
  492.     public function setRegionalCaptionColor(?string $regionalCaptionColor): void
  493.     {
  494.         $this->regionalCaptionColor $regionalCaptionColor;
  495.     }
  496.     /**
  497.      * @deprecated
  498.      */
  499.     public function isOnlineOrderAllowed() {
  500.         return $this->onlineOrderAllowed;
  501.     }
  502.     public function setOnlineOrderAllowed($onlineOrderAllowed) {
  503.         $this->onlineOrderAllowed $onlineOrderAllowed;
  504.     }
  505.     public function isMobileAppOnlineOrderAllowed() {
  506.         return $this->mobileAppOnlineOrderAllowed;
  507.     }
  508.     public function setMobileAppOnlineOrderAllowed($mobileAppOnlineOrderAllowed) {
  509.         $this->mobileAppOnlineOrderAllowed $mobileAppOnlineOrderAllowed;
  510.     }
  511.     public function getOnlineOrderAllowedRemovedAt(): ?\DateTimeImmutable
  512.     {
  513.         return $this->onlineOrderAllowedRemovedAt;
  514.     }
  515.     public function setOnlineOrderAllowedRemovedAt(?\DateTimeImmutable $onlineOrderAllowedRemovedAt): void
  516.     {
  517.         $this->onlineOrderAllowedRemovedAt $onlineOrderAllowedRemovedAt;
  518.     }
  519.     // TODO: null is temporary while cache reloaded
  520.     public function isWithoutCodes(): ?bool
  521.     {
  522.         return $this->withoutCodes;
  523.     }
  524.     // TODO: null is temporary while cache reloaded
  525.     public function setWithoutCodes(?bool $withoutCodes): void
  526.     {
  527.         $this->withoutCodes = (bool) $withoutCodes;
  528.     }
  529.     public function isShowPriceInConditions() {
  530.         return $this->showPriceInConditions;
  531.     }
  532.     public function setShowPriceInConditions($showPriceInConditions) {
  533.         $this->showPriceInConditions $showPriceInConditions;
  534.     }
  535.     public function isShowAltOffers() {
  536.         return $this->showAltOffers;
  537.     }
  538.     public function setShowAltOffers($showAltOffers) {
  539.         $this->showAltOffers $showAltOffers;
  540.     }
  541.     public function isActiveCurrencyCalculator() {
  542.         return $this->activeCurrencyCalculator;
  543.     }
  544.     public function setActiveCurrencyCalculator($activeCurrencyCalculator) {
  545.         $this->activeCurrencyCalculator $activeCurrencyCalculator;
  546.     }
  547.     public function getBankCurrencyID() {
  548.         return $this->bankCurrencyID;
  549.     }
  550.     public function setBankCurrencyID($bankCurrencyID) {
  551.         $this->bankCurrencyID $bankCurrencyID;
  552.     }
  553.     public function getPartnerOnlineRegistrationLink(): ?string
  554.     {
  555.         return $this->partnerOnlineRegistrationLink;
  556.     }
  557.     public function setPartnerOnlineRegistrationLink(?string $partnerOnlineRegistrationLink): void
  558.     {
  559.         $this->partnerOnlineRegistrationLink $partnerOnlineRegistrationLink;
  560.     }
  561.     public function isPartnerOnlineRegistrationAllowed(): bool
  562.     {
  563.         return $this->partnerOnlineRegistrationAllowed;
  564.     }
  565.     public function setPartnerOnlineRegistrationAllowed(bool $partnerOnlineRegistrationAllowed): void
  566.     {
  567.         $this->partnerOnlineRegistrationAllowed $partnerOnlineRegistrationAllowed;
  568.     }
  569.     public function getOnlineRegistrationLink(): string
  570.     {
  571.         if ($this->partnerOnlineRegistrationAllowed && $this->partnerOnlineRegistrationLink !== null) {
  572.             return $this->partnerOnlineRegistrationLink;
  573.         }
  574.         return '/online-zapis/' $this->ID;
  575.     }
  576.     /**
  577.      * @return BankCurrency
  578.      */
  579.     public function getBankCurrency() {
  580.         return $this->bankCurrency;
  581.     }
  582.     public function setBankCurrency(BankCurrency $bankCurrency null) {
  583.         $this->bankCurrency $bankCurrency;
  584.     }
  585.     public function getAdditionalPercents() {
  586.         return $this->additionalPercents;
  587.     }
  588.     public function setAdditionalPercents($additionalPercents) {
  589.         $this->additionalPercents $additionalPercents;
  590.     }
  591.     public function getShowCurrencies() {
  592.         return $this->showCurrencies;
  593.     }
  594.     public function setShowCurrencies($showCurrencies) {
  595.         $this->showCurrencies $showCurrencies;
  596.     }
  597.     public function getAddress() {
  598.         return $this->address;
  599.     }
  600.     public function setAddress($address) {
  601.         $this->address $address;
  602.     }
  603.     public function getSearchPosition() {
  604.         return $this->searchPosition;
  605.     }
  606.     public function setSearchPosition($searchPosition) {
  607.         $this->searchPosition $searchPosition;
  608.     }
  609.     public function isActiveSearchPosition() {
  610.         return $this->activeSearchPosition;
  611.     }
  612.     public function setActiveSearchPosition($activeCearchPosition) {
  613.         $this->activeSearchPosition $activeCearchPosition;
  614.     }
  615.     public function getGeoLocations() {
  616.         return $this->geoLocations;
  617.     }
  618.     public function setGeoLocation(ArrayCollection $geoLocations) {
  619.         $this->geoLocations $geoLocations;
  620.     }
  621.     public function getGeoLocationById(int $id): ?GeoLocation
  622.     {
  623.         foreach ($this->geoLocations as $geoLocation) {
  624.             if ($id === $geoLocation->getID()) {
  625.                 return $geoLocation;
  626.             }
  627.         }
  628.         return null;
  629.     }
  630.     public function getGeoLocationsSortedByDistanceToLocation($location) {
  631.         if (!is_array($location)) {
  632.             return $this->geoLocations;
  633.         }
  634.         $iterator $this->getGeoLocations()->getIterator();
  635.         $iterator->uasort(function ($geoLocation1$geoLocation2) use ($location) {
  636.             $distance1 CommonUtil::getDistance($location[0], $location[1], $geoLocation1->getLatitude(), $geoLocation1->getLongitude(), 'K');
  637.             $distance2 CommonUtil::getDistance($location[0], $location[1], $geoLocation2->getLatitude(), $geoLocation2->getLongitude(), 'K');
  638.             return $distance1 $distance2 ? -1;
  639.         });
  640.         return new ArrayCollection(iterator_to_array($iterator));
  641.     }
  642.     public function addGeoLocation(GeoLocation $geoLocation) {
  643.         if (!$this->geoLocations->contains($geoLocation)) {
  644.             $this->geoLocations->add($geoLocation);
  645.         }
  646.     }
  647.     public function addProductFastDelivery(ProductFastDelivery $productFastDelivery)
  648.     {
  649.         if (!$this->productFastDelivery->contains($productFastDelivery)) {
  650.             $productFastDelivery->setOffer($this);
  651.             $this->productFastDelivery->add($productFastDelivery);
  652.         }
  653.     }
  654.     public function addOfferDeliveryZone(OfferDeliveryZone $offerDeliveryZone)
  655.     {
  656.         if (!$this->offerDeliveryZone->contains($offerDeliveryZone)) {
  657.             $offerDeliveryZone->setOffer($this);
  658.             $this->offerDeliveryZone->add($offerDeliveryZone);
  659.         }
  660.     }
  661.     public function getProductFastDelivery() {
  662.         return $this->productFastDelivery;
  663.     }
  664.     public function getPhoneNumbers() {
  665.         return $this->phoneNumbers;
  666.     }
  667.     public function setPhoneNumbers(ArrayCollection $phoneNumbers) {
  668.         $this->phoneNumbers $phoneNumbers;
  669.     }
  670.     public function getPhoneNumbersWithoutGeoLocations() {
  671.         $phoneNumberWithLocationIDList = [];
  672.         foreach ($this->getGeoLocations() as $geoLocation) {
  673.             foreach ($geoLocation->getPhoneNumbers() as $phoneNumber) {
  674.                 $phoneNumberWithLocationIDList[] = $phoneNumber->getID();
  675.             }
  676.         }
  677.         $phoneNumbersWithoutGeoLocations = [];
  678.         foreach ($this->phoneNumbers as $phoneNumber) {
  679.             if (!in_array($phoneNumber->getID(), $phoneNumberWithLocationIDList)) {
  680.                 $phoneNumbersWithoutGeoLocations[] = $phoneNumber;
  681.             }
  682.         }
  683.         return $phoneNumbersWithoutGeoLocations;
  684.     }
  685.     public function addPhoneNumber(PhoneNumber $phoneNumber) {
  686.         if (!$this->phoneNumbers->contains($phoneNumber)) {
  687.             $phoneNumber->setOffer($this);
  688.             $this->phoneNumbers->add($phoneNumber);
  689.             return true;
  690.         }
  691.         return false;
  692.     }
  693.     public function removePhoneNumberByID($phoneNumberID) {
  694.         foreach ($this->phoneNumbers as $phoneNumber) {
  695.             if ($phoneNumber->getID() == $phoneNumberID) {
  696.                 $this->phoneNumbers->removeElement($phoneNumber);
  697.                 $phoneNumber->setOffer(null);
  698.             }
  699.         }
  700.     }
  701.     /**
  702.      * @return \Doctrine\Common\Collections\ArrayCollection
  703.      */
  704.     public function getCategories() {
  705.         return $this->categories;
  706.     }
  707.     public function getCategoriesByType($type) {
  708.         $result = new ArrayCollection();
  709.         foreach ($this->categories as $category) {
  710.             if ($category->getTypeID() == $type) {
  711.                 $result->add($category);
  712.             }
  713.         }
  714.         return $result;
  715.     }
  716.     public function getCategoriesByCity($cityID) {
  717.         $categories = new ArrayCollection();
  718.         foreach ($this->categories as $category) {
  719.             if ($category->getCity()->getID() == $cityID) {
  720.                 $categories->add($category);
  721.             }
  722.         }
  723.         return $categories;
  724.     }
  725.     /**
  726.      * @deprecated
  727.      */
  728.     public function setCategories(ArrayCollection $categories) {
  729.         $this->categories $categories;
  730.     }
  731.     /**
  732.      * @return \Doctrine\Common\Collections\ArrayCollection
  733.      */
  734.     public function getMedias() {
  735.         return $this->medias;
  736.     }
  737.     public function setMedias($medias) {
  738.         $this->medias $medias;
  739.     }
  740.     /**
  741.      * @return \Slivki\Entity\Seo
  742.      */
  743.     public function getSeo() {
  744.         return $this->seo;
  745.     }
  746.     public function setSeo(Seo $seo) {
  747.         $seo->setResourceURL("Slivki:Default:details");
  748.         $this->seo $seo;
  749.     }
  750.     public function setDescriptions($descriptions) {
  751.         $this->descriptions $descriptions;
  752.     }
  753.     public function getDescriptions() {
  754.         return $this->descriptions;
  755.     }
  756.     public function getDescriptionByType($descriptionType) {
  757.         /** @var \Slivki\Entity\EntityDescription $description */
  758.         foreach ($this->descriptions as $description) {
  759.             if ($description->getTypeID() == $descriptionType) {
  760.                 return $description->getDescription();
  761.             }
  762.         }
  763.         return "";
  764.     }
  765.     public function getConditions() {
  766.         return $this->getDescriptionByType(EntityDescription::TYPE_OFFER_CONDITIONS_ID);
  767.     }
  768.     public function getFeatures() {
  769.         return $this->getDescriptionByType(EntityDescription::TYPE_OFFER_FEATURES_ID);
  770.     }
  771.     public function getLocation() {
  772.         return $this->getDescriptionByType(EntityDescription::TYPE_OFFER_LOCATION_ID);
  773.     }
  774.     public function getLogo() {
  775.         return $this->getDescriptionByType(EntityDescription::TYPE_OFFER_LOGO_ID);
  776.     }
  777.     public function getLegal() {
  778.         return $this->getDescriptionByType(EntityDescription::TYPE_OFFER_LEGAL_ID);
  779.     }
  780.     public function getDescriptionList(): array
  781.     {
  782.         return array_filter(
  783.             array(...$this->descriptions),
  784.             static fn (EntityDescription $description): bool => EntityDescription::TYPE_OFFER_DESCRIPTION_ID === $description->getTypeID(),
  785.         );
  786.     }
  787.     public function getCommonWorkingHours() {
  788.         return $this->getDescriptionByType(EntityDescription::TYPE_OFFER_WORKING_HOURS_ID);
  789.     }
  790.     public function addTeaserMedia(OfferTeaserMedia $teaserMedia) {
  791.         if (!$this->teaserMedias->contains($teaserMedia)) {
  792.             $this->teaserMedias->add($teaserMedia);
  793.             $teaserMedia->setOffer($this);
  794.         }
  795.     }
  796.     public function getTeaserMedia(): ?OfferTeaserMedia
  797.     {
  798.         return $this->teaserMedias->count() > $this->teaserMedias->first() : null;
  799.     }
  800.     public function getTeaserMedias() {
  801.         return $this->teaserMedias;
  802.     }
  803.     public function setTeaserMedias(ArrayCollection $medias) {
  804.         $this->teaserMedias $medias;
  805.     }
  806.     public function removeTeaserMedia(OfferTeaserMedia $teaserMedia) {
  807.         $this->teaserMedias->removeElement($teaserMedia);
  808.     }
  809.     public function addMobileTeaserMedia(OfferMobileTeaserMedia $mobileTeaserMedia) {
  810.         if (!$this->mobileTeaserMedias->contains($mobileTeaserMedia)) {
  811.             $this->mobileTeaserMedias->add($mobileTeaserMedia);
  812.             $mobileTeaserMedia->setOffer($this);
  813.         }
  814.     }
  815.     /** @return null|OfferMobileTeaserMedia */
  816.     public function getMobileTeaserMedia() {
  817.         return $this->mobileTeaserMedias->first();
  818.     }
  819.     public function getMobileTeaserMedias() {
  820.         return $this->mobileTeaserMedias;
  821.     }
  822.     public function setMobileTeaserMedias(ArrayCollection $medias) {
  823.         $this->mobileTeaserMedias $medias;
  824.     }
  825.     public function removeMobileTeaserMedia(OfferMobileTeaserMedia $mobileTeaserMedia) {
  826.         $this->mobileTeaserMedias->removeElement($mobileTeaserMedia);
  827.     }
  828.     public function addAppTeaserMedia(OfferAppTeaserMedia $appTeaserMedia) {
  829.         if (!$this->appTeaserMedias->contains($appTeaserMedia)) {
  830.             $this->appTeaserMedias->add($appTeaserMedia);
  831.             $appTeaserMedia->setOffer($this);
  832.         }
  833.     }
  834.     public function getAppTeaserMedia(): ?OfferAppTeaserMedia
  835.     {
  836.         return $this->appTeaserMedias->count() > $this->appTeaserMedias->first() : null;
  837.     }
  838.     public function getAppTeaserMedias() {
  839.         return $this->appTeaserMedias;
  840.     }
  841.     public function setAppTeaserMedias(ArrayCollection $medias) {
  842.         $this->appTeaserMedias $medias;
  843.     }
  844.     public function removeAppTeaserMedia(OfferAppTeaserMedia $appTeaserMedia) {
  845.         $this->appTeaserMedias->removeElement($appTeaserMedia);
  846.     }
  847.     public function addGiftCertificatePdfBgMedia(GiftCertificatePdfBgMedia $giftCertificatePdfBgMedia) {
  848.         if (!$this->giftCertificatePdfBgMedias->contains($giftCertificatePdfBgMedia)) {
  849.             $this->giftCertificatePdfBgMedias->add($giftCertificatePdfBgMedia);
  850.             $giftCertificatePdfBgMedia->setOffer($this);
  851.         }
  852.     }
  853.     /** @return null|GiftCertificatePdfBgMedia */
  854.     public function getGiftCertificatePdfBgMedia() {
  855.         return $this->giftCertificatePdfBgMedias->first();
  856.     }
  857.     public function getGiftCertificatePdfBgMedias() {
  858.         return $this->giftCertificatePdfBgMedias;
  859.     }
  860.     public function setGiftCertificatePdfBgMedias(ArrayCollection $medias) {
  861.         $this->giftCertificatePdfBgMedias $medias;
  862.     }
  863.     public function removeGiftCertificatePdfBgMedia(GiftCertificatePdfBgMedia $giftCertificatePdfBgMedia) {
  864.         $this->giftCertificatePdfBgMedias->removeElement($giftCertificatePdfBgMedia);
  865.     }
  866.     public function getOnlineOrderSettings(): ?OnlineOrderSettings
  867.     {
  868.         return $this->onlineOrderSettings->count() > $this->onlineOrderSettings->first() : null;
  869.     }
  870.     public function setOnlineOrderSettings(OnlineOrderSettings $onlineOrderSettings): void
  871.     {
  872.         $onlineOrderSettings->setOffer($this);
  873.         $this->onlineOrderSettings = new ArrayCollection([$onlineOrderSettings]);
  874.     }
  875.     public function getOnlineOrderSettingsJSON(): ?array
  876.     {
  877.         $onlineOrderSettings $this->getOnlineOrderSettings();
  878.         if ($onlineOrderSettings === null) {
  879.             return null;
  880.         }
  881.         return $onlineOrderSettings->jsonSerialize();
  882.     }
  883.     public function addMapLogoMedia(OfferMapLogoMedia $media): void
  884.     {
  885.         if (!$this->mapLogoMedias->contains($media)) {
  886.             $this->mapLogoMedias->add($media);
  887.             $media->setOffer($this);
  888.         }
  889.     }
  890.     public function getMapLogoMedia(): ?OfferMapLogoMedia
  891.     {
  892.         return $this->mapLogoMedias->count() > $this->mapLogoMedias->first() : null;
  893.     }
  894.     public function getMapLogoMedias(): Collection
  895.     {
  896.         return $this->mapLogoMedias;
  897.     }
  898.     public function setMapLogoMedias(ArrayCollection $mapLogoMedias): void
  899.     {
  900.         $this->mapLogoMedias $mapLogoMedias;
  901.     }
  902.     public function removeMapLogoMedia(OfferMapLogoMedia $media): void
  903.     {
  904.         $this->mapLogoMedias->removeElement($media);
  905.     }
  906.     public function addDeliveryZoneMedia(OfferDeliveryZoneMedia $media): void
  907.     {
  908.         if (!$this->deliveryZoneMedias->contains($media)) {
  909.             $this->deliveryZoneMedias->add($media);
  910.             $media->setOffer($this);
  911.         }
  912.     }
  913.     public function getDeliveryZoneMedia(): ?OfferDeliveryZoneMedia
  914.     {
  915.         return $this->deliveryZoneMedias->count() > $this->deliveryZoneMedias->first() : null;
  916.     }
  917.     public function getDeliveryZoneMedias(): Collection
  918.     {
  919.         return $this->deliveryZoneMedias;
  920.     }
  921.     public function setDeliveryZoneMedias(ArrayCollection $deliveryZoneMedias): void
  922.     {
  923.         $this->deliveryZoneMedias $deliveryZoneMedias;
  924.     }
  925.     public function removeDeliveryZoneMedia(OfferDeliveryZoneMedia $media): void
  926.     {
  927.         $this->deliveryZoneMedias->removeElement($media);
  928.     }
  929.     public function addTopBlockMedia(OfferTopBlockMedia $topBlockMedia) {
  930.         if (!$this->topBlockMedias->contains($topBlockMedia)) {
  931.             $this->topBlockMedias->add($topBlockMedia);
  932.             $topBlockMedia->setOffer($this);
  933.         }
  934.     }
  935.     public function getTopBlockMedia(): ?OfferTopBlockMedia
  936.     {
  937.         return $this->topBlockMedias->count() > $this->topBlockMedias->first() : null;
  938.     }
  939.     public function getTopBlockMedias() {
  940.         return $this->topBlockMedias;
  941.     }
  942.     public function setTopBlockMedias(ArrayCollection $medias) {
  943.         $this->topBlockMedias $medias;
  944.     }
  945.     public function removeTopBlockMedia(OfferTopBlockMedia $topBlockMedia) {
  946.         $this->topBlockMedias->removeElement($topBlockMedia);
  947.     }
  948.     public function addTopBlockMobileMedia(OfferTopBlockMobileMedia $topBlockMobileMedia) {
  949.         if (!$this->topBlockMobileMedias->contains($topBlockMobileMedia)) {
  950.             $this->topBlockMobileMedias->add($topBlockMobileMedia);
  951.             $topBlockMobileMedia->setOffer($this);
  952.         }
  953.     }
  954.     public function getTopBlockMobileMedia(): ?OfferTopBlockMobileMedia
  955.     {
  956.         return $this->topBlockMobileMedias->count() > $this->topBlockMobileMedias->first() : null;
  957.     }
  958.     public function getTopBlockMobileMedias() {
  959.         return $this->topBlockMobileMedias;
  960.     }
  961.     public function setTopBlockMobileMedias(ArrayCollection $medias) {
  962.         $this->topBlockMobileMedias $medias;
  963.     }
  964.     public function removeTopBlockMobileMedia(OfferTopBlockMobileMedia $topBlockMobileMedia) {
  965.         $this->topBlockMobileMedias->removeElement($topBlockMobileMedia);
  966.     }
  967.     public function addOnlineOrderPopupLogoMedia(OnlineOrderPopupLogoMedia $onlineOrderPopupLogoMedia): void
  968.     {
  969.         if (!$this->onlineOrderPopupLogoMedias->contains($onlineOrderPopupLogoMedia)) {
  970.             $this->onlineOrderPopupLogoMedias = new ArrayCollection();
  971.             $this->onlineOrderPopupLogoMedias->add($onlineOrderPopupLogoMedia);
  972.             $onlineOrderPopupLogoMedia->setOffer($this);
  973.         }
  974.     }
  975.     public function getOnlineOrderPopupLogoMedia(): ?OnlineOrderPopupLogoMedia
  976.     {
  977.         return false === $this->onlineOrderPopupLogoMedias->first() ? null $this->onlineOrderPopupLogoMedias->first();
  978.     }
  979.     /**
  980.      * @return Collection<OnlineOrderPopupLogoMedia>
  981.      */
  982.     public function getOnlineOrderPopupLogoMedias(): Collection
  983.     {
  984.         return $this->onlineOrderPopupLogoMedias;
  985.     }
  986.     public function setOnlineOrderPopupLogoMedias(ArrayCollection $medias): void
  987.     {
  988.         $this->onlineOrderPopupLogoMedias $medias;
  989.     }
  990.     public function removeOnlineOrderPopupLogoMedia(OnlineOrderPopupLogoMedia $onlineOrderPopupLogoMedia): void
  991.     {
  992.         $this->topBlockMedias->removeElement($onlineOrderPopupLogoMedia);
  993.     }
  994.     public function addMailingTeaserMedia(OfferMailingTeaserMedia $mailingTeaserMedia null) {
  995.         if (!$this->mailingTeaserMedias->contains($mailingTeaserMedia)) {
  996.             $this->mailingTeaserMedias->add($mailingTeaserMedia);
  997.             $mailingTeaserMedia->setOffer($this);
  998.         }
  999.     }
  1000.     /** @return null|OfferMailingTeaserMedia */
  1001.     public function getMailingTeaserMedia() {
  1002.         return $this->mailingTeaserMedias->first();
  1003.     }
  1004.     public function getMailingTeaserMedias() {
  1005.         return $this->mailingTeaserMedias;
  1006.     }
  1007.     public function setMailingTeaserMedias(ArrayCollection $medias) {
  1008.         $this->mailingTeaserMedias $medias;
  1009.     }
  1010.     public function removeMailingTeaserMedia(OfferMailingTeaserMedia $mailingTeaserMedia) {
  1011.         $this->mailingTeaserMedias->removeElement($mailingTeaserMedia);
  1012.     }
  1013.     public function setHotFeedIconMedia(Media $hotFeedIconMedia null) {
  1014.         $this->hotFeedIconMedia $hotFeedIconMedia;
  1015.     }
  1016.     /**
  1017.      * @return null|Media
  1018.      */
  1019.     public function getHotFeedIconMedia() {
  1020.         return $this->hotFeedIconMedia;
  1021.     }
  1022.     public function setDetailMeidas(array $mediaList) {
  1023.         $this->detailMeidas $mediaList;
  1024.     }
  1025.     public function getDetailMedias()
  1026.     {
  1027.         return $this->detailMeidas;
  1028.     }
  1029.     public function setShopMedias(array $mediaList) {
  1030.         $this->shopMedias $mediaList;
  1031.     }
  1032.     public function getShopMedias(): array
  1033.     {
  1034.         return $this->shopMedias ?? [];
  1035.     }
  1036.     public function addShopMedias(Media $media) {
  1037.         if (!$this->shopMedias->contains($media)) {
  1038.             $this->shopMedias->add($media);
  1039.         }
  1040.     }
  1041.     public function setSupplierPhotoMedias(array $mediaList) {
  1042.         $this->supplierPhotoMedias $mediaList;
  1043.     }
  1044.     public function getSupplierPhotoMedias() {
  1045.         return $this->supplierPhotoMedias;
  1046.     }
  1047.     public function getOfferCodePools() {
  1048.         return $this->offerCodePools;
  1049.     }
  1050.     public function setOfferCodePools(ArrayCollection $offerCodePools) {
  1051.         $this->offerCodePools $offerCodePools;
  1052.     }
  1053.     /**
  1054.      * @return bool|OfferCodePool
  1055.      */
  1056.     public function getLastActiveCodePool() {
  1057.         /** @var \Slivki\Entity\OfferCodePool $offerCodePool */
  1058.         foreach ($this->offerCodePools->toArray() as $offerCodePool) {
  1059.             if ($offerCodePool->isActive()) {
  1060.                 return $offerCodePool;
  1061.             }
  1062.         }
  1063.         return false;
  1064.     }
  1065.     public function setCodePool(OfferCodePool $codePool) {
  1066.         if ($this->offerCodePools->count() == 0) {
  1067.             $this->offerCodePools->add($codePool);
  1068.         }
  1069.         foreach ($this->offerCodePools as $key => $pool) {
  1070.             if ($pool->getID() == $codePool->getID()) {
  1071.                 $this->offerCodePools->set($key$codePool);
  1072.             }
  1073.         }
  1074.         $this->usedCodesCount $this->getUsedCodesCount(true);
  1075.         $this->fakeFreeCodesCount $this->getFakeFreeCodesCount(true);
  1076.         $this->freeCodesCount $this->getFreeCodesCount(true);
  1077.         $this->reservedCodesCount $this->getReservedCodesCount(true);
  1078.         $this->setLastCodePoolStartPurchaseCount();
  1079.         $this->lastCodePoolStartPurchaseCount $this->getLastCodePoolStartPurchaseCount();
  1080.     }
  1081.     public function getOfferOrders() {
  1082.         return $this->offerOrders;
  1083.     }
  1084.     public function setOfferOrders(ArrayCollection $offerOrders) {
  1085.         $this->offerOrders $offerOrders;
  1086.     }
  1087.     public function getUsedCodesCount($reload false) {
  1088.         if ($this->usedCodesCount != null && !$reload) {
  1089.             return $this->usedCodesCount;
  1090.         }
  1091.         $lastActiveCodePool $this->getLastActiveCodePool();
  1092.         if (!$lastActiveCodePool) {
  1093.             $this->usedCodesCount 0;
  1094.             return 0;
  1095.         }
  1096.         $usedCodes trim($lastActiveCodePool->getCodesUsed(), "\n");
  1097.         if ($usedCodes == '') {
  1098.             $this->usedCodesCount $lastActiveCodePool->getUsedCodesCountFake();
  1099.             return $this->usedCodesCount;
  1100.         }
  1101.         $this->usedCodesCount count(explode("\n"$usedCodes)) + $lastActiveCodePool->getUsedCodesCountFake();
  1102.         return $this->usedCodesCount;
  1103.     }
  1104.     public function getLastCodePoolStartPurchaseCount(): int
  1105.     {
  1106.         if (null === $this->lastCodePoolStartPurchaseCount) {
  1107.             $this->setLastCodePoolStartPurchaseCount();
  1108.         }
  1109.         return $this->lastCodePoolStartPurchaseCount;
  1110.     }
  1111.     public function setLastCodePoolStartPurchaseCount(): void
  1112.     {
  1113.         $lastActiveCodePool $this->getLastActiveCodePool();
  1114.         if (!$lastActiveCodePool) {
  1115.             $this->lastCodePoolStartPurchaseCount 0;
  1116.             return;
  1117.         }
  1118.         $this->lastCodePoolStartPurchaseCount $lastActiveCodePool->getUsedCodesCountFake();
  1119.     }
  1120.     public function getUsedCodesCountForPastOffer() {
  1121.         $this->usedCodesCount 0;
  1122.         if ($this->offerCodePools->count() > 0) {
  1123.             $codePool $this->offerCodePools->last();
  1124.             if ($codePool) {
  1125.                 $usedCodes trim($codePool->getCodesUsed(), "\n");
  1126.                 if ($usedCodes == '') {
  1127.                     return 0;
  1128.                 }
  1129.                 return count(explode("\n"$usedCodes)) + $codePool->getUsedCodesCountFake();
  1130.             }
  1131.         }
  1132.         return 0;
  1133.     }
  1134.     public function setUsedCodesCount($usedCodesCount) {
  1135.         $this->usedCodesCount $usedCodesCount;
  1136.     }
  1137.     public function getFreeCodesCount($reload false) {
  1138.         if ($this->freeCodesCount != null && !$reload) {
  1139.             return $this->freeCodesCount;
  1140.         }
  1141.         $lastActiveCodePool $this->getLastActiveCodePool();
  1142.         if (!$lastActiveCodePool) {
  1143.             $this->freeCodesCount 0;
  1144.             return 0;
  1145.         }
  1146.         $this->freeCodesCount $lastActiveCodePool->getFreeCodesCount();
  1147.         return $this->freeCodesCount;
  1148.     }
  1149.     public function hasFreeCodes(): bool
  1150.     {
  1151.         return $this->getFreeCodesCount() > 0;
  1152.     }
  1153.     public function getReservedCodesCount($reload false) {
  1154.         if ($this->reservedCodesCount != null && !$reload) {
  1155.             return $this->reservedCodesCount;
  1156.         }
  1157.         $lastActiveCodePool $this->getLastActiveCodePool();
  1158.         if (!$lastActiveCodePool) {
  1159.             $this->reservedCodesCount 0;
  1160.             return 0;
  1161.         }
  1162.         $this->reservedCodesCount $lastActiveCodePool->getReservedCodesCount();
  1163.         return $this->reservedCodesCount;
  1164.     }
  1165.     public function getFakeFreeCodesCount($reload false) {
  1166.         if ($this->fakeFreeCodesCount != null && !$reload) {
  1167.             return $this->fakeFreeCodesCount;
  1168.         }
  1169.         $codePool $this->getLastActiveCodePool();
  1170.         if (!$codePool) {
  1171.             $this->fakeFreeCodesCount 0;
  1172.             return 0;
  1173.         }
  1174.         $this->fakeFreeCodesCount $this->getUsedCodesCount() + $codePool->getFreeCodesCount();
  1175.         return $this->fakeFreeCodesCount;
  1176.     }
  1177.     public function getDirectors() {
  1178.         return $this->directors;
  1179.     }
  1180.     public function findFirstDirector(): ?Director
  1181.     {
  1182.         return $this->directors->first() === false null $this->directors->first();
  1183.     }
  1184.     public function getDirectorID() {
  1185.         if ($this->directorID !== null) {
  1186.             return $this->directorID;
  1187.         }
  1188.         if ($this->directors->count()) {
  1189.             $directorID $this->directors->first()->getID();
  1190.             $this->directorID $directorID;
  1191.             return $directorID;
  1192.         }
  1193.         return null;
  1194.     }
  1195.     public function getCodesCountByUser(User $user) {
  1196.         $criteria Criteria::create()->where(Criteria::expr()->eq("user"$user));
  1197.         $offerOrders $this->offerOrders->matching($criteria);
  1198.         $codesCount 0;
  1199.         /** @var OfferOrder $offerOrder */
  1200.         foreach($offerOrders as $offerOrder) {
  1201.             $offerOrderStatus $offerOrder->getStatus();
  1202.             if ($offerOrderStatus == OfferOrder::STATUS_CONFIRM) {
  1203.                 $codesCount += $offerOrder->getCodesCount();
  1204.             }
  1205.         }
  1206.         return $codesCount;
  1207.     }
  1208.     public function isLuceneReindex() {
  1209.         return $this->luceneReindex;
  1210.     }
  1211.     public function setLuceneReindex($luceneReindex) {
  1212.         $this->luceneReindex $luceneReindex;
  1213.     }
  1214.     public function getCodeCost() {
  1215.         return $this->codeCost;
  1216.     }
  1217.     public function setCodeCost($codeCost) {
  1218.         $this->codeCost $codeCost;
  1219.     }
  1220.     public function getCodeCostByCount() {
  1221.         return $this->codeCostByCount;
  1222.     }
  1223.     public function setCodeCostByCount($codeCostByCount) {
  1224.         $this->codeCostByCount $codeCostByCount;
  1225.     }
  1226.     public function isInFreeCodesCategory() {
  1227.         if ($this->inFreeCategory != null) {
  1228.             return $this->inFreeCategory;
  1229.         }
  1230.         foreach ($this->categories as $category) {
  1231.             if ($category->getID() == Category::FREE_CODES_CATEGORY_ID || $category->getTypeID() == Category::FREE_CATEGORY_TYPE) {
  1232.                 $this->inFreeCategory true;
  1233.                 return true;
  1234.             }
  1235.         }
  1236.         $this->inFreeCategory false;
  1237.         return false;
  1238.     }
  1239.     /**
  1240.      * @return boolean
  1241.      */
  1242.     public function isInActivePeriod() {
  1243.         $activeSince $this->getActiveSince();
  1244.         $activeTill $this->getActiveTill();
  1245.         $timeNow = new \DateTime();
  1246.         if(!$activeSince instanceof \DateTime || !$activeTill instanceof \DateTime) {
  1247.             return false;
  1248.         }
  1249.         return $activeSince <= $timeNow && $activeTill $timeNow;
  1250.     }
  1251.     public function isVisible(): bool
  1252.     {
  1253.         return $this->isActive() && $this->isInActivePeriod() && !$this->isHidden();
  1254.     }
  1255.     /**
  1256.      * @return boolean
  1257.      * @deprecated
  1258.      */
  1259.     public function isInVisiblePeriod() {
  1260.         return !$this->hidden;
  1261.     }
  1262.     public function getRating() {
  1263.         return $this->rating;
  1264.     }
  1265.     public function setRating($rating) {
  1266.         $this->rating $rating;
  1267.     }
  1268.     /**
  1269.      * @return User
  1270.      */
  1271.     public function getManager() {
  1272.         return $this->manager;
  1273.     }
  1274.     public function setManager(User $manager) {
  1275.         $this->manager $manager;
  1276.     }
  1277.     public function getDefaultCategoryID() {
  1278.         return $this->defaultCategoryID;
  1279.     }
  1280.     public function setDefaultCategoryID($categoryID) {
  1281.         $this->defaultCategoryID $categoryID;
  1282.     }
  1283.     public function getCompanyName() {
  1284.         return $this->companyName;
  1285.     }
  1286.     public function setCompanyName($companyName) {
  1287.         $this->companyName $companyName;
  1288.     }
  1289.     public function isTelegramBotShow() {
  1290.         return $this->telegramBotShow;
  1291.     }
  1292.     public function setTelegramBotShow($telegramBotShow) {
  1293.         $this->telegramBotShow $telegramBotShow;
  1294.     }
  1295.     public function getTelegramBotPosition() {
  1296.         return $this->telegramBotPosition;
  1297.     }
  1298.     public function setTelegramBotPosition($telegramBotPosition) {
  1299.         $this->telegramBotPosition $telegramBotPosition;
  1300.     }
  1301.     public function getGiftCertificates() {
  1302.         return $this->giftCertificates;
  1303.     }
  1304.     public function getActiveGiftCertificates() {
  1305.         $criteria Criteria::create()->where(Criteria::expr()->eq('active'true))->andWhere(Criteria::expr()->eq('hidden'false));
  1306.         return $this->giftCertificates->matching($criteria);
  1307.     }
  1308.     public function isGiftCertificateOffer() {
  1309.         if ($this->giftCertificateOffer != null) {
  1310.             return $this->giftCertificateOffer;
  1311.         }
  1312.         $this->giftCertificateOffer $this->getActiveGiftCertificates()->count() > 0;
  1313.         return $this->giftCertificateOffer;
  1314.     }
  1315.     public function setGiftCertificates(Collection $giftCertificates) {
  1316.         $this->giftCertificates $giftCertificates;
  1317.     }
  1318.     public function addGiftCertificate(GiftCertificate $giftCertificate) {
  1319.         if (!$this->giftCertificates->contains($giftCertificate)) {
  1320.             $this->giftCertificates->add($giftCertificate);
  1321.             $giftCertificate->setOffer($this);
  1322.         }
  1323.     }
  1324.     public function isNeedReview() {
  1325.         return $this->review;
  1326.     }
  1327.     public function setNeedReview($review) {
  1328.         $this->review $review;
  1329.     }
  1330.     public function isOnReview() {
  1331.         return $this->onReview;
  1332.     }
  1333.     public function setOnReview($onReview) {
  1334.         $this->onReview $onReview;
  1335.     }
  1336.     public function getRenewedOn() {
  1337.         return $this->renewedOn;
  1338.     }
  1339.     public function setRenewedOn(\DateTime $renewedOn) {
  1340.         $this->renewedOn $renewedOn;
  1341.     }
  1342.     /** @return City */
  1343.     public function getDefaultCity() {
  1344.         return $this->defaultCity;
  1345.     }
  1346.     public function setDefaultCity(City $defaultCity) {
  1347.         $this->defaultCity $defaultCity;
  1348.     }
  1349.     public function getDefaultCityId(): ?int
  1350.     {
  1351.         return $this->defaultCityId;
  1352.     }
  1353.     public function setDefaultCityId(?int $defaultCityId): void
  1354.     {
  1355.         $this->defaultCityId $defaultCityId;
  1356.     }
  1357.     public function getTeaserLogoWidth() {
  1358.         return $this->teaserLogoWidth;
  1359.     }
  1360.     public function setTeaserLogoWidth($teaserLogoWidth) {
  1361.         $this->teaserLogoWidth $teaserLogoWidth;
  1362.     }
  1363.     public function getTeaserLogoHeight() {
  1364.         return $this->teaserLogoHeight;
  1365.     }
  1366.     public function setTeaserLogoHeight($teaserLogoHeight) {
  1367.         $this->teaserLogoHeight $teaserLogoHeight;
  1368.     }
  1369.     public function isHideNoveltyLabel() {
  1370.         return $this->hideNoveltyLabel;
  1371.     }
  1372.     public function setHideNoveltyLabel($hideNoveltyLabel) {
  1373.         $this->hideNoveltyLabel $hideNoveltyLabel;
  1374.     }
  1375.     public function isHideBannersInComments() {
  1376.         return $this->hideBannersInComments;
  1377.     }
  1378.     public function setHideBannersInComments($hideBannersInComments) {
  1379.         $this->hideBannersInComments $hideBannersInComments;
  1380.     }
  1381.     public function getExtensions() {
  1382.         return $this->extensions;
  1383.     }
  1384.     public function setExtensions(ArrayCollection $extensions) {
  1385.         $this->extensions $extensions;
  1386.     }
  1387.     /**
  1388.      * @return FoodOfferExtension[]|ArrayCollection
  1389.      */
  1390.     public function getFoodExtensions() {
  1391.         $foodExtensions = new ArrayCollection();
  1392.         if (!$this->extensions) {
  1393.             return $foodExtensions;
  1394.         }
  1395.         foreach ($this->extensions as $extension) {
  1396.             if ($extension instanceof FoodOfferExtension && !$extension instanceof FoodOfferOptionExtension) {
  1397.                 $foodExtensions->add($extension);
  1398.             }
  1399.         }
  1400.         return $foodExtensions;
  1401.     }
  1402.     public function getTireExtensions() {
  1403.         $tireExtensions = new ArrayCollection();
  1404.         foreach ($this->extensions as $extension) {
  1405.             if ($extension instanceof TireOfferExtension) {
  1406.                 $tireExtensions->add($extension);
  1407.             }
  1408.         }
  1409.         return $tireExtensions;
  1410.     }
  1411.     public function getFoodOptionExtensions() {
  1412.         $foodOptionExtensions = new ArrayCollection();
  1413.         foreach ($this->extensions as $extension) {
  1414.             if ($extension instanceof FoodOfferOptionExtension) {
  1415.                 $foodOptionExtensions->add($extension);
  1416.             }
  1417.         }
  1418.         return $foodOptionExtensions;
  1419.     }
  1420.     public function getItems() {
  1421.         $items = new ArrayCollection();
  1422.         if (!$this->extensions) {
  1423.             return $items;
  1424.         }
  1425.         foreach ($this->extensions as $extension) {
  1426.             if ($extension instanceof ItemOfferExtension) {
  1427.                 $items->add($extension);
  1428.             }
  1429.         }
  1430.         return $items;
  1431.     }
  1432.     public function addExtension(OfferExtension $extension) {
  1433.         if (!$this->extensions->contains($extension)) {
  1434.             $this->extensions->add($extension);
  1435.             $extension->setOffer($this);
  1436.         }
  1437.     }
  1438.     public function getSumForFreeDelivery() {
  1439.         return $this->sumForFreeDelivery;
  1440.     }
  1441.     public function setSumForFreeDelivery($sumForFreeDelivery) {
  1442.         $this->sumForFreeDelivery $sumForFreeDelivery;
  1443.     }
  1444.     public function getDeliveryPrice() {
  1445.         return $this->deliveryPrice;
  1446.     }
  1447.     public function setDeliveryPrice($deliveryPrice) {
  1448.         $this->deliveryPrice $deliveryPrice;
  1449.     }
  1450.     /**
  1451.      * @return ArrayCollection
  1452.      */
  1453.     public function getAntiTags() {
  1454.         return $this->antitags;
  1455.     }
  1456.     public function addAntiTag(AntiTag $antitag) {
  1457.         if (!$this->antitags->contains($antitag)) {
  1458.             $antitag->addOffer($this);
  1459.             $this->antitags->add($antitag);
  1460.         }
  1461.     }
  1462.     public function deleteAntiTag(AntiTag $antitag) {
  1463.         $this->antitags->removeElement($antitag);
  1464.     }
  1465.     public function hasAntiTag(AntiTag $antitag) {
  1466.         return $this->antitags->contains($antitag);
  1467.     }
  1468.     public function getCreatedOn() {
  1469.         return $this->createdOn;
  1470.     }
  1471.     public function setCreatedOn($createdOn) {
  1472.         $this->createdOn $createdOn;
  1473.     }
  1474.     public function isAllowedBuyOnlyCode() {
  1475.         return $this->allowedBuyOnlyCode;
  1476.     }
  1477.     public function setAllowedBuyOnlyCode($allowedBuyOnlyCode) {
  1478.         $this->allowedBuyOnlyCode $allowedBuyOnlyCode;
  1479.     }
  1480.     public function getBuyCodeButtonText() {
  1481.         return $this->buyCodeButtonText;
  1482.     }
  1483.     public function setBuyCodeButtonText($buyCodeButtonText) {
  1484.         $this->buyCodeButtonText $buyCodeButtonText;
  1485.     }
  1486.     public function getBuyItemsButtonText() {
  1487.         return $this->buyItemsButtonText;
  1488.     }
  1489.     public function setBuyItemsButtonText($buyItemsButtonText) {
  1490.         $this->buyItemsButtonText $buyItemsButtonText;
  1491.     }
  1492.     public function setShareClick($shareClick) {
  1493.         $this->shareClick $shareClick;
  1494.     }
  1495.     public function getShareClick() {
  1496.         return $this->shareClick;
  1497.     }
  1498.     public function getOfferDeliveryZone(): ?Collection
  1499.     {
  1500.         return $this->offerDeliveryZone;
  1501.     }
  1502.     public function getPurchaseKoeff() {
  1503.         return $this->purchaseKoeff;
  1504.     }
  1505.     public function setPurchaseKoeff($purchaseKoeff) {
  1506.         $this->purchaseKoeff $purchaseKoeff;
  1507.     }
  1508.     public function getVersion() {
  1509.         return $this->version;
  1510.     }
  1511.     public function setVersion($version) {
  1512.         $this->version $version;
  1513.     }
  1514.     public function getSupplierCategoryData() {
  1515.         return $this->supplierCategoryData;
  1516.     }
  1517.     public function setSupplierCategoryData($supplierCategoryData) {
  1518.         $this->supplierCategoryData $supplierCategoryData;
  1519.     }
  1520.     public function isQrCodes(): bool
  1521.     {
  1522.         return $this->qrCodes;
  1523.     }
  1524.     public function setQrCodes(bool $qrCodes): void
  1525.     {
  1526.         $this->qrCodes $qrCodes;
  1527.     }
  1528.     public function isRecurrentDisabled(): bool
  1529.     {
  1530.         return $this->recurrentDisabled;
  1531.     }
  1532.     public function setRecurrentDisabled(bool $recurrentDisabled): void
  1533.     {
  1534.         $this->recurrentDisabled $recurrentDisabled;
  1535.     }
  1536.     public function isAvailableOnFood(): bool
  1537.     {
  1538.         return $this->availableOnFood;
  1539.     }
  1540.     public function setAvailableOnFood(bool $availableOnFood): void
  1541.     {
  1542.         $this->availableOnFood $availableOnFood;
  1543.     }
  1544.     public function getAllowedOnlineOrderTypes(): ?array
  1545.     {
  1546.         return $this->allowedOnlineOrderTypes;
  1547.     }
  1548.     public function setAllowedOnlineOrderTypes(?array $allowedOnlineOrderTypes): void
  1549.     {
  1550.         $this->allowedOnlineOrderTypes $allowedOnlineOrderTypes;
  1551.     }
  1552.     public function getTitleFontColor(): string
  1553.     {
  1554.         return $this->titleFontColor;
  1555.     }
  1556.     public function setTitleFontColor(string $titleFontColor): void
  1557.     {
  1558.         $this->titleFontColor $titleFontColor;
  1559.     }
  1560.     public function getCategoriesIds(): array
  1561.     {
  1562.         $categoryIds = [];
  1563.         foreach ($this->categories as $category) {
  1564.             $categoryIds[] = $category->getID();
  1565.         }
  1566.         return $categoryIds;
  1567.     }
  1568.     public function jsonSerialize(): array
  1569.     {
  1570.         $categoryIDs = [];
  1571.         foreach ($this->categories as $category) {
  1572.             $categoryIDs[] = $category->getID();
  1573.         }
  1574.         return [
  1575.             'ID' => $this->ID,
  1576.             'title' => $this->title,
  1577.             'defaultCityId' => $this->getDefaultCity() !== null $this->getDefaultCity()->getID(): $this->defaultCityId,
  1578.             'meOnMapName' => $this->meOnMapName,
  1579.             'explanationText' => $this->explanationText,
  1580.             'active' => $this->active,
  1581.             'hidden' => $this->hidden,
  1582.             'discount' => $this->discount,
  1583.             'regularPrice' => $this->regularPrice,
  1584.             'offerPrice' => $this->offerPrice,
  1585.             'address' => $this->address,
  1586.             'codeCost' => $this->codeCost,
  1587.             'codeCostByCount' => $this->codeCostByCount,
  1588.             'additionalPercents' => $this->additionalPercents,
  1589.             'showPriceInConditions' => $this->showPriceInConditions,
  1590.             'showAltOffers' => $this->showAltOffers,
  1591.             'free' => $this->free,
  1592.             'captionName' => $this->captionName,
  1593.             'captionColor' => $this->captionColor,
  1594.             'titleFontColor' => $this->titleFontColor,
  1595.             'regionalCaptionName' => $this->regionalCaptionName,
  1596.             'regionalCaptionColor' => $this->regionalCaptionColor,
  1597.             'withoutCodes' => $this->withoutCodes,
  1598.             'activeCurrencyCalculator' => $this->activeCurrencyCalculator,
  1599.             'bankCurrencyID' => $this->bankCurrencyID,
  1600.             'rawRegularPrice' => $this->getRawRegularPrice(),
  1601.             'rawOfferPrice' => $this->getRawOfferPrice(),
  1602.             'activeSearchPosition' => $this->activeSearchPosition,
  1603.             'searchPosition' => $this->searchPosition,
  1604.             'defaultCategoryID' => $this->defaultCategoryID,
  1605.             'companyName' => $this->companyName,
  1606.             'hint' => $this->hint ?: '',
  1607.             'price' => $this->price,
  1608.             'oldPrice' => $this->oldPrice,
  1609.             'teaserLogoWidth' => $this->teaserLogoWidth,
  1610.             'teaserLogoHeight' => $this->teaserLogoHeight,
  1611.             'hideNoveltyLabel' => $this->hideNoveltyLabel,
  1612.             'hideBannersInComments' => $this->hideBannersInComments,
  1613.             'onlineOrderAllowed' => $this->onlineOrderAllowed,
  1614.             'mobileAppOnlineOrderAllowed' => $this->mobileAppOnlineOrderAllowed,
  1615.             'buyCodeDisable' => $this->buyCodeDisable,
  1616.             'hideInApp' => $this->hideInApp,
  1617.             'brandboxEnabled' => $this->brandboxEnabled,
  1618.             'allowedBuyOnlyCode' => $this->allowedBuyOnlyCode,
  1619.             'buyCodeButtonText' => $this->buyCodeButtonText,
  1620.             'buyItemsButtonText' => $this->buyItemsButtonText,
  1621.             'activeSince' => $this->activeSince,
  1622.             'activeTill' => $this->activeTill,
  1623.             'freeCodesCount' => $this->getFreeCodesCount(),
  1624.             'reservedCodesCount' => $this->getReservedCodesCount(),
  1625.             'inFreeCategory' => $this->isInFreeCodesCategory(),
  1626.             'bankCurrency' => $this->bankCurrency,
  1627.             'codeActiveTill' => $this->codeActiveTill,
  1628.             'usedCodesCount' => $this->getUsedCodesCount(),
  1629.             'fakeFreeCodesCount' => $this->getFakeFreeCodesCount(),
  1630.             'lastCodePoolStartPurchaseCount' => $this->getLastCodePoolStartPurchaseCount(),
  1631.             'categoryIDs' => $categoryIDs,
  1632.             'purchaseKoeff' => $this->purchaseKoeff,
  1633.             'giftCertificateOffer' => $this->isGiftCertificateOffer(),
  1634.             'supplierCategoryData' => $this->supplierCategoryData,
  1635.             'telegramBotShow' => $this->telegramBotShow,
  1636.             'discountDeliveryPopup' => $this->getDiscountDeliveryPopup(),
  1637.             'discountPickupPopup' => $this->getDiscountPickupPopup(),
  1638.             'deliveryTimeTeaser' => $this->getDeliveryTimeTeaser(),
  1639.             'foodcourtInfoTeaser' => $this->getFoodcourtInfoTeaser(),
  1640.             'foodcourtInfoColorTeaser' => $this->getFoodcourtInfoColorTeaser(),
  1641.             'externalOfferLink' => $this->getExternalOfferLink(),
  1642.             'isShowExternalOfferLink' => $this->getIsShowExternalOfferLink(),
  1643.             'hideFeatures' => $this->hideFeatures,
  1644.             'isIncludedInBeauty' => $this->isIncludedInBeauty,
  1645.             'qrCodes' =>  $this->qrCodes,
  1646.             'recurrentDisabled' => $this->recurrentDisabled,
  1647.             'availableOnFood' => $this->availableOnFood,
  1648.             'onlineAutoOpened' => $this->onlineAutoOpened,
  1649.             'foodcourtLogoEnabled' => $this->foodcourtLogoEnabled,
  1650.             'onlineOrderGiftEnabled' => $this->onlineOrderGiftEnabled,
  1651.             'onlineOrderSettings' => $this->getOnlineOrderSettingsJSON(),
  1652.             'directorID' => $this->getDirectorID(),
  1653.             'rating' => $this->rating,
  1654.             'buyCodeInAppOnly' => $this->buyCodeInAppOnly,
  1655.             'allowedOnlineOrderTypes' => $this->allowedOnlineOrderTypes,
  1656.             'showProductsInOfferDescription' => $this->showProductsInOfferDescription,
  1657.             'separateTabForCertificatesInApp' => $this->separateTabForCertificatesInApp,
  1658.             'checkAddressInOfferMenu' => $this->checkAddressInOfferMenu,
  1659.             'showMapIconInApp' => $this->showMapIconInApp,
  1660.             'telegram' => $this->telegram,
  1661.             'viber' => $this->viber,
  1662.             'messengerCallBack' => $this->messengerCallBack,
  1663.             'partnerOnlineRegistrationLink' => $this->partnerOnlineRegistrationLink,
  1664.             'partnerOnlineRegistrationAllowed' => $this->partnerOnlineRegistrationAllowed,
  1665.             'yclientAppKey' => $this->yclientAppKey,
  1666.             'yclientCompanyId' => $this->yclientCompanyId,
  1667.             'allowedPaymentMethodsForCertificate' => $this->allowedPaymentMethodsForCertificate,
  1668.             'festOffer' => $this->festOffer,
  1669.             'useUnusedCodes' => $this->useUnusedCodes,
  1670.         ];
  1671.     }
  1672.     public function fromJSON($data)
  1673.     {
  1674.         $this->freeCodesCount $data->freeCodesCount;
  1675.         $this->reservedCodesCount $data->reservedCodesCount;
  1676.         $this->lastCodePoolStartPurchaseCount $data->lastCodePoolStartPurchaseCount ?? 0;
  1677.         $this->usedCodesCount $data->usedCodesCount;
  1678.         $this->fakeFreeCodesCount $data->fakeFreeCodesCount;
  1679.         $this->inFreeCategory $data->inFreeCategory;
  1680.         $this->activeSince = new \DateTime($data->activeSince->date);
  1681.         $this->activeTill = new \DateTime($data->activeTill->date);
  1682.         $this->codeActiveTill = new \DateTime($data->codeActiveTill->date);
  1683.         if (isset($data->festOffer)) {
  1684.             $this->festOffer $data->festOffer;
  1685.         }
  1686.         if (isset($data->categoryIDs)) {
  1687.             $this->categoriIDs $data->categoryIDs;
  1688.         }
  1689.         if (isset($data->giftCertificateOffer)) {
  1690.             $this->giftCertificateOffer $data->giftCertificateOffer;
  1691.         }
  1692.         if (isset($data->bankCurrency) && isset($data->bankCurrency->ID)) {
  1693.             $bankCurrency = new BankCurrency();
  1694.             $bankCurrency->setID($data->bankCurrency->ID);
  1695.             $bankCurrency->setRate($data->bankCurrency->rate);
  1696.             $bankCurrency->setCurrency($data->bankCurrency->currency);
  1697.             $bankCurrency->setSign($data->bankCurrency->sign);
  1698.             $this->bankCurrency $bankCurrency;
  1699.         }
  1700.         if (isset($data->useUnusedCodes)) {
  1701.             $this->useUnusedCodes $data->useUnusedCodes;
  1702.         }
  1703.         if (isset($data->onlineOrderSettings) && isset($data->onlineOrderSettings->ID)) {
  1704.             $onlineOrderSettings = new OnlineOrderSettings();
  1705.             $onlineOrderSettings->setID($data->onlineOrderSettings->ID);
  1706.             $onlineOrderSettings->setMinDeliverySum($data->onlineOrderSettings->minDeliverySum);
  1707.             $onlineOrderSettings->setMinSumForFreeDelivery($data->onlineOrderSettings->minSumForFreeDelivery);
  1708.             $onlineOrderSettings->setDeliveryPrice($data->onlineOrderSettings->deliveryPrice);
  1709.             $onlineOrderSettings->setPickupEnabled($data->onlineOrderSettings->pickupEnabled);
  1710.             $onlineOrderSettings->setDeliveryEnabled($data->onlineOrderSettings->deliveryEnabled);
  1711.             $onlineOrderSettings->setAllowedPaymentMethods($data->onlineOrderSettings->allowedPaymentMethods);
  1712.             $onlineOrderSettings->setOrderPeriodInDays($data->onlineOrderSettings->orderPeriodInDays);
  1713.             $onlineOrderSettings->setPickupDiscountPercent($data->onlineOrderSettings->pickupDiscountPercent);
  1714.             $onlineOrderSettings->setEmail($data->onlineOrderSettings->email);
  1715.             $onlineOrderSettings->setSplitPayment($data->onlineOrderSettings->splitPayment);
  1716.             $onlineOrderSettings->setDomain($data->onlineOrderSettings->domain);
  1717.             $onlineOrderSettings->setSchedule($data->onlineOrderSettings->schedule);
  1718.             $onlineOrderSettings->setDeliveryTimeFrom($data->onlineOrderSettings->deliveryTimeFrom);
  1719.             $onlineOrderSettings->setDeliveryTimeTill($data->onlineOrderSettings->deliveryTimeTill);
  1720.             $onlineOrderSettings->setDeliverySchedule($data->onlineOrderSettings->deliverySchedule);
  1721.             $onlineOrderSettings->setDeliveryLeadType($data->onlineOrderSettings->deliveryLeadType);
  1722.             $onlineOrderSettings->setDeliveryLeadTime($data->onlineOrderSettings->deliveryLeadTime);
  1723.             $onlineOrderSettings->setDeliveryIntervalBetweenOrdersType($data->onlineOrderSettings->deliveryIntervalBetweenOrdersType);
  1724.             $onlineOrderSettings->setDeliveryIntervalBetweenOrdersTime($data->onlineOrderSettings->deliveryIntervalBetweenOrdersTime);
  1725.             $onlineOrderSettings->setDeliveryDisableType($data->onlineOrderSettings->deliveryDisableType);
  1726.             $onlineOrderSettings->setDeliveryDisableTime($data->onlineOrderSettings->deliveryDisableTime);
  1727.             $onlineOrderSettings->setDeliveryNearlyEnabled($data->onlineOrderSettings->deliveryNearlyEnabled);
  1728.             $onlineOrderSettings->setDeliveryPriceInfo($data->onlineOrderSettings->deliveryPriceInfo ?? null);
  1729.             $onlineOrderSettings->setDeliveryWorkingTime($data->onlineOrderSettings->deliveryWorkingTime ?? null);
  1730.             $onlineOrderSettings->setPickupCookingTime($data->onlineOrderSettings->pickupCookingTime ?? null);
  1731.             $onlineOrderSettings->setPickupLeadTime($data->onlineOrderSettings->pickupLeadTime ?? null);
  1732.             $onlineOrderSettings->setPriceCodeDependsOnOrder($data->onlineOrderSettings->priceCodeDependsOnOrder ?? null);
  1733.             $this->setOnlineOrderSettings($onlineOrderSettings);
  1734.         }
  1735.         if (isset($data->directorID)) {
  1736.             $this->directorID $data->directorID;
  1737.         }
  1738.     }
  1739.     public function isBuyCodeDisable() {
  1740.         return $this->buyCodeDisable;
  1741.     }
  1742.     public function setBuyCodeDisable($buyCodeDisable) {
  1743.         $this->buyCodeDisable $buyCodeDisable;
  1744.     }
  1745.     public function isHideInApp() {
  1746.         return $this->hideInApp;
  1747.     }
  1748.     public function setHideInApp($hideInApp) {
  1749.         $this->hideInApp $hideInApp;
  1750.     }
  1751.     public function getBrandboxEnabled() {
  1752.         return $this->brandboxEnabled;
  1753.     }
  1754.     public function setBrandboxEnabled($brandboxEnabled): void {
  1755.         $this->brandboxEnabled $brandboxEnabled;
  1756.     }
  1757.     public function getDiscountPickupPopup(): ?string
  1758.     {
  1759.         return $this->discountPickupPopup;
  1760.     }
  1761.     public function setDiscountPickupPopup(?string $discountPickupPopup): void
  1762.     {
  1763.         $this->discountPickupPopup $discountPickupPopup;
  1764.     }
  1765.     public function getExternalOfferLink(): ?string
  1766.     {
  1767.         return $this->externalOfferLink;
  1768.     }
  1769.     public function setExternalOfferLink(?string $externalOfferLink): void
  1770.     {
  1771.         $this->externalOfferLink $externalOfferLink;
  1772.     }
  1773.     public function getIsShowExternalOfferLink()
  1774.     {
  1775.         return $this->isShowExternalOfferLink;
  1776.     }
  1777.     public function setIsShowExternalOfferLink($isShowExternalOfferLink): void
  1778.     {
  1779.         $this->isShowExternalOfferLink $isShowExternalOfferLink;
  1780.     }
  1781.     public function getDiscountDeliveryPopup(): ?string
  1782.     {
  1783.         return $this->discountDeliveryPopup;
  1784.     }
  1785.     public function setDiscountDeliveryPopup(?string $discountDeliveryPopup): void
  1786.     {
  1787.         $this->discountDeliveryPopup $discountDeliveryPopup;
  1788.     }
  1789.     public function isFoodOnlineOrderAllowedOnSite(): bool
  1790.     {
  1791.         return $this->isOnlineOrderAllowedByDeviceAndType(
  1792.             OfferOnlineOrderDevice::byValue(OfferOnlineOrderDevice::SITE),
  1793.             OfferOnlineOrderType::byValue(OfferOnlineOrderType::FOOD)
  1794.         );
  1795.     }
  1796.     public function isFoodOnlineOrderAllowedOnApp(): bool
  1797.     {
  1798.         return $this->isOnlineOrderAllowedByDeviceAndType(
  1799.             OfferOnlineOrderDevice::byValue(OfferOnlineOrderDevice::APP),
  1800.             OfferOnlineOrderType::byValue(OfferOnlineOrderType::FOOD)
  1801.         );
  1802.     }
  1803.     public function isGiftCertificateOnlineOrderAllowedOnSite(): bool
  1804.     {
  1805.         return $this->isOnlineOrderAllowedByDeviceAndType(
  1806.             OfferOnlineOrderDevice::byValue(OfferOnlineOrderDevice::SITE),
  1807.             OfferOnlineOrderType::byValue(OfferOnlineOrderType::GIFT_CERTIFICATE)
  1808.         );
  1809.     }
  1810.     public function isGiftCertificateOnlineOrderAllowedOnApp(): bool
  1811.     {
  1812.         return $this->isOnlineOrderAllowedByDeviceAndType(
  1813.             OfferOnlineOrderDevice::byValue(OfferOnlineOrderDevice::APP),
  1814.             OfferOnlineOrderType::byValue(OfferOnlineOrderType::GIFT_CERTIFICATE)
  1815.         );
  1816.     }
  1817.     public function isTireOnlineOrderAllowedOnSite(): bool
  1818.     {
  1819.         return $this->isOnlineOrderAllowedByDeviceAndType(
  1820.             OfferOnlineOrderDevice::byValue(OfferOnlineOrderDevice::SITE),
  1821.             OfferOnlineOrderType::byValue(OfferOnlineOrderType::TIRE)
  1822.         );
  1823.     }
  1824.     public function isTireOnlineOrderAllowedOnApp(): bool
  1825.     {
  1826.         return $this->isOnlineOrderAllowedByDeviceAndType(
  1827.             OfferOnlineOrderDevice::byValue(OfferOnlineOrderDevice::APP),
  1828.             OfferOnlineOrderType::byValue(OfferOnlineOrderType::TIRE)
  1829.         );
  1830.     }
  1831.     public function isOneOfOnlineOrderAllowedOnApp(): bool
  1832.     {
  1833.         if (null === $this->allowedOnlineOrderTypes) {
  1834.             return false;
  1835.         }
  1836.         return \count($this->allowedOnlineOrderTypes[OfferOnlineOrderDevice::APP]) > 0;
  1837.     }
  1838.     public function isOneOfOnlineOrderAllowedOnSite(): bool
  1839.     {
  1840.         if (null === $this->allowedOnlineOrderTypes) {
  1841.             return false;
  1842.         }
  1843.         return \count($this->allowedOnlineOrderTypes[OfferOnlineOrderDevice::SITE]) > 0;
  1844.     }
  1845.     public function getAllowedOnlineOrderTypesOnApp(): ?array
  1846.     {
  1847.         if (null === $this->allowedOnlineOrderTypes || === count($this->allowedOnlineOrderTypes[OfferOnlineOrderDevice::APP])) {
  1848.             return null;
  1849.         }
  1850.         return $this->allowedOnlineOrderTypes[OfferOnlineOrderDevice::APP];
  1851.     }
  1852.     private function isOnlineOrderAllowedByDeviceAndType(OfferOnlineOrderDevice $deviceOfferOnlineOrderType $type): bool
  1853.     {
  1854.         if (null === $this->allowedOnlineOrderTypes) {
  1855.             return false;
  1856.         }
  1857.         return in_array($type->getValue(), $this->allowedOnlineOrderTypes[$device->getValue()], true);
  1858.     }
  1859.     public function getOfferType(bool $isBoughtFreeCode false): int
  1860.     {
  1861.         $offerType self::TYPE_DEFAULT;
  1862.         if (in_array($this->getID(), Dominos::OFFER_IDS_MINSK_AND_REGIONStrue)) {
  1863.             return self::TYPE_DOMINOS;
  1864.         }
  1865.         if ($this->isFoodOnlineOrderAllowedOnApp()) {
  1866.             return $this->isBuyCodeDisable() ? self::TYPE_ONLINE_ORDER_ONLY self::TYPE_ONLINE_ORDER;
  1867.         }
  1868.         if ($this->isGiftCertificateOnlineOrderAllowedOnApp()) {
  1869.             return $this->isBuyCodeDisable() ? self::TYPE_GIFT_CERTIFICATE_DISABLE_CODE self::TYPE_GIFT_CERTIFICATE;
  1870.         }
  1871.         if ($this->getID() === self::PETROL_OFFER_ID) {
  1872.             return self::TYPE_TRIPLE;
  1873.         }
  1874.         if ($this->getTireExtensions()->count() > 0) {
  1875.             return self::TYPE_TIRE;
  1876.         }
  1877.         if (!$isBoughtFreeCode && ($this->isInFreeCodesCategory() || $this->isFree())) {
  1878.             return self::TYPE_FREE_PER_DAY;
  1879.         }
  1880.         return $offerType;
  1881.     }
  1882.     public function isHideFeatures() {
  1883.         return $this->hideFeatures;
  1884.     }
  1885.     public function setHideFeatures($hideFeatures) {
  1886.         $this->hideFeatures $hideFeatures;
  1887.     }
  1888.     public function getFirstGeoLocation(): GeoLocation
  1889.     {
  1890.         return $this->geoLocations->first();
  1891.     }
  1892.     public function getDeliveryTimeTeaser(): ?string
  1893.     {
  1894.         return $this->deliveryTimeTeaser;
  1895.     }
  1896.     public function setDeliveryTimeTeaser(?string $deliveryTimeTeaser): void
  1897.     {
  1898.         $this->deliveryTimeTeaser $deliveryTimeTeaser;
  1899.     }
  1900.     public function isExternalOfferLinkAndShow(): bool
  1901.     {
  1902.         return null !== $this->externalOfferLink && $this->isShowExternalOfferLink;
  1903.     }
  1904.     public function isNotAccess(): bool
  1905.     {
  1906.         return !$this->isActive() || $this->isHidden() || !$this->isInActivePeriod() || $this->isBuyCodeDisable();
  1907.     }
  1908.     public function getFoodcourtInfoTeaser(): ?string
  1909.     {
  1910.         return $this->foodcourtInfoTeaser;
  1911.     }
  1912.     public function setFoodcourtInfoTeaser(?string $foodcourtInfoTeaser): void
  1913.     {
  1914.         $this->foodcourtInfoTeaser $foodcourtInfoTeaser;
  1915.     }
  1916.     public function getFoodcourtInfoColorTeaser(): ?string
  1917.     {
  1918.         return $this->foodcourtInfoColorTeaser;
  1919.     }
  1920.     public function setFoodcourtInfoColorTeaser(?string $foodcourtInfoColorTeaser): void
  1921.     {
  1922.         $this->foodcourtInfoColorTeaser $foodcourtInfoColorTeaser;
  1923.     }
  1924.     public function isIncludedInBeauty(): bool
  1925.     {
  1926.         return $this->isIncludedInBeauty;
  1927.     }
  1928.     public function setIsIncludedInBeauty(bool $isIncludedInBeauty): void
  1929.     {
  1930.         $this->isIncludedInBeauty $isIncludedInBeauty;
  1931.     }
  1932.     public function getStatus(): OfferStatus
  1933.     {
  1934.         return $this->isVisible() ? OfferStatus::byValue(OfferStatus::ACTIVATED) : OfferStatus::byValue(OfferStatus::DEACTIVATED);
  1935.     }
  1936.     public function getCity(): ?City
  1937.     {
  1938.         foreach ($this->categories as $category) {
  1939.             if ($category->getID() === $this->getDefaultCategoryID()) {
  1940.                 return $category->getCity();
  1941.             }
  1942.         }
  1943.         $category $this->categories->first();
  1944.         return false === $category null $category->getCity();
  1945.     }
  1946.     public function isOnlineAutoOpened(): bool
  1947.     {
  1948.         return $this->onlineAutoOpened;
  1949.     }
  1950.     public function setOnlineAutoOpened(bool $onlineAutoOpened): void
  1951.     {
  1952.         $this->onlineAutoOpened $onlineAutoOpened;
  1953.     }
  1954.     public function isFoodcourtLogoEnabled(): bool
  1955.     {
  1956.         return $this->foodcourtLogoEnabled;
  1957.     }
  1958.     public function setFoodcourtLogoEnabled(bool $foodcourtLogoEnabled): void
  1959.     {
  1960.         $this->foodcourtLogoEnabled $foodcourtLogoEnabled;
  1961.     }
  1962.     public function isOnlineOrderGiftEnabled(): bool
  1963.     {
  1964.         return $this->onlineOrderGiftEnabled;
  1965.     }
  1966.     public function setOnlineOrderGiftEnabled(bool $onlineOrderGiftEnabled): void
  1967.     {
  1968.         $this->onlineOrderGiftEnabled $onlineOrderGiftEnabled;
  1969.     }
  1970.     public function isBuyCodeInAppOnly(): bool
  1971.     {
  1972.         return $this->buyCodeInAppOnly;
  1973.     }
  1974.     public function setBuyCodeInAppOnly(bool $buyCodeInAppOnly): void
  1975.     {
  1976.         $this->buyCodeInAppOnly $buyCodeInAppOnly;
  1977.     }
  1978.     public function isShowProductsInOfferDescription(): bool
  1979.     {
  1980.         return $this->showProductsInOfferDescription;
  1981.     }
  1982.     public function setShowProductsInOfferDescription(bool $showProductsInOfferDescription): void
  1983.     {
  1984.         $this->showProductsInOfferDescription $showProductsInOfferDescription;
  1985.     }
  1986.     public function isCheckAddressInOfferMenu(): bool
  1987.     {
  1988.         return $this->checkAddressInOfferMenu;
  1989.     }
  1990.     public function setCheckAddressInOfferMenu(bool $checkAddressInOfferMenu): void
  1991.     {
  1992.         $this->checkAddressInOfferMenu $checkAddressInOfferMenu;
  1993.     }
  1994.     public function isShowMapIconInApp(): bool
  1995.     {
  1996.         return $this->showMapIconInApp;
  1997.     }
  1998.     public function setShowMapIconInApp(bool $showMapIconInApp): void
  1999.     {
  2000.         $this->showMapIconInApp $showMapIconInApp;
  2001.     }
  2002.     public function isDuplicateCodesEnable(): bool
  2003.     {
  2004.         return in_array($this->ID, [
  2005.                 self::CAR_SHARING_OFFER_ID,
  2006.                 280939,
  2007.                 289045,
  2008.                 289751,
  2009.                 self::TL24_OFFER_ID,
  2010.                 294815,
  2011.                 296038,
  2012.                 296656,
  2013.             ],
  2014.             true,
  2015.         );
  2016.     }
  2017.     public function getCityByFirstCategory(): ?City
  2018.     {
  2019.         return $this->categories->count() > $this->categories->first()->getCity() : null;
  2020.     }
  2021.     public function isSeparateTabForCertificatesInApp(): bool
  2022.     {
  2023.         return $this->separateTabForCertificatesInApp;
  2024.     }
  2025.     public function setSeparateTabForCertificatesInApp(bool $separateTabForCertificatesInApp): void
  2026.     {
  2027.         $this->separateTabForCertificatesInApp $separateTabForCertificatesInApp;
  2028.     }
  2029.     public function getMapPrice(): ?float
  2030.     {
  2031.         return $this->mapPrice;
  2032.     }
  2033.     public function updateMapPrice(?float $mapPrice): void
  2034.     {
  2035.         $this->mapPrice $mapPrice;
  2036.     }
  2037.     public function getMapRating(): ?int
  2038.     {
  2039.         return $this->mapRating;
  2040.     }
  2041.     public function updateMapRating(?int $mapRating): void
  2042.     {
  2043.         $this->mapRating $mapRating;
  2044.     }
  2045.     public function getSumInCurrency(float $sum): ?float
  2046.     {
  2047.         return $this->isActiveCurrencyCalculator() && null !== $this->getBankCurrency()
  2048.             ? $sum $this->getBankCurrency()->getRate()
  2049.             : null;
  2050.     }
  2051.     public function getDirectorName(): ?string
  2052.     {
  2053.         if (null !== $this->directorName) {
  2054.             return $this->directorName;
  2055.         }
  2056.         if ($this->directors->count() > 0) {
  2057.             $directorName $this->directors->first()->getName();
  2058.             $this->directorName $directorName;
  2059.             return $directorName;
  2060.         }
  2061.         return null;
  2062.     }
  2063.     public function getOfferFoodDeliveryZoneNames(): array
  2064.     {
  2065.         if (null === $this->offerFoodDeliveryZone) {
  2066.             return [];
  2067.         }
  2068.         $sortedZoneNames = [];
  2069.         foreach ($this->offerFoodDeliveryZone->toArray() as $zone) {
  2070.             $sortedZoneNames[$zone->getPosition()] = $zone->getName();
  2071.         }
  2072.         return $sortedZoneNames;
  2073.     }
  2074.     public function getTelegram(): ?string
  2075.     {
  2076.         return $this->telegram;
  2077.     }
  2078.     public function getViber(): ?string
  2079.     {
  2080.         return $this->viber;
  2081.     }
  2082.     public function setTelegram(?string $telegram): void
  2083.     {
  2084.         $this->telegram $telegram;
  2085.     }
  2086.     public function setViber(?string $viber): void
  2087.     {
  2088.         $this->viber $viber;
  2089.     }
  2090.     public function getMessengerCallBack(): ?string
  2091.     {
  2092.         return $this->messengerCallBack;
  2093.     }
  2094.     public function setMessengerCallBack(?string $messengerCallBack): void
  2095.     {
  2096.         $this->messengerCallBack $messengerCallBack;
  2097.     }
  2098.     public function isBundleOffer(): bool
  2099.     {
  2100.         return in_array(
  2101.             $this->getID(),
  2102.             [
  2103.                 self::MARSEL_MASSAGE_OFFER_ID,
  2104.                 self::FREESTYLE_CERTIFICATE_OFFER_ID,
  2105.                 self::FREESTYLE_FLOATING_CERTIFICATE_OFFER_ID,
  2106.             ],
  2107.             true
  2108.         );
  2109.     }
  2110.     public function getTelegramLink(): ?string
  2111.     {
  2112.         if (empty($this->telegram) && $this->defaultCityId !== City::TASHKENT_CITY_ID) {
  2113.             return self::DEFAULT_TELEGRAM;
  2114.         }
  2115.         return $this->telegram;
  2116.     }
  2117.     public function getViberLink(): ?string
  2118.     {
  2119.         if (empty($this->viber) && $this->defaultCityId !== City::TASHKENT_CITY_ID) {
  2120.             return self::DEFAULT_VIBER;
  2121.         }
  2122.         return $this->viber;
  2123.     }
  2124.     public function getYclientAppKey(): ?string
  2125.     {
  2126.         return $this->yclientAppKey;
  2127.     }
  2128.     public function setYclientAppKey(?string $yclientAppKey): void
  2129.     {
  2130.         $this->yclientAppKey $yclientAppKey;
  2131.     }
  2132.     public function getYclientCompanyId(): ?string
  2133.     {
  2134.         return $this->yclientCompanyId;
  2135.     }
  2136.     public function yclientCompanyIds(): array
  2137.     {
  2138.         return array_map(
  2139.             static fn (string $companyId) => (int) $companyId,
  2140.             explode(','$this->yclientCompanyId)
  2141.         );
  2142.     }
  2143.     public function setYclientCompanyId(?string $yclientCompanyId): void
  2144.     {
  2145.         $this->yclientCompanyId $yclientCompanyId;
  2146.     }
  2147.     public function isAvailableYclient(): bool
  2148.     {
  2149.         return $this->yclientCompanyId !== null && $this->yclientAppKey !== null;
  2150.     }
  2151.     public function getAllowedPaymentMethodsForCertificate(): ?array
  2152.     {
  2153.         return $this->allowedPaymentMethodsForCertificate;
  2154.     }
  2155.     public function setAllowedPaymentMethodsForCertificate(?array $allowedPaymentMethodsForCertificate): void
  2156.     {
  2157.         $this->allowedPaymentMethodsForCertificate $allowedPaymentMethodsForCertificate;
  2158.     }
  2159.     public function isOnlinePaymentForCertificate(): bool
  2160.     {
  2161.         return array_key_exists((string)  PaymentType::ONLINE$this->allowedPaymentMethodsForCertificate)
  2162.             && (bool) $this->allowedPaymentMethodsForCertificate[(string) PaymentType::ONLINE];
  2163.     }
  2164.     public function isCashPaymentForCertificate(): bool
  2165.     {
  2166.         return array_key_exists((string) PaymentType::CASH$this->allowedPaymentMethodsForCertificate)
  2167.             && (bool) $this->allowedPaymentMethodsForCertificate[(string) PaymentType::CASH];
  2168.     }
  2169.     public function isTerminalPaymentForCertificate(): bool
  2170.     {
  2171.         return array_key_exists((string) PaymentType::TERMINAL$this->allowedPaymentMethodsForCertificate)
  2172.             && (bool) $this->allowedPaymentMethodsForCertificate[(string) PaymentType::TERMINAL];
  2173.     }
  2174.     public function isSlivkiPayPaymentForCertificate(): bool
  2175.     {
  2176.         return array_key_exists((string)PaymentType::SLIVKI_PAY$this->allowedPaymentMethodsForCertificate)
  2177.             && (bool) $this->allowedPaymentMethodsForCertificate[(string) PaymentType::SLIVKI_PAY];
  2178.     }
  2179.     public function isFestOffer(): bool
  2180.     {
  2181.         return $this->festOffer;
  2182.     }
  2183.     public function setFestOffer(bool $festOffer): void
  2184.     {
  2185.         $this->festOffer $festOffer;
  2186.     }
  2187.     public function isUseUnusedCodes(): bool
  2188.     {
  2189.         return $this->useUnusedCodes;
  2190.     }
  2191.     public function setUseUnusedCodes(bool $useUnusedCodes): void
  2192.     {
  2193.         $this->useUnusedCodes $useUnusedCodes;
  2194.     }
  2195.     public function isDeliveryZoneAvailable(): bool
  2196.     {
  2197.         return $this->offerDeliveryZone !== null && $this->offerDeliveryZone->count() > 0;
  2198.     }
  2199. }