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

ReductionCartStore.php 2.1KB

3 年前
3 年前
3 年前
3 年前
3 年前
3 年前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
  4. use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
  5. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  6. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  7. use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver;
  8. use Lc\SovBundle\Model\User\UserInterface;
  9. use Lc\SovBundle\Repository\AbstractStore;
  10. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  11. use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
  12. class ReductionCartStore extends AbstractStore
  13. {
  14. use SectionStoreTrait;
  15. protected ReductionCartRepositoryQuery $query;
  16. protected ReductionCartSolver $reductionCartSolver;
  17. protected PriceSolver $priceSolver;
  18. public function __construct(
  19. ReductionCartRepositoryQuery $query,
  20. ReductionCartSolver $reductionCartSolver,
  21. PriceSolver $priceSolver
  22. ) {
  23. $this->query = $query;
  24. $this->reductionCartSolver = $reductionCartSolver;
  25. $this->priceSolver = $priceSolver;
  26. }
  27. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  28. {
  29. $query->orderBy('id');
  30. return $query;
  31. }
  32. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  33. {
  34. if($this->section) {
  35. $query->filterBySection($this->section);
  36. }
  37. $query->filterIsOnlineAndOffline();
  38. return $query;
  39. }
  40. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  41. {
  42. return $query;
  43. }
  44. // getReductionCartByCode
  45. public function getByCode(string $code, $query = null)
  46. {
  47. $query = $this->createDefaultQuery($query);
  48. $query->filterByCode($code);
  49. $reductionCarts = $query->find();
  50. $findReductionCart = null;
  51. foreach ($reductionCarts as $reductionCart) {
  52. if ($reductionCart && in_array($code, $reductionCart->getCodes())) {
  53. $findReductionCart = $reductionCart;
  54. }
  55. }
  56. return $findReductionCart;
  57. }
  58. }