Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ReductionCreditStore.php 3.1KB

3 anos atrás
2 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
2 anos atrás
3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
  4. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  5. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  6. use Lc\SovBundle\Model\User\UserInterface;
  7. use Lc\CaracoleBundle\Repository\AbstractStore;
  8. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  9. class ReductionCreditStore extends AbstractStore
  10. {
  11. use MerchantStoreTrait;
  12. protected ReductionCreditRepositoryQuery $query;
  13. public function __construct(
  14. ReductionCreditRepositoryQuery $query
  15. ) {
  16. $this->query = $query;
  17. }
  18. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  19. {
  20. $query->orderBy('id');
  21. return $query;
  22. }
  23. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  24. {
  25. $this->addFilterByMerchantRequired($query);
  26. $query->filterIsOnlineAndOffline();
  27. return $query;
  28. }
  29. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  30. {
  31. return $query;
  32. }
  33. // findReductionCreditsByUser
  34. public function getByTypeAndUser(string $type, UserInterface $user, $query = null)
  35. {
  36. $query = $this->createDefaultQuery($query);
  37. $query
  38. ->filterByType($type)
  39. ->filterByUser($user);
  40. return $query->find();
  41. }
  42. // findReductionGiftToUseByUser
  43. public function getReductionGiftToUseByUser(UserInterface $user, $query = null)
  44. {
  45. $query = $this->createDefaultQuery($query);
  46. $query->filterByUser($user);
  47. return $query->find();
  48. }
  49. // findReductionGiftOwnedByUser
  50. public function getReductionGiftOwnedByUser(UserInterface $user, $query = null)
  51. {
  52. $query = $this->createDefaultQuery($query);
  53. $query
  54. ->filterByOwner($user)
  55. ->filterInactive();
  56. return $query->find();
  57. }
  58. // findReductionGiftOwnedActiveByUser
  59. public function getReductionGiftOwnedActiveByUser(UserInterface $user, $query = null)
  60. {
  61. $query = $this->createDefaultQuery($query);
  62. $query
  63. ->filterByOwner($user)
  64. ->filterActive();
  65. return $query->find();
  66. }
  67. //Toutes les reductionGift d'un utilisateur inter/merchant
  68. public function getReductionGiftByUserOutOfContext(UserInterface $user, $query = null)
  69. {
  70. $query = $this->createQuery($query);
  71. $query->filterIsOnlineAndOffline();
  72. $query->filterByUser($user);
  73. $query->filterByType(ReductionCreditModel::TYPE_GIFT);
  74. return $query->find();
  75. }
  76. //Toutes les reductionCredit d'un utilisateur inter/merchant
  77. public function getReductionCreditByUserOutOfContext(UserInterface $user, $query = null)
  78. {
  79. $query = $this->createQuery($query);
  80. $query->filterIsOnlineAndOffline();
  81. $query->filterByUser($user);
  82. $query->filterByType(ReductionCreditModel::TYPE_CREDIT);
  83. return $query->find();
  84. }
  85. }