您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

94 行
2.5KB

  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. $this->addFilterBySectionOptionnal($query);
  30. $this->addFilterByMerchantViaSectionOptionnal($query);
  31. $query->filterIsOnlineAndOffline();
  32. return $query;
  33. }
  34. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  35. {
  36. return $query;
  37. }
  38. // findReductionCreditsByUser
  39. public function getByTypeAndUser(string $type, UserInterface $user, $query = null)
  40. {
  41. $query = $this->createDefaultQuery($query);
  42. $query
  43. ->filterByType($type)
  44. ->filterByUser($user);
  45. return $query->find();
  46. }
  47. // findReductionGiftToUseByUser
  48. public function getReductionGiftToUseByUser(UserInterface $user, $query = null)
  49. {
  50. $query = $this->createDefaultQuery($query);
  51. $query->filterByUser($user);
  52. return $query->find();
  53. }
  54. // findReductionGiftOwnedByUser
  55. public function getReductionGiftOwnedByUser(UserInterface $user, $query = null)
  56. {
  57. $query = $this->createDefaultQuery($query);
  58. $query
  59. ->filterByOwner($user)
  60. ->filterInactive();
  61. return $query->find();
  62. }
  63. // findReductionGiftOwnedActiveByUser
  64. public function getReductionGiftOwnedActiveByUser(UserInterface $user, $query = null)
  65. {
  66. $query = $this->createDefaultQuery($query);
  67. $query
  68. ->filterByOwner($user)
  69. ->filterActive();
  70. return $query->find();
  71. }
  72. }