You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0KB

  1. <?php
  2. namespace common\logic\Payment\Repository;
  3. use common\logic\AbstractRepositoryQuery;
  4. use common\logic\Order\Order\Model\Order;
  5. use common\logic\Payment\Service\PaymentDefinition;
  6. use common\logic\User\User\Model\User;
  7. class PaymentRepositoryQuery extends AbstractRepositoryQuery
  8. {
  9. protected PaymentDefinition $definition;
  10. public function loadDependencies(): void
  11. {
  12. $this->loadDefinition(PaymentDefinition::class);
  13. }
  14. public function filterByOrder(Order $order): self
  15. {
  16. $this->andWhere(['id_order' => $order->id]);
  17. return $this;
  18. }
  19. public function filterByUser(User $user): self
  20. {
  21. $this->andWhere(['id_user' => $user->id]);
  22. return $this;
  23. }
  24. public function filterIsCredit()
  25. {
  26. $this->andWhere("payment.type = 'initial-credit' OR payment.type = 'credit' OR payment.type = 'debit' OR (payment.type = 'payment' AND payment.mean_payment = 'credit') OR (payment.type = 'refund' AND payment.mean_payment = 'credit')");
  27. return $this;
  28. }
  29. }