Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CreditHistoryRepository.php 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  4. use Lc\ShopBundle\Context\CreditHistoryInterface;
  5. /**
  6. * @method CreditHistoryInterface|null find($id, $lockMode = null, $lockVersion = null)
  7. * @method CreditHistoryInterface|null findOneBy(array $criteria, array $orderBy = null)
  8. * @method CreditHistoryInterface[] findAll()
  9. * @method CreditHistoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  10. */
  11. class CreditHistoryRepository extends BaseRepository implements DefaultRepositoryInterface
  12. {
  13. public function getInterfaceClass()
  14. {
  15. return CreditHistoryInterface::class;
  16. }
  17. public function findAllByDateStartEnd($merchant, $dateStart, $dateEnd)
  18. {
  19. return $this->createQueryBuilder('e')
  20. ->innerJoin('e.userMerchant', 'user_merchant')
  21. ->andWhere('user_merchant.merchant = :merchant')
  22. ->setParameter(':merchant', $merchant)
  23. ->andWhere('e.createdAt >= :dateStart')
  24. ->andWhere('e.createdAt <= :dateEnd')
  25. ->setParameter(':dateStart', $dateStart)
  26. ->setParameter(':dateEnd', $dateEnd)
  27. ->addOrderBy('e.createdAt', 'ASC')
  28. ->getQuery()->getResult();
  29. }
  30. public function findAllByUserMerchant($userMerchant)
  31. {
  32. return $this->createQueryBuilder('e')
  33. ->andWhere('e.userMerchant = :userMerchant')
  34. ->setParameter('userMerchant', $userMerchant)
  35. ->addOrderBy('e.createdAt', 'DESC')
  36. ->getQuery()->getResult();
  37. }
  38. }