first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace External\PompoBundle\View;
use Query\Operator;
class BonusProgramExchangeView extends \KupShop\BonusProgramBundle\View\Exchange\BonusProgramExchangeView
{
protected function getExchangeList(): array
{
$data = parent::getExchangeList();
// Odfiltruju partnerske slevy, ktere uz nemaji dostupne zadne kupony
foreach ($data as $key => $item) {
if (($item['partner'] ?? 'N') === 'Y') {
if (!$this->hasAvailablePartnerCoupons((int) $item['id_discount'])) {
unset($data[$key]);
}
}
}
return $data;
}
private function hasAvailablePartnerCoupons(int $discountId): bool
{
$count = sqlQueryBuilder()
->select('COUNT(*)')
->from('discounts_coupons')
->andWhere(Operator::equals(['id_discount' => $discountId]))
->andWhere('id_user IS NULL AND id_order_purchased IS NULL AND id_order_used IS NULL')
->andWhere(Operator::equals(['used' => 'N']))
->andWhere('date_from <= NOW() OR date_from IS NULL')
->andWhere('date_to >= NOW() OR date_to IS NULL')
->execute()->fetchOne();
if ($count > 0) {
return true;
}
return false;
}
}