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.

44 lines
1.8KB

  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. }