|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
-
- namespace Lc\ShopBundle\Repository;
-
- use Lc\ShopBundle\Context\DefaultRepositoryInterface;
- use Lc\ShopBundle\Context\ReductionCatalogInterface;
-
- /**
- * @method ReductionCatalogInterface|null find($id, $lockMode = null, $lockVersion = null)
- * @method ReductionCatalogInterface|null findOneBy(array $criteria, array $orderBy = null)
- * @method ReductionCatalogInterface[] findAll()
- * @method ReductionCatalogInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
- class ReductionCatalogRepository extends BaseRepository implements DefaultRepositoryInterface
- {
- public function getInterfaceClass()
- {
- return ReductionCatalogInterface::class;
- }
-
-
- public function getReductionCatalogByProductFamily($productFamily, $user)
- {
-
- $query = $this->findByMerchantQuery();
- $query->andWhere('e.status = 1');
- $query->andWhere(':user MEMBER OF e.users OR e.users is empty');
- $query->andWhere(':groupUser MEMBER OF e.groupUsers OR e.groupUsers is empty');
- $query->andWhere(':productFamily MEMBER OF e.productFamilies OR e.productFamilies is empty');
- $query->andWhere(':productCategory MEMBER OF e.productCategories OR e.productCategories is empty');
- $query->andWhere(':supplier MEMBER OF e.suppliers OR e.suppliers is empty');
- $query->setParameter('user', $user);
- $query->setParameter('groupUser', $user->getGroupUsers());
- $query->setParameter('productFamily', $productFamily);
- $query->setParameter('productCategory', $productFamily->getProductCategories());
- $query->setParameter('supplier', $productFamily->getSupplier());
-
-
- return $query->getQuery()->getResult();
-
-
- }
-
-
- public function getReductionCatalogByProductFamilyConditions($productFamilyIds, $user)
- {
-
- $query = $this->findByMerchantQuery();
- $query->andWhere('e.status = 1');
- $query->andWhere(':user MEMBER OF e.users OR e.users is empty');
- $query->andWhere(':groupUser MEMBER OF e.groupUsers OR e.groupUsers is empty');
- $query->andWhere(':productFamily MEMBER OF e.productFamilies OR e.productFamilies is empty');
- $query->andWhere(':productCategory MEMBER OF e.productCategories OR e.productCategories is empty');
- $query->andWhere(':supplier MEMBER OF e.suppliers OR e.suppliers is empty');
- $query->setParameter('user', $user);
- $query->setParameter('groupUser', $user->getGroupUsers());
- $query->setParameter('productFamily', $productFamilyIds['ids']);
- $query->setParameter('productCategory', $productFamilyIds['categories']);
- $query->setParameter('supplier', $productFamilyIds['suppliers']);
-
-
- return $query->getQuery()->getResult();
-
-
- }
- }
|