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.

TicketRepository.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  4. use Doctrine\Persistence\ManagerRegistry;
  5. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  6. use Lc\ShopBundle\Context\TicketInterface;
  7. use Lc\ShopBundle\Context\UnitInterface;
  8. use Lc\ShopBundle\Model\Ticket;
  9. use Lc\ShopBundle\Repository\BaseRepository;
  10. /**
  11. * @method TicketInterface|null find($id, $lockMode = null, $lockVersion = null)
  12. * @method TicketInterface|null findOneBy(array $criteria, array $orderBy = null)
  13. * @method TicketInterface[] findAll()
  14. * @method TicketInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  15. */
  16. class TicketRepository extends BaseRepository implements DefaultRepositoryInterface
  17. {
  18. public function getInterfaceClass()
  19. {
  20. return TicketInterface::class;
  21. }
  22. public function filterStatus($query, $statusArray)
  23. {
  24. $query->andWhere('e.status IN (:status)')->setParameter('status', $statusArray) ;
  25. return $query ;
  26. }
  27. public function findAllOpen()
  28. {
  29. $query = $this->findByMerchantQuery() ;
  30. $this->filterStatus($query, [Ticket::TICKET_STATUS_OPEN, Ticket::TICKET_STATUS_BEING_PROCESSED]) ;
  31. $query->addOrderBy('e.id', 'DESC') ;
  32. return $query->getQuery()->getResult() ;
  33. }
  34. public function countAllOpen()
  35. {
  36. $query = $this->findByMerchantQuery() ;
  37. $query->select('count(e.id)');
  38. $this->filterStatus($query, [Ticket::TICKET_STATUS_OPEN, Ticket::TICKET_STATUS_BEING_PROCESSED]) ;
  39. return $query->getQuery()->getSingleScalarResult() ;
  40. }
  41. }