|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
-
- namespace Lc\ShopBundle\Repository;
-
- use Lc\ShopBundle\Context\DefaultRepositoryInterface;
- use Lc\ShopBundle\Context\ReductionCatalogInterface;
- use Symfony\Component\Validator\Constraints\DateTime;
-
-
- 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('e.permanent = 1 OR (e.dateStart <= :now AND e.dateEnd >= :now)');
- if($user){
- $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->setParameter('user', $user);
- $query->setParameter('groupUser', $user->getGroupUsers());
- }
-
- $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('productFamily', $productFamilyIds['ids']);
- $query->setParameter('productCategory', $productFamilyIds['categories']);
- $query->setParameter('supplier', $productFamilyIds['suppliers']);
- $query->setParameter(':now', new \DateTime());
-
- return $query->getQuery()->getResult();
-
-
- }
- }
|