src/Service/Shop/ShopService.php line 583

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Elements.at New Media Solutions GmbH
  4.  *
  5.  */
  6. namespace App\Service\Shop;
  7. use App\Ecommerce\AvailabilitySystem\Event\AvailabilitySystem;
  8. use App\Ecommerce\CartManager\SessionCartItem;
  9. use App\Model\Shop\Cart\CartItemGroup as CustomCartItemGroup;
  10. use App\Model\Shop\Event\EventProduct;
  11. use App\Model\Shop\Event\ShopDynamicPrice;
  12. use App\Model\Shop\Merchandise\MerchandiseProduct;
  13. use App\Model\Shop\Ticket\ShopTicketCatalog;
  14. use App\Model\Traits\SkidataTrait;
  15. use App\Service\TicketShopFrameworkBundle\TicketFilter;
  16. use Carbon\Carbon;
  17. use Elements\Bundle\TicketShopFrameworkBundle\Ecommerce\PricingManager\PriceInfo as TSFPricingManagerPriceInfo;
  18. use Elements\Bundle\TicketShopFrameworkBundle\Exception\UnavailableException;
  19. use Elements\Bundle\TicketShopFrameworkBundle\Model\DataObject\TicketConsumerCategory;
  20. use Elements\Bundle\TicketShopFrameworkBundle\Model\DataObject\TicketProduct;
  21. use Elements\Bundle\TicketShopFrameworkBundle\Model\Shop\Cart\CartItemGroup;
  22. use Elements\Bundle\TicketShopFrameworkBundle\Model\Shop\Cart\TicketShopCartInterface;
  23. use Elements\Bundle\TicketShopFrameworkBundle\Model\Shop\Ticketing\TicketCatalogAvailability;
  24. use Endroid\QrCode\Color\Color;
  25. use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh;
  26. use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow;
  27. use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelMedium;
  28. use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelQuartile;
  29. use Endroid\QrCode\Label\Label;
  30. use Endroid\QrCode\QrCode;
  31. use Endroid\QrCode\Writer\PngWriter;
  32. use Endroid\QrCode\Writer\Result\ResultInterface;
  33. use Pimcore\Bundle\EcommerceFrameworkBundle\PricingManager\PriceInfoInterface;
  34. use Pimcore\Bundle\EcommerceFrameworkBundle\Type\Decimal;
  35. use Pimcore\Logger;
  36. use Pimcore\Model\DataObject\Fieldcollection\Data\SkidataAdditionalProductItem;
  37. use Pimcore\Model\DataObject\Objectbrick\Data\AbstractData;
  38. use Pimcore\Model\DataObject\Objectbrick\Data\PaymentProviderDPG;
  39. use Pimcore\Model\DataObject\Objectbrick\Data\PaymentProviderDPGPayPal;
  40. use Pimcore\Model\DataObject\OnlineShopOrder\PaymentProvider;
  41. use Pimcore\Model\DataObject\SkidataConsumerCategory;
  42. use Pimcore\Model\DataObject\SkidataProduct;
  43. use Pimcore\Model\DataObject\TicketSeason;
  44. use Symfony\Component\HttpFoundation\Request;
  45. class ShopService
  46. {
  47.     use SkidataTrait;
  48.     public function __construct(
  49.         protected ProductService $productService
  50.     ) {
  51.     }
  52.     /**
  53.      * @param ShopTicketCatalog $catalog
  54.      *
  55.      * @return array<mixed>
  56.      */
  57.     public function getSeasonDates(ShopTicketCatalog $catalog): array
  58.     {
  59.         return $this->modifySeasonDates($catalog->getTicketSeasons());
  60.     }
  61.     /**
  62.      * @param TicketSeason[]|null $seasons
  63.      *
  64.      * @return array<mixed>
  65.      */
  66.     public function modifySeasonDates(array|null $seasons): array
  67.     {
  68.         $dates = [];
  69.         if (empty($seasons)) {
  70.             return $dates;
  71.         }
  72.         foreach ($seasons as $season) {
  73.             foreach ($season->getDates()->getDefinitionArray() as $definition) {
  74.                 if ($definition['type'] == 'RecurringDate') {
  75.                     $dates[] = [
  76.                         'season' => $season->getSeason(),
  77.                         'from' => Carbon::parse($definition['values']['fromDate']),
  78.                         'to' => Carbon::parse($definition['values']['toDate']),
  79.                     ];
  80.                 }
  81.             }
  82.         }
  83.         return $dates;
  84.     }
  85.     /**
  86.      * @param array<mixed>|null $seasonDates
  87.      * @param Carbon $date
  88.      *
  89.      * @return string
  90.      */
  91.     public function getSeasonNameForDate(array|null $seasonDatesCarbon $date): string
  92.     {
  93.         if (!empty($seasonDates)) {
  94.             foreach ($seasonDates as $seasonDate) {
  95.                 if ($date->between($seasonDate['from'], $seasonDate['to'])) {
  96.                     return $seasonDate['season'];
  97.                 }
  98.             }
  99.         }
  100.         //todo: default?
  101.         return 'midseason';
  102.     }
  103.     /**
  104.      * @param TicketCatalogAvailability $ticketCatalogAvailability
  105.      *
  106.      * @return array<mixed>
  107.      */
  108.     public function getInsurancesForProduct(TicketCatalogAvailability $ticketCatalogAvailability): array
  109.     {
  110.         $insurances = [];
  111.         foreach ($ticketCatalogAvailability->getTicketAvailability() as $availability) {
  112.             foreach ($availability->getConsumerAvailabilities() as $consumerAvailability) {
  113.                 if ($consumerInsurances $consumerAvailability->getAdditionalProductAvailabilities()) {
  114.                     $ticket $availability->getTicketProduct();
  115.                     foreach ($consumerInsurances as $insurance) {
  116.                         /** @var \App\Model\Shop\Ticket\TicketProduct $insuranceTicketProduct */
  117.                         $insuranceTicketProduct $insurance->getAdditionalProduct();
  118.                         $insurances['insurances'][$ticket->getId()][] = $insuranceTicketProduct;
  119.                         $insurances['mappingObject'][$insuranceTicketProduct->getId()] = $insuranceTicketProduct->getInsuranceMetaProduct();
  120.                     }
  121.                     /** @phpstan-ignore-next-line  */
  122.                     if (isset($insurances['insurances'])) {
  123.                         $insurances['insurances'][$ticket->getId()] = array_unique($insurances['insurances'][$ticket->getId()]);
  124.                     }
  125.                 }
  126.             }
  127.         }
  128.         return $insurances;
  129.     }
  130.     public function isInsuranceAllowed(
  131.         TicketProduct $insurance,
  132.         SkidataProduct $skidataProduct,
  133.         SkidataConsumerCategory $category
  134.     ): bool {
  135.         $insuranceUuid $insurance->getSkidataProduct()?->getUuid();
  136.         // find matching item for product / category
  137.         $additionalProductItems $skidataProduct->getAdditionalProductItems();
  138.         if ($additionalProductItems) {
  139.             /** @var SkidataAdditionalProductItem $additionalProductItem */
  140.             foreach ($additionalProductItems as $additionalProductItem) {
  141.                 if (!$additionalProductItem->getSkiDataProduct() || !$additionalProductItem->getConsumerCategory()) {
  142.                     continue;
  143.                 }
  144.                 if ($category->getUuid() == $additionalProductItem->getConsumerCategory()->getUuid()
  145.                     && $insuranceUuid == $additionalProductItem->getSkiDataProduct()->getUuid()) {
  146.                     return true;
  147.                 }
  148.             }
  149.         }
  150.         return false;
  151.     }
  152.     /**
  153.      * @param TicketProduct $product
  154.      * @param TicketConsumerCategory $consumerCategory
  155.      * @param int $count
  156.      * @param TicketProduct|null $additional
  157.      * @param ShopTicketCatalog|null $ticketCatalog
  158.      * @param TicketShopCartInterface $cart
  159.      * @param Carbon|null $ticketStartDate
  160.      * @param array<mixed> $params
  161.      *
  162.      * @return array<mixed>
  163.      *
  164.      * @throws \Exception
  165.      */
  166.     public function addTicketItemsToCartPerConsumer(
  167.         TicketProduct $product,
  168.         TicketConsumerCategory $consumerCategory,
  169.         int $count,
  170.         ?TicketProduct $additional,
  171.         ?ShopTicketCatalog $ticketCatalog,
  172.         TicketShopCartInterface $cart,
  173.         Carbon $ticketStartDate null,
  174.         array $params = []
  175.     ): array {
  176.         $productVariation $product->getOrCreateOrderableObject($consumerCategory$ticketStartDatenull$ticketCatalog);
  177.         $addedItems = [];
  178.         for ($i 0$i $count$i++) {
  179.             $itemKey sprintf('%d%s'$productVariation->getId(), uniqid());
  180.             try {
  181.                 $priceInfo $productVariation->getOSPriceInfo();
  182.             } catch (UnavailableException $exception) {
  183.                 Logger::warning(sprintf('trying to add unavailable ticket #%s: %s'$productVariation->getId(),
  184.                     $exception->getMessage()));
  185.                 return [];
  186.             }
  187.             if ($priceInfo instanceof \Elements\Bundle\TicketShopFrameworkBundle\Ecommerce\PriceSystem\Skidata\PriceInfo) {
  188.                 if ($priceInfo->getTicketBasePrice()->getAmount()->lessThan(Decimal::zero())) {
  189.                     Logger::warning(sprintf('trying to add ticket with ticket price < 0 : ticket #%s',
  190.                         $productVariation->getId()));
  191.                     return [];
  192.                 }
  193.             }
  194.             $addedItems[] = $cart->addItem($productVariation1$itemKeyfalse$params);
  195.             /** @var SessionCartItem $addedItem */
  196.             $addedItem $cart->getItem($itemKey);
  197.             if ($additional) {
  198.                 $subItemKey $addedItem->getItemKey() . '-option-' $count;
  199.                 $addedItem->addSubItem($additional1$subItemKey);
  200.             }
  201.             if (array_key_exists('person'$params)) {
  202.                 $addedItem->setPerson($params['person']);
  203.             }
  204.             $addedItem->setIsUpgradeProduct($params['isUpgradeOption']);
  205.             $addedItem->setOriginalProduct($params['originalProduct']);
  206.         }
  207.         $cart->save();
  208.         //        if ($count > 0) {
  209.         //            $trackingManager = Factory::getInstance()->getTrackingManager();
  210.         //            $trackingManager->trackCartProductActionAdd($cart, $productVariation, $count);
  211.         //        }
  212.         return $addedItems;
  213.     }
  214.     /**
  215.      * @param ShopTicketCatalog $catalog
  216.      * @param Carbon $startDate
  217.      *
  218.      * @return bool
  219.      */
  220.     public function isServiceViewHidden(ShopTicketCatalog $catalogCarbon $startDateCarbon $endDate nullbool $exactDate false): bool
  221.     {
  222.         if ($catalog->getUpgrades()) {
  223.             return false;
  224.         }
  225.         $firstValidityDateRange $catalog->getFirstValidDateRange($startDate);
  226.         if ($firstValidityDateRange) {
  227.             $startDate $startDate->greaterThan($firstValidityDateRange['from']) ? $startDate $firstValidityDateRange['from'];
  228.             if (!$endDate && !$exactDate) {
  229.                 $endDate $firstValidityDateRange['to'];
  230.             } elseif (!$endDate && $exactDate) {
  231.                 //only one day clicked
  232.                 $endDate $startDate;
  233.             }
  234.             $filter = new TicketFilter($startDate$endDate);
  235.             $filter->setExactDuration($exactDate);
  236.             //we don't need price calculation here
  237.             $filter->setIgnorePrice(true);
  238.             //check for insurances
  239.             $catalogAvailability $filter->getTicketCatalogAvailability($catalogtrue);
  240.             //if more than one ticket is bookable e.g. day-ticket + half-day ticket
  241.             if (count($catalogAvailability->getTicketAvailability()) > 1) {
  242.                 return false;
  243.             }
  244.             //if insurances are found
  245.             foreach ($catalogAvailability->getTicketAvailability() as $ticketAvailability) {
  246.                 foreach ($ticketAvailability->getConsumerAvailabilities() as $consumerAvailability) {
  247.                     if ($consumerAvailability->getAdditionalProductAvailabilities()) {
  248.                         return false;
  249.                     }
  250.                 }
  251.             }
  252.         }
  253.         return true;
  254.     }
  255.     /**
  256.      * @param EventProduct $product
  257.      * @param ShopDynamicPrice $priceObj
  258.      * @param TicketShopCartInterface $cart
  259.      * @param Carbon $date
  260.      * @param int $quantity
  261.      * @param array<mixed> $params
  262.      *
  263.      * @return SessionCartItem
  264.      *
  265.      * @throws \Exception
  266.      */
  267.     public function addEventToCartPerPriceObject(
  268.         EventProduct $product,
  269.         ShopDynamicPrice $priceObj,
  270.         TicketShopCartInterface $cart,
  271.         Carbon $date,
  272.         int $quantity,
  273.         array $params = [],
  274.         bool $allowAddingPastEvents false
  275.     ): ?SessionCartItem {
  276.         if($product->getBookableOnDayOfEvent() && ($date->isBefore(Carbon::now()->startOfDay()) && !$allowAddingPastEvents)) {
  277.             Logger::warning(sprintf('trying to add event with date in the past #%s: %s'$product->getId(), $date->format('c')));
  278.             return null;
  279.         } elseif ($product->getBookableOnDayOfEvent() && $product->getStopSale() > 0) {
  280.             $lastSale = clone $date;
  281.             $lastSale->subHours(intval($product->getStopSale()));
  282.             if($lastSale->isBefore(Carbon::now())) {
  283.                 Logger::warning(sprintf('trying to add event with date/time beyond stop sales setting  #%s: %s'$product->getId(), $date->format('c')));
  284.                 return null;
  285.             }
  286.         } elseif (!$product->getBookableOnDayOfEvent() && ($date->isBefore(Carbon::now()->addDay()->startOfDay()) && !$allowAddingPastEvents)) {
  287.             Logger::warning(sprintf('trying to add event with date today or in the past, event is not bookable on day of event #%s: %s'$product->getId(), $date->format('c')));
  288.             return null;
  289.         }
  290.         $productVariation $product->getOrCreateOrderableObject($date$priceObj);
  291.         $itemKey sprintf('%d'$productVariation->getId());
  292.         try {
  293.             $priceInfo $productVariation->getOSPriceInfo();
  294.         } catch (UnavailableException $exception) {
  295.             Logger::warning(sprintf('trying to add unavailable event #%s: %s'$productVariation->getId(), $exception->getMessage()));
  296.             return null;
  297.         }
  298.         if ($priceInfo instanceof \Elements\Bundle\TicketShopFrameworkBundle\Ecommerce\PriceSystem\Skidata\PriceInfo) {
  299.             if ($priceInfo->getTicketBasePrice()->getAmount()->lessThan(Decimal::zero())) {
  300.                 Logger::warning(sprintf('trying to add event with price < 0 : event #%s'$productVariation->getId()));
  301.                 return null;
  302.             }
  303.         }
  304.         $itemKey $cart->addItem($productVariation$quantity$itemKeyfalse$params);
  305.         /** @var SessionCartItem|null $cartItem */
  306.         $cartItem $cart->getItem($itemKey);
  307.         $cart->save();
  308.         //        if ($quantity > 0) {
  309.         //            $trackingManager = Factory::getInstance()->getTrackingManager();
  310.         //            $trackingManager->trackCartProductActionAdd($cart, $productVariation, $quantity);
  311.         //        }
  312.         return $cartItem;
  313.     }
  314.     /**
  315.      * @param MerchandiseProduct $merch
  316.      * @param int $quantity
  317.      * @param TicketShopCartInterface $cart
  318.      *
  319.      * @return SessionCartItem|null
  320.      */
  321.     public function addMerchandiseToCart(MerchandiseProduct $merchint $quantityTicketShopCartInterface $cart): ?SessionCartItem
  322.     {
  323.         $itemKey 'merch-' $merch->getId();
  324.         //todo check if is available
  325.         $itemKey $cart->addItem($merch$quantity$itemKey);
  326.         /** @var SessionCartItem|null $cartItem */
  327.         $cartItem $cart->getItem($itemKey);
  328.         $cart->save();
  329.         //        if ($quantity > 0) {
  330.         //            $trackingManager = Factory::getInstance()->getTrackingManager();
  331.         //            $trackingManager->trackCartProductActionAdd($cart, $merch, $quantity);
  332.         //        }
  333.         return $cartItem;
  334.     }
  335.     public function isValidMaxParticipants(EventProduct $eventint $totalParticipants): bool
  336.     {
  337.         $quota $event->getQuota();
  338.         if ($maxParticipants $event->getMaxParticipantPerBooking()) {
  339.             return $totalParticipants <= $maxParticipants && $totalParticipants <= $quota;
  340.         } else {
  341.             return true;
  342.         }
  343.     }
  344.     public function isValidParticipants(EventProduct $eventCarbon $bookedDateint $realAddedParticipants): bool
  345.     {
  346.         /** @var AvailabilitySystem $availabilitySystem */
  347.         $availabilitySystem $event->getAvailabilitySystemImplementation();
  348.         $availability $availabilitySystem->getAvailableQuota($event$bookedDatetrue);
  349.         if ($availability->isAvailable()) {
  350.             return $realAddedParticipants <= $availability->getAvailableQuota();
  351.         }
  352.         return false;
  353.     }
  354.     /**
  355.      * @param CartItemGroup[] $groupedItems
  356.      *
  357.      * @return array<mixed>
  358.      */
  359.     public function groupCartItemsByClass(array $groupedItems): array
  360.     {
  361.         $groupedClassItems = [];
  362.         foreach ($groupedItems as $item) {
  363.             /** @var MerchandiseProduct|EventProduct|TicketProduct $product */
  364.             $product $item->getProduct();
  365.             $groupedClassItems[$product->getClassName()][] = $item;
  366.         }
  367.         return $groupedClassItems;
  368.     }
  369.     public function getPricingRulesText(PriceInfoInterface $priceInfo): ?string
  370.     {
  371.         $rules $priceInfo->getRules();
  372.         $rulesText = [];
  373.         foreach ($rules as $rule) {
  374.             if ($description $rule->getDescription()) {
  375.                 $rulesText[] = $description;
  376.             }
  377.         }
  378.         return $rulesText implode(' | '$rulesText) : null;
  379.     }
  380.     /**
  381.      * @param PriceInfoInterface|CartItemGroup $subject
  382.      *
  383.      * @return string|null
  384.      */
  385.     public function getPricingRulesLabel(PriceInfoInterface|CartItemGroup|CustomCartItemGroup $subject): ?string
  386.     {
  387.         if ($subject instanceof PriceInfoInterface) {
  388.             if ($subject instanceof TSFPricingManagerPriceInfo) {
  389.                 $priceInfo $subject;
  390.                 $priceInfo->getPrice();
  391.                 $originalPriceInfo $priceInfo->getOriginalPriceInfo();
  392.                 if ($originalPriceInfo instanceof \App\Ecommerce\PriceSystem\PriceInfoInterface
  393.                     && $originalPriceInfo->getDiscountLabel()) {
  394.                     $prefix = ($originalPriceInfo->isHideDiscountValue() || !$originalPriceInfo->getDiscount()) ? '' ' ' $originalPriceInfo->getDiscount() . '% ';
  395.                     return $prefix $originalPriceInfo->getDiscountLabel();
  396.                 }
  397.             }
  398.         } else {
  399.             $labels = [];
  400.             foreach ($subject->getItems() as $cartItem) {
  401.                 $labels[] = $this->getPricingRulesLabel($cartItem->getPriceInfo());
  402.             }
  403.             //filter null-values from $labels
  404.             $labels array_keys(array_flip(array_filter($labels)));
  405.             if (count($labels) == 1) {
  406.                 return $labels[0];
  407.             }
  408.         }
  409.         return null;
  410.     }
  411.     /**
  412.      * @param string $code
  413.      * @param int $size
  414.      * @param string|null $label
  415.      *
  416.      * @return ResultInterface
  417.      */
  418.     public function createQrCode(string $codeint $size 200string $label nullint $errorLevel null): ResultInterface
  419.     {
  420.         $writer = new PngWriter();
  421.         $qrCode = new QrCode($code);
  422.         match ($errorLevel) {
  423.             => $errorLevel = new ErrorCorrectionLevelLow(),
  424.             => $errorLevel = new ErrorCorrectionLevelMedium(),
  425.             => $errorLevel = new ErrorCorrectionLevelQuartile(),
  426.             default => $errorLevel = new ErrorCorrectionLevelHigh(),
  427.         };
  428.         $qrCode->setSize($size);
  429.         $qrCode->setErrorCorrectionLevel($errorLevel);
  430.         $qrCode->setForegroundColor(new Color(0000));
  431.         $qrCode->setBackgroundColor(new Color(2552552550));
  432.         if ($label) {
  433.             $label Label::create($label)->setTextColor(new Color(000));
  434.         }
  435.         return $writer->write($qrCodenull$label);
  436.     }
  437.     /**
  438.      * @param array<mixed> $recurringDates
  439.      *
  440.      * @return ?Carbon
  441.      */
  442.     public function getMaxValidityDate(array $recurringDates): ?Carbon
  443.     {
  444.         $maxDate null;
  445.         foreach ($recurringDates as $date) {
  446.             $maxDate $date['toDate']->greaterThan($maxDate) ? $date['toDate'] : $maxDate;
  447.         }
  448.         return $maxDate;
  449.     }
  450.     /**
  451.      * @param array<mixed> $recurringDates
  452.      *
  453.      * @return ?Carbon
  454.      */
  455.     public function getMinValidityDate(array $recurringDates): ?Carbon
  456.     {
  457.         $minDate null;
  458.         foreach ($recurringDates as $date) {
  459.             $minDate = (null == $minDate || $date['fromDate']->lessThan($minDate)) ? $date['fromDate'] : $minDate;
  460.         }
  461.         return $minDate;
  462.     }
  463.     public function hasUserPermission(string $permission): bool
  464.     {
  465.         $user \Pimcore\Tool\Admin::getCurrentUser();
  466.         return $user->isAllowed($permission);
  467.     }
  468.     /**
  469.      * @param string $idString
  470.      * @param bool $returnInt
  471.      *
  472.      * @return array<mixed>|int|null
  473.      */
  474.     public function extractIdsFromString(?string $idStringbool $returnInt false): array|int|null
  475.     {
  476.         if (null == $idString) {
  477.             return null;
  478.         }
  479.         $output array_map('intval'explode(','$idString));
  480.         return count($output) === && $returnInt $output[0] : $output;
  481.     }
  482.     /**
  483.      * @param Request $request
  484.      *
  485.      * @return array<mixed>
  486.      */
  487.     public function getDatesForPriceCalculator(Request $request): array
  488.     {
  489.         $output = [];
  490.         $isMobile $request->get('isMobile');
  491.         $output['startDate'] = $request->get('shownStartYear') && $request->get('shownStartMonth')
  492.             ? Carbon::create($request->get('shownStartYear'), $request->get('shownStartMonth'))
  493.             : Carbon::today()->startOfMonth();
  494.         $output['endDate'] = $request->get('shownEndYear') && $request->get('shownEndMonth')
  495.             ? Carbon::create($request->get('shownEndYear'), $request->get('shownEndMonth'))->endOfMonth()
  496.             : ($isMobile === 'false' Carbon::today()->addMonthNoOverflow()->endOfMonth() : Carbon::today()->endOfMonth());
  497.         return $output;
  498.     }
  499.     /**
  500.      * @param \App\Model\Shop\Ticket\ShopTicketCatalog $catalog
  501.      * @param array<int> $priceGroupIds
  502.      *
  503.      * @return array<int>
  504.      */
  505.     public function getCorrectAllowedConsumerIds(ShopTicketCatalog $catalog, array $priceGroupIds): array
  506.     {
  507.         $allowedConsumerIds = [];
  508.         foreach ($catalog->getTicketConsumerCategories() as $consumerCategory) {
  509.             $consumerId $consumerCategory->getId();
  510.             $parentId $consumerCategory->getParentId();
  511.             if (in_array($consumerId$priceGroupIds)) {
  512.                 $allowedConsumerIds[] = $consumerId;
  513.                 unset($priceGroupIds[array_search($consumerId$priceGroupIds)]);
  514.             }
  515.             if (in_array($parentId$priceGroupIds)) {
  516.                 $allowedConsumerIds[] = $consumerId;
  517.                 unset($priceGroupIds[array_search($parentId$priceGroupIds)]);
  518.             }
  519.         }
  520.         return $allowedConsumerIds;
  521.     }
  522.     /**
  523.      * @param Carbon $date
  524.      * @param Carbon $endDate
  525.      * @param Carbon $minDate
  526.      * @param array<mixed> $seasonDates
  527.      * @param array<mixed> $pressures
  528.      *
  529.      * @return array<mixed>
  530.      */
  531.     public function buildCalendarData(Carbon $dateCarbon $endDateCarbon $minDate, array $seasonDates, array $pressures): array
  532.     {
  533.         $output = [];
  534.         while ($date->lessThanOrEqualTo($endDate)) {
  535.             $dates = [];
  536.             $month $date->month;
  537.             $year $date->year;
  538.             $tmpDate $date->copy();
  539.             while ($date->lessThanOrEqualTo($tmpDate->endOfMonth())) {
  540.                 $data = [
  541.                     'date' => $date->toDateTimeLocalString(),
  542.                     'season' => $this->getSeasonNameForDate($seasonDates$date),
  543.                     'disabled' => $date->lessThan($minDate),
  544.                 ];
  545.                 if ($date->gte($minDate)) {
  546.                     $data['priceTendency'] = $this->productService->getPriceTendency($date->copy(), $pressures);
  547.                 }
  548.                 $dates[] = $data;
  549.                 $date->addDay();
  550.             }
  551.             $output[] = [
  552.                 'month' => $month,
  553.                 'year' => $year,
  554.                 'dates' => $dates,
  555.             ];
  556.         }
  557.         return $output;
  558.     }
  559.     /**
  560.      * @param PaymentProvider|null $providerBrick
  561.      *
  562.      * @return PaymentProviderDPG|PaymentProviderDPGPayPal|null
  563.      */
  564.     public function getDatatransProviderBrick(?PaymentProvider $providerBrick): ?AbstractData
  565.     {
  566.         $paymentProvider null;
  567.         if (null !== $providerBrick) {
  568.             if ($paymentProviderDPG $providerBrick->getPaymentProviderDPG()) {
  569.                 $paymentProvider $paymentProviderDPG;
  570.             }
  571.             if ($paymentProviderDPGPayPal $providerBrick->getPaymentProviderDPGPayPal()) {
  572.                 $paymentProvider $paymentProviderDPGPayPal;
  573.             }
  574.         }
  575.         return $paymentProvider;
  576.     }
  577. }