Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

94 lines
2.6KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  4. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
  5. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
  6. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  7. use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
  8. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  9. use Lc\SovBundle\Model\User\UserInterface;
  10. use Lc\SovBundle\Repository\AbstractStore;
  11. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  12. class ReductionCreditStore extends AbstractStore
  13. {
  14. use SectionStoreTrait;
  15. use MerchantStoreTrait;
  16. protected ReductionCreditRepositoryQuery $query;
  17. public function __construct(
  18. ReductionCreditRepositoryQuery $query
  19. ) {
  20. $this->query = $query;
  21. }
  22. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  23. {
  24. $query->orderBy('id');
  25. return $query;
  26. }
  27. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  28. {
  29. if($this->section) {
  30. $query->filterBySection($this->section);
  31. }
  32. if(isset($this->merchant) && $this->merchant) {
  33. $query->filterByMerchantViaSection($this->merchant);
  34. }
  35. $query->filterIsOnlineAndOffline();
  36. return $query;
  37. }
  38. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  39. {
  40. return $query;
  41. }
  42. // findReductionCreditsByUser
  43. public function getByTypeAndUser(string $type, UserInterface $user, $query = null)
  44. {
  45. $query = $this->createDefaultQuery($query);
  46. $query
  47. ->filterByType($type)
  48. ->filterByUser($user);
  49. return $query->find();
  50. }
  51. // findReductionGiftToUseByUser
  52. public function getReductionGiftToUseByUser(UserInterface $user, $query = null)
  53. {
  54. /// @TODO : à écrire
  55. $query = $this->createDefaultQuery($query);
  56. $query->filterByUser($user);
  57. return $query->find();
  58. }
  59. // findReductionGiftOwnedByUser
  60. public function getReductionGiftOwnedByUser(UserInterface $user, $query = null)
  61. {
  62. /// @TODO : à écrire
  63. $query = $this->createDefaultQuery($query);
  64. $query->filterByOwner($user);
  65. return $query->find();
  66. }
  67. // findReductionGiftOwnedActiveByUser
  68. public function getReductionGiftOwnedActiveByUser(UserInterface $user, $query = null)
  69. {
  70. /// @TODO : à écrire
  71. $query = $this->createDefaultQuery($query);
  72. $query->filterByOwner($user);
  73. return $query->find();
  74. }
  75. }