Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

OrderShopRepositoryQuery.php 6.7KB

pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Order;
  3. use App\Entity\Delivery\DeliveryAvailabilityPointSale;
  4. use App\Entity\Delivery\DeliveryAvailabilityZone;
  5. use App\Entity\PointSale\PointSale;
  6. use Knp\Component\Pager\PaginatorInterface;
  7. use Lc\CaracoleBundle\Model\Address\AddressInterface;
  8. use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
  9. use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
  10. use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
  11. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
  12. use Lc\CaracoleBundle\Model\User\VisitorInterface;
  13. use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
  14. use Lc\SovBundle\Model\User\UserInterface;
  15. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  16. use DateTime;
  17. class OrderShopRepositoryQuery extends AbstractRepositoryQuery
  18. {
  19. use SectionRepositoryQueryTrait;
  20. protected bool $isJoinProduct = false;
  21. protected bool $isJoinOrderProduct = false;
  22. protected bool $isJoinOrderReductionCredits = false;
  23. protected bool $isJoinOrderReductionCarts = false;
  24. protected bool $isJoinOrderStatus = false;
  25. protected bool $isJoinMerchant = false;
  26. protected bool $isJoinSection = false;
  27. protected bool $isJoinComplementaryOrderShops = false;
  28. protected bool $isJoinDeliveryPointSale = false;
  29. public function __construct(OrderShopRepository $repository, PaginatorInterface $paginator)
  30. {
  31. parent::__construct($repository, 'r', $paginator);
  32. }
  33. // @TODO : nécessaire ?
  34. public function selectParam($select): self
  35. {
  36. return $this
  37. ->addSelect($select);
  38. }
  39. public function selectCount(): self
  40. {
  41. return $this
  42. ->select('count(r.id) as total');
  43. }
  44. public function filterByUser(UserInterface $user): self
  45. {
  46. return $this
  47. ->andWhere('.user = :user')
  48. ->setParameter('user', $user);
  49. }
  50. public function filterIsMerchantOnline(): self
  51. {
  52. $this->joinMerchant();
  53. return $this
  54. ->andWhere('merchant.status = :status')
  55. ->setParameter(':status', 1);
  56. }
  57. public function filterByDateStart(string $dateField, DateTime $dateStart): self
  58. {
  59. return $this
  60. ->andWhere('.' . $dateField . ' >= :dateStart')
  61. ->setParameter('dateStart', $dateStart);
  62. }
  63. public function filterByDateEnd(string $dateField, DateTime $dateEnd): self
  64. {
  65. return $this
  66. ->andWhere('.' . $dateField . ' <= :dateEnd')
  67. ->setParameter('dateEnd', $dateEnd);
  68. }
  69. public function filterByVisitor(VisitorInterface $visitor): self
  70. {
  71. return $this
  72. ->andWhere('.visitor = :visitor')
  73. ->setParameter('visitor', $visitor);
  74. }
  75. public function filterByAddress(AddressInterface $address): self
  76. {
  77. return $this
  78. ->andWhere('.deliveryAddress = :address OR .invoiceAddress = :address')
  79. ->setParameter('address', $address);
  80. }
  81. public function filterByStatus(array $statusArray): self
  82. {
  83. $this->joinOrderStatus();
  84. return $this
  85. ->andWhere('os.alias IN (:alias)')
  86. ->setParameter('alias', $statusArray);
  87. }
  88. public function filterByReductionCredit(ReductionCreditInterface $reductionCredit): self
  89. {
  90. $this->joinOrderReductionCredits();
  91. return $this
  92. ->andWhere('orc.reductionCredit = :reductionCredit')
  93. ->setParameter('reductionCredit', $reductionCredit);
  94. }
  95. public function filterByReductionCart(ReductionCartInterface $reductionCart): self
  96. {
  97. $this->joinOrderReductionCarts();
  98. return $this
  99. ->andWhere('orcart.reductionCart = :reductionCart')
  100. ->setParameter('reductionCart', $reductionCart);
  101. }
  102. public function filterByCycleNumber(int $cycleNumber): self
  103. {
  104. return $this
  105. ->andWhere('.cycleNumber = :cycleNumber')
  106. ->setParameter('cycleNumber', $cycleNumber);
  107. }
  108. public function filterIsNotComplementaryOrderShop(): self
  109. {
  110. return $this
  111. ->andWhere('.mainOrderShop = false OR .mainOrderShop IS NULL');
  112. }
  113. public function filterIsNullMainOrderShop(): self
  114. {
  115. return $this
  116. ->andWhere('.mainOrderShop IS NULL');
  117. }
  118. public function selectOrderReductionCarts(): self
  119. {
  120. $this->joinOrderReductionCarts();
  121. return $this->addSelect('orcart');
  122. }
  123. public function joinOrderProduct(): self
  124. {
  125. if (!$this->isJoinOrderProduct) {
  126. $this->isJoinOrderProduct = true;
  127. return $this
  128. ->innerJoin('.orderProducts', 'op');
  129. }
  130. return $this;
  131. }
  132. public function joinOrderReductionCredits(): self
  133. {
  134. if (!$this->isJoinOrderReductionCredits) {
  135. $this->isJoinOrderReductionCredits = true;
  136. return $this
  137. ->innerJoin('.orderReductionCredits', 'orc');
  138. }
  139. return $this;
  140. }
  141. public function joinOrderStatus(): self
  142. {
  143. if (!$this->isJoinOrderStatus) {
  144. $this->isJoinOrderStatus = true;
  145. return $this
  146. ->leftJoin('.orderStatus', 'os');
  147. }
  148. return $this;
  149. }
  150. public function joinOrderReductionCarts(): self
  151. {
  152. if (!$this->isJoinOrderReductionCarts) {
  153. $this->isJoinOrderReductionCarts = true;
  154. return $this
  155. ->leftJoin('.orderReductionCarts', 'orcart');
  156. }
  157. return $this;
  158. }
  159. public function joinMerchant(): self
  160. {
  161. $this->joinSection();
  162. if (!$this->isJoinMerchant) {
  163. $this->isJoinMerchant = true;
  164. return $this
  165. ->leftJoin('s.merchant', 'merchant');
  166. }
  167. return $this;
  168. }
  169. public function joinSection(): self
  170. {
  171. if (!$this->isJoinSection) {
  172. $this->isJoinSection = true;
  173. return $this
  174. ->leftJoin('.section', 's');
  175. }
  176. return $this;
  177. }
  178. public function joinComplementaryOrderShops(): self
  179. {
  180. if (!$this->isJoinComplementaryOrderShops) {
  181. $this->isJoinComplementaryOrderShops = true;
  182. return $this
  183. ->leftJoin('.complementaryOrderShops', 'complementaryOrderShops');
  184. }
  185. return $this;
  186. }
  187. public function joinDeliveryPointSale(): self
  188. {
  189. if (!$this->isJoinDeliveryPointSale) {
  190. $this->isJoinDeliveryPointSale = true;
  191. return $this
  192. ->leftJoin('.deliveryPointSale', 'pointSale');
  193. }
  194. return $this;
  195. }
  196. }