Просмотр исходного кода

CreditHistory répo

packProduct
Charly 3 лет назад
Родитель
Сommit
a0411ca896
5 измененных файлов: 80 добавлений и 3 удалений
  1. +1
    -1
      Model/Credit/CreditHistoryModel.php
  2. +46
    -0
      Repository/Credit/CreditHistoryRepositoryQuery.php
  3. +31
    -0
      Repository/Credit/CreditHistoryStore.php
  4. +1
    -1
      Repository/User/UserRepositoryQuery.php
  5. +1
    -1
      Repository/User/UserStore.php

+ 1
- 1
Model/Credit/CreditHistoryModel.php Просмотреть файл

@@ -29,7 +29,7 @@ abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffI
const MEAN_PAYMENT_CASH = 'cash';


/**
/**$merchant
* @ORM\Column(type="float", nullable=true)
*/
protected $amount;

+ 46
- 0
Repository/Credit/CreditHistoryRepositoryQuery.php Просмотреть файл

@@ -2,13 +2,59 @@

namespace Lc\CaracoleBundle\Repository\Credit;

use App\Entity\Merchant\Merchant;
use App\Entity\User\UserMerchant;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
use DateTime;

class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
{
protected $isJoinUserMerchants = false;

public function __construct(CreditHistoryRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}

public function joinUserMerchant(): self
{
if (!$this->isJoinUserMerchants) {
$this->isJoinUserMerchants = true;

return $this
->innerJoin('.userMerchant', 'um');
}
return $this;
}

public function filterByJoinUserMerchant(Merchant $merchant): self
{
$this->joinUserMerchant();
return $this
->andWhere('um.merchant = :merchant')
->setParameter('merchant', $merchant);
}

public function filterByUserMerchant(UserMerchant $userMerchant): self
{
return $this
->andWhere('.userMerchant = :userMerchant')
->setParameter('userMerchant', $userMerchant);
}

public function filterByDateStart(DateTime $dateStart): self
{
return $this
->andWhere('.createdAt >= :dateStart')
->setParameter(':dateStart', $dateStart);
}

public function filterByDateEnd(DateTime $dateEnd): self
{
return $this
->andWhere('.createdAt <= :dateEnd')
->setParameter(':dateEnd', $dateEnd);
}
}

+ 31
- 0
Repository/Credit/CreditHistoryStore.php Просмотреть файл

@@ -2,14 +2,45 @@

namespace Lc\CaracoleBundle\Repository\Credit;

use App\Entity\User\UserMerchant;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use DateTime;

class CreditHistoryStore extends AbstractStore
{
use MerchantStoreTrait;

protected CreditHistoryRepositoryQuery $query;

public function __construct(CreditHistoryRepositoryQuery $query)
{
$this->query = $query;
}

//findAllByDateStartEnd
public function getByDateStartEnd(DateTime $dateStart, DateTime $dateEnd): array
{
$query = $this->query->create();

$query
->filterByJoinUserMerchant($this->merchant)
->filterByDateStart($dateStart)
->filterByDateEnd($dateEnd)
->orderBy('.createdAt');

return $query->find();
}

//findAllByUserMerchant
public function getByUserMerchant(UserMerchant $userMerchant): array
{
$query = $this->query->create();

$query
->filterByUserMerchant($userMerchant)
->orderBy('.createdAt', 'DESC');

return $query->find();
}
}

+ 1
- 1
Repository/User/UserRepositoryQuery.php Просмотреть файл

@@ -30,7 +30,7 @@ class UserRepositoryQuery extends SovUserRepositoryQuery
->andWhere('um.active = 1');
}

public function filterByUserMerchant(Merchant $merchant): self
public function filterByJoinUserMerchant(Merchant $merchant): self
{
$this->joinUserMerchants();
return $this

+ 1
- 1
Repository/User/UserStore.php Просмотреть файл

@@ -18,7 +18,7 @@ class UserStore extends SovUserStore

if ($this->merchant) {
$query
->filterByUserMerchant($this->merchant)
->filterByJoinUserMerchant($this->merchant)
->filterMerchantIsActive();
}


Загрузка…
Отмена
Сохранить