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.

ReductionCartStore.php 2.2KB

3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  4. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  5. use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver;
  6. use Lc\CaracoleBundle\Repository\AbstractStore;
  7. use Lc\SovBundle\Model\User\UserInterface;
  8. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  9. class ReductionCartStore extends AbstractStore
  10. {
  11. use MerchantStoreTrait;
  12. protected ReductionCartRepositoryQuery $query;
  13. protected ReductionCartSolver $reductionCartSolver;
  14. protected PriceSolver $priceSolver;
  15. public function __construct(
  16. ReductionCartRepositoryQuery $query,
  17. ReductionCartSolver $reductionCartSolver,
  18. PriceSolver $priceSolver
  19. )
  20. {
  21. $this->query = $query;
  22. $this->reductionCartSolver = $reductionCartSolver;
  23. $this->priceSolver = $priceSolver;
  24. }
  25. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  26. {
  27. $query->orderBy('id');
  28. return $query;
  29. }
  30. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  31. {
  32. $this->addFilterByMerchantRequired($query);
  33. $query->filterIsOnlineAndOffline();
  34. return $query;
  35. }
  36. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  37. {
  38. return $query;
  39. }
  40. // getReductionCartByCode
  41. public function getByCode(string $code, $query = null)
  42. {
  43. $query = $this->createDefaultQuery($query);
  44. $query->filterByCode($code);
  45. $reductionCarts = $query->find();
  46. $findReductionCart = null;
  47. foreach ($reductionCarts as $reductionCart) {
  48. if ($reductionCart && in_array($code, $reductionCart->getCodes())) {
  49. $findReductionCart = $reductionCart;
  50. }
  51. }
  52. return $findReductionCart;
  53. }
  54. //Toutes les reductionCart d'un utilisateur inter/merchant
  55. public function getByUserOutOfContext(UserInterface $user, $query = null)
  56. {
  57. $query = $this->createQuery($query);
  58. $query->filterIsOnlineAndOffline();
  59. $query->filterByUser($user);
  60. return $query->find();
  61. }
  62. }