You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7KB

  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  4. use Lc\ShopBundle\Context\ReductionCartInterface;
  5. /**
  6. * @method ReductionCartInterface|null find($id, $lockMode = null, $lockVersion = null)
  7. * @method ReductionCartInterface|null findOneBy(array $criteria, array $orderBy = null)
  8. * @method ReductionCartInterface[] findAll()
  9. * @method ReductionCartInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  10. */
  11. class ReductionCartRepository extends BaseRepository implements DefaultRepositoryInterface
  12. {
  13. public function getInterfaceClass()
  14. {
  15. return ReductionCartInterface::class;
  16. }
  17. public function findOneByCode($code)
  18. {
  19. $query = $this->findByMerchantQuery() ;
  20. $query->andWhere('e.codes LIKE :code')->setParameter('code', '%'.$code.'%') ;
  21. return $query->getQuery()->getOneOrNullResult() ;
  22. }
  23. public function getValuesOfFieldType(){
  24. $query = $this->findByMerchantQuery() ;
  25. $query->select('DISTINCT e.type');
  26. $query->andWhere('e.status = 1');
  27. return $query->getQuery()->getResult() ;
  28. }
  29. public function getValuesOfFieldCode(){
  30. $query = $this->findByMerchantQuery() ;
  31. $query->select('DISTINCT e.codes');
  32. $query->andWhere('e.status = 1');
  33. return $query->getQuery()->getResult() ;
  34. }
  35. public function getEligibleReductionCart($order)
  36. {
  37. $query = $this->findByMerchantQuery() ;
  38. $query->andWhere('e.status = 1');
  39. return $query->getQuery()->getResult();
  40. }
  41. }