瀏覽代碼

Refactoring repositories #1084

feature/souke
Guillaume 1 年之前
父節點
當前提交
d13161ccfd
共有 60 個文件被更改,包括 453 次插入197 次删除
  1. +10
    -0
      common/logic/AbstractDefinition.php
  2. +21
    -1
      common/logic/AbstractRepository.php
  3. +21
    -2
      common/logic/AbstractRepositoryQuery.php
  4. +1
    -0
      common/logic/AbstractService.php
  5. +6
    -6
      common/logic/Config/TaxRate/Repository/TaxRateRepository.php
  6. +3
    -2
      common/logic/Config/TaxRate/Repository/TaxRateRepositoryQuery.php
  7. +8
    -0
      common/logic/DefinitionInterface.php
  8. +27
    -51
      common/logic/Distribution/Distribution/Repository/DistributionRepository.php
  9. +45
    -4
      common/logic/Distribution/Distribution/Repository/DistributionRepositoryQuery.php
  10. +14
    -0
      common/logic/Distribution/Distribution/Service/DistributionDefinition.php
  11. +8
    -1
      common/logic/Distribution/Distribution/Wrapper/DistributionContainer.php
  12. +17
    -17
      common/logic/Distribution/PointSaleDistribution/Repository/PointSaleDistributionRepository.php
  13. +27
    -0
      common/logic/Distribution/PointSaleDistribution/Repository/PointSaleDistributionRepositoryQuery.php
  14. +14
    -0
      common/logic/Distribution/PointSaleDistribution/Service/PointSaleDistributionDefinition.php
  15. +8
    -2
      common/logic/Distribution/PointSaleDistribution/Wrapper/PointSaleDistributionContainer.php
  16. +4
    -4
      common/logic/Distribution/ProductDistribution/Repository/ProductDistributionRepository.php
  17. +6
    -1
      common/logic/Distribution/ProductDistribution/Repository/ProductDistributionRepositoryQuery.php
  18. +4
    -4
      common/logic/Document/DeliveryNote/Repository/DeliveryNoteRepository.php
  19. +6
    -1
      common/logic/Document/DeliveryNote/Repository/DeliveryNoteRepositoryQuery.php
  20. +4
    -4
      common/logic/Document/Invoice/Repository/InvoiceRepository.php
  21. +6
    -1
      common/logic/Document/Invoice/Repository/InvoiceRepositoryQuery.php
  22. +4
    -4
      common/logic/Document/Quotation/Repository/QuotationRepository.php
  23. +6
    -1
      common/logic/Document/Quotation/Repository/QuotationRepositoryQuery.php
  24. +4
    -4
      common/logic/Order/Order/Repository/OrderRepository.php
  25. +6
    -1
      common/logic/Order/Order/Repository/OrderRepositoryQuery.php
  26. +4
    -4
      common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepository.php
  27. +6
    -1
      common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepositoryQuery.php
  28. +4
    -4
      common/logic/Order/ProductOrder/Repository/ProductOrderRepository.php
  29. +6
    -1
      common/logic/Order/ProductOrder/Repository/ProductOrderRepositoryQuery.php
  30. +4
    -4
      common/logic/PointSale/PointSale/Repository/PointSaleRepository.php
  31. +6
    -1
      common/logic/PointSale/PointSale/Repository/PointSaleRepositoryQuery.php
  32. +4
    -4
      common/logic/PointSale/UserPointSale/Repository/UserPointSaleRepository.php
  33. +6
    -1
      common/logic/PointSale/UserPointSale/Repository/UserPointSaleRepositoryQuery.php
  34. +4
    -4
      common/logic/Producer/Producer/Repository/ProducerRepository.php
  35. +6
    -1
      common/logic/Producer/Producer/Repository/ProducerRepositoryQuery.php
  36. +4
    -4
      common/logic/Producer/ProducerPriceRange/Repository/ProducerPriceRangeRepository.php
  37. +6
    -1
      common/logic/Producer/ProducerPriceRange/Repository/ProducerPriceRangeRepositoryQuery.php
  38. +4
    -4
      common/logic/Product/Product/Repository/ProductRepository.php
  39. +6
    -1
      common/logic/Product/Product/Repository/ProductRepositoryQuery.php
  40. +4
    -4
      common/logic/Product/ProductCategory/Repository/ProductCategoryRepository.php
  41. +6
    -1
      common/logic/Product/ProductCategory/Repository/ProductCategoryRepositoryQuery.php
  42. +4
    -4
      common/logic/Product/ProductPointSale/Repository/ProductPointSaleRepository.php
  43. +6
    -1
      common/logic/Product/ProductPointSale/Repository/ProductPointSaleRepositoryQuery.php
  44. +4
    -4
      common/logic/Product/ProductPrice/Repository/ProductPriceRepository.php
  45. +6
    -1
      common/logic/Product/ProductPrice/Repository/ProductPriceRepositoryQuery.php
  46. +3
    -1
      common/logic/RepositoryQueryInterface.php
  47. +4
    -4
      common/logic/Subscription/ProductSubscription/Repository/ProductSubscriptionRepository.php
  48. +6
    -1
      common/logic/Subscription/ProductSubscription/Repository/ProductSubscriptionRepositoryQuery.php
  49. +4
    -4
      common/logic/Subscription/Subscription/Repository/SubscriptionRepository.php
  50. +6
    -1
      common/logic/Subscription/Subscription/Repository/SubscriptionRepositoryQuery.php
  51. +4
    -4
      common/logic/User/CreditHistory/Repository/CreditHistoryRepository.php
  52. +6
    -1
      common/logic/User/CreditHistory/Repository/CreditHistoryRepositoryQuery.php
  53. +4
    -4
      common/logic/User/User/Repository/UserRepository.php
  54. +6
    -1
      common/logic/User/User/Repository/UserRepositoryQuery.php
  55. +4
    -4
      common/logic/User/UserGroup/Repository/UserGroupRepository.php
  56. +6
    -1
      common/logic/User/UserGroup/Repository/UserGroupRepositoryQuery.php
  57. +4
    -4
      common/logic/User/UserProducer/Repository/UserProducerRepository.php
  58. +6
    -1
      common/logic/User/UserProducer/Repository/UserProducerRepositoryQuery.php
  59. +4
    -4
      common/logic/User/UserUserGroup/Repository/UserUserGroupRepository.php
  60. +6
    -1
      common/logic/User/UserUserGroup/Repository/UserUserGroupRepositoryQuery.php

+ 10
- 0
common/logic/AbstractDefinition.php 查看文件

@@ -0,0 +1,10 @@
<?php

namespace common\logic;

use yii\db\ActiveRecord;

abstract class AbstractDefinition extends AbstractService implements DefinitionInterface
{

}

+ 21
- 1
common/logic/AbstractRepository.php 查看文件

@@ -4,6 +4,11 @@ namespace common\logic;

abstract class AbstractRepository extends AbstractService implements RepositoryInterface
{
const WITH = 'with';
const JOIN_WITH = 'join_with';
const ORDER_BY = 'orderby';
const ATTRIBUTE_ID_PRODUCER = 'attribute_id_producer';

public function createQuery()
{
$this->repositoryQuery->createQuery();
@@ -17,11 +22,26 @@ abstract class AbstractRepository extends AbstractService implements RepositoryI

$defaultOptions = $this->getDefaultOptionsSearch();

// id producer
// with
if (is_array($defaultOptions['with']) && count($defaultOptions['with'])) {
$this->repositoryQuery->with($defaultOptions['with']);
}

// join with
if (is_array($defaultOptions['join_with']) && count($defaultOptions['join_with'])) {
$this->repositoryQuery->joinWith($defaultOptions['join_with']);
}

// id producer contexte
if(isset($defaultOptions['attribute_id_producer']) && $defaultOptions['attribute_id_producer']) {
$this->repositoryQuery->andWhere([$defaultOptions['attribute_id_producer'] => $this->getProducerContextId()]);
}

// order by
if(isset($defaultOptions['orderby']) && $defaultOptions['orderby']) {
$this->repositoryQuery->orderBy($defaultOptions['orderby']);
}

return $this->repositoryQuery;
}
}

+ 21
- 2
common/logic/AbstractRepositoryQuery.php 查看文件

@@ -2,11 +2,20 @@

namespace common\logic;

use common\components\ActiveRecordCommon;
use yii\db\ActiveQuery;

class AbstractRepositoryQuery extends AbstractService implements RepositoryQueryInterface
abstract class AbstractRepositoryQuery extends AbstractService implements RepositoryQueryInterface
{
protected ActiveQuery $query;
protected DefinitionInterface $definition;

public function createQuery(): self
{
$this->query = $this->baseQuery();

return $this;
}

public function __call(string $name, $params): self
{
@@ -15,6 +24,14 @@ class AbstractRepositoryQuery extends AbstractService implements RepositoryQuery
return $this;
}

public function count()
{
$class = $this->definition->getEntityFqcn();
$class::groupByPrimaryKey($class, $this->query);

return $this->query->count();
}

public function find()
{
return $this->query->all();
@@ -25,8 +42,10 @@ class AbstractRepositoryQuery extends AbstractService implements RepositoryQuery
return $this->query->one();
}

public function filterById(int $id)
public function filterById(int $id): self
{
$this->query->andWhere(['id' => $id]);

return $this;
}
}

+ 1
- 0
common/logic/AbstractService.php 查看文件

@@ -11,6 +11,7 @@ abstract class AbstractService extends AbstractSingleton implements ServiceInter
protected function getHierarchy(): array
{
return [
DefinitionInterface::class,
SolverInterface::class,
RepositoryQueryInterface::class,
RepositoryInterface::class,

+ 6
- 6
common/logic/Config/TaxRate/Repository/TaxRateRepository.php 查看文件

@@ -8,20 +8,20 @@ use yii\db\ActiveQuery;

class TaxRateRepository extends AbstractRepository
{
protected TaxRateRepositoryQuery $query;
protected TaxRateRepositoryQuery $repositoryQuery;

public function loadDependencies(): void
{
$this->query = $this->loadService(TaxRateRepositoryQuery::class);
$this->repositoryQuery = $this->loadService(TaxRateRepositoryQuery::class);
}

public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => 'pourcent ASC',
'attribute_id_producer' => ''
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => 'pourcent ASC',
self::ATTRIBUTE_ID_PRODUCER => ''
] ;
}


+ 3
- 2
common/logic/Config/TaxRate/Repository/TaxRateRepositoryQuery.php 查看文件

@@ -4,11 +4,12 @@ namespace common\logic\Config\TaxRate\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Config\TaxRate\Model\TaxRate;
use yii\db\ActiveQuery;

class TaxRateRepositoryQuery extends AbstractRepositoryQuery
{
public function createQuery()
public function baseQuery(): ActiveQuery
{
$this->query = TaxRate::find();
return TaxRate::find();
}
}

+ 8
- 0
common/logic/DefinitionInterface.php 查看文件

@@ -0,0 +1,8 @@
<?php

namespace common\logic;

interface DefinitionInterface
{

}

+ 27
- 51
common/logic/Distribution/Distribution/Repository/DistributionRepository.php 查看文件

@@ -2,7 +2,6 @@

namespace common\logic\Distribution\Distribution\Repository;

use common\helpers\GlobalParam;
use common\logic\AbstractRepository;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\Distribution\Service\DistributionSolver;
@@ -25,10 +24,10 @@ class DistributionRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => 'date ASC',
'attribute_id_producer' => 'distribution.id_producer'
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => 'date ASC',
self::ATTRIBUTE_ID_PRODUCER => 'distribution.id_producer'
];
}

@@ -51,25 +50,24 @@ class DistributionRepository extends AbstractRepository

public function findOneFirstDistribution(): ?Distribution
{
return Distribution::searchOne([], [
'orderby' => 'date ASC'
]);
return $this->createDefaultQuery()
->orderBy('date ASC')
->findOne();
}

public function findOneLastDistribution(): ?Distribution
{
return Distribution::searchOne([], [
'orderby' => 'date DESC'
]);
return $this->createDefaultQuery()
->orderBy('date DESC')
->findOne();
}

public function findDistributionsActive(): array
{
return Distribution::searchAll([
'active' => 1
], [
'orderby' => 'date ASC',
]);
return $this->createDefaultQuery()
->filterByActive(true)
->orderBy('date ASC')
->find();
}

/**
@@ -77,51 +75,34 @@ class DistributionRepository extends AbstractRepository
*/
public function findDistributionsIncoming($ignoreActive = false): array
{
$paramsWhere = [
'id_producer' => $this->getProducerContext()->id,
];
$query = $this->createDefaultQuery();

if(!$ignoreActive) {
$paramsWhere['active'] = 1;
$query->filterByActive(true);
}

$distributionsArray = Distribution::find()
->where('date > \'' . date('Y-m-d') . '\'')
->andWhere($paramsWhere)
->orderBy('date ASC')
->all();
$query
->filterByDateBetterThanToday()
->orderBy('date ASC');

return $distributionsArray;
return $query->find();
}

/**
* Recherche les distributions futures où l'abonnement peut s'appliquer.
*/
// searchMatchedIncomingDistributions
public function findDistributionsIncomingMatchWithSubscrtiption(Subscription $subscription, bool $filterByOrderDeadline = false): array
{
$params = [
':date_earliest_order' => date('Y-m-d'),
':date_begin' => date('Y-m-d', strtotime($subscription->date_begin)),
':id_producer' => GlobalParam::getCurrentProducerId()
];
$incomingDistributionsArray = $this->createDefaultQuery()
->filterByDateBetterThanToday()
->filterBySubscriptionDates($subscription)
->find();

$incomingDistributions = Distribution::find()
->where('id_producer = :id_producer')
->andWhere('date >= :date_begin')
->andWhere('date > :date_earliest_order');

if ($subscription->date_end) {
$incomingDistributions->andWhere('date <= :date_end');
$params[':date_end'] = date('Y-m-d', strtotime($subscription->date_end));
if($filterByOrderDeadline) {
$incomingDistributionsArray = $this->distributionSolver
->filterDistributionsByDateDelay($incomingDistributionsArray);
}

$incomingDistributions->orderBy('date ASC');

$incomingDistributions->params($params);
$incomingDistributionsArray = $incomingDistributions->all();
$this->distributionSolver->filterDistributionsByDateDelay($incomingDistributionsArray);

$matchedIncomingDistributionsArray = [];
foreach ($incomingDistributionsArray as $incomingDistribution) {
if ($this->subscriptionSolver->isSubscriptionMatchWith($subscription, $incomingDistribution->date)) {
@@ -129,14 +110,9 @@ class DistributionRepository extends AbstractRepository
}
}

if($filterByOrderDeadline) {
$matchedIncomingDistributionsArray = $this->distributionSolver->filterDistributionsByDateDelay($matchedIncomingDistributionsArray);
}

return $matchedIncomingDistributionsArray;
}

// isDateAvailable
public function isDistributionDateAvailable(string $date = null): bool
{
if($date && strlen($date)) {

+ 45
- 4
common/logic/Distribution/Distribution/Repository/DistributionRepositoryQuery.php 查看文件

@@ -4,21 +4,62 @@ namespace common\logic\Distribution\Distribution\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\Distribution\Service\DistributionDefinition;
use common\logic\Subscription\Subscription\Model\Subscription;
use yii\db\ActiveQuery;

class DistributionRepositoryQuery extends AbstractRepositoryQuery
{
public function createQuery()
public function loadDependencies(): void
{
$this->query = Distribution::find();
$this->definition = $this->loadService(DistributionDefinition::class);
}

return $this;
public function baseQuery(): ActiveQuery
{
$class = $this->definition->getEntityFqcn();
return $class::find();
}

public function filterByDate(string $date)
public function filterByDate(string $date): self
{
$this->query->andWhere(['date' => $date]);

return $this;
}

public function filterByActive(bool $active): self
{
$this->query->andWhere(['active' => $active]);

return $this;
}

public function filterByDateBetterThanToday(): self
{
$this->query
->andWhere('date > :date')
->addParams(['date' => date('Y-m-d') ]);

return $this;
}

public function filterBySubscriptionDates(Subscription $subscription): self
{
$this->query
->andWhere('date >= :date_begin')
->addParams([
'date_begin' => date('Y-m-d', strtotime($subscription->date_begin)),
]);

if($subscription->date_end) {
$this->query
->andWhere('date <= :date_end')
->addParams([
'date_end' => date('Y-m-d', strtotime($subscription->date_end))
]);
}

return $this;
}
}

+ 14
- 0
common/logic/Distribution/Distribution/Service/DistributionDefinition.php 查看文件

@@ -0,0 +1,14 @@
<?php

namespace common\logic\Distribution\Distribution\Service;

use common\logic\AbstractDefinition;
use common\logic\Distribution\Distribution\Model\Distribution;

class DistributionDefinition extends AbstractDefinition
{
public function getEntityFqcn(): string
{
return Distribution::class;
}
}

+ 8
- 1
common/logic/Distribution/Distribution/Wrapper/DistributionContainer.php 查看文件

@@ -6,24 +6,31 @@ use common\logic\AbstractContainer;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\Distribution\Repository\DistributionRepository;
use common\logic\Distribution\Distribution\Service\DistributionBuilder;
use common\logic\Distribution\Distribution\Service\DistributionDefinition;
use common\logic\Distribution\Distribution\Service\DistributionSolver;

class DistributionContainer extends AbstractContainer
{
public function getEntityFqcn(): string
{
return Distribution::class;
return $this->getDefinition()->getEntityFqcn();
}

public function getServices(): array
{
return [
DistributionDefinition::class,
DistributionSolver::class,
DistributionRepository::class,
DistributionBuilder::class
];
}

public function getDefinition(): DistributionDefinition
{
return DistributionDefinition::getInstance();
}

public function getSolver(): DistributionSolver
{
return DistributionSolver::getInstance();

+ 17
- 17
common/logic/Distribution/PointSaleDistribution/Repository/PointSaleDistributionRepository.php 查看文件

@@ -9,42 +9,42 @@ use common\logic\PointSale\PointSale\Model\PointSale;

class PointSaleDistributionRepository extends AbstractRepository
{
protected PointSaleDistributionRepositoryQuery $query;
protected PointSaleDistributionRepositoryQuery $repositoryQuery;

public function loadDependencies(): void
{
$this->query = $this->loadService(PointSaleDistributionRepositoryQuery::class);
$this->repositoryQuery = $this->loadService(PointSaleDistributionRepositoryQuery::class);
}

public function getDefaultOptionsSearch(): array
{
return [
'with' => ['distribution', 'pointSale'],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
] ;
self::WITH => ['distribution', 'pointSale'],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}

public function findOnePointSaleDistribution(Distribution $distribution, PointSale $pointSale): ?PointSaleDistribution
{
return PointSaleDistribution::searchOne([
'id_distribution' => $distribution->id,
'id_point_sale' => $pointSale->id
]);
return $this->createDefaultQuery()
->filterByDistribution($distribution)
->filterByPointSale($pointSale)
->findOne();
}

public function findPointSaleDistributionsByDistribution(Distribution $distribution): array
{
return PointSaleDistribution::searchAll([
'id_distribution' => $distribution->id
]) ;
return $this->createDefaultQuery()
->filterByDistribution($distribution)
->find();
}

public function countPointSaleDistributionsByDistribution(Distribution $distribution): int
{
return PointSaleDistribution::searchCount([
'id_distribution' => $distribution->id
]);
return $this->createDefaultQuery()
->filterByDistribution($distribution)
->count();
}
}

+ 27
- 0
common/logic/Distribution/PointSaleDistribution/Repository/PointSaleDistributionRepositoryQuery.php 查看文件

@@ -3,8 +3,35 @@
namespace common\logic\Distribution\PointSaleDistribution\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionDefinition;
use common\logic\PointSale\PointSale\Model\PointSale;
use yii\db\ActiveQuery;

class PointSaleDistributionRepositoryQuery extends AbstractRepositoryQuery
{
public function loadDependencies(): void
{
$this->definition = $this->loadService(PointSaleDistributionDefinition::class);
}

public function baseQuery(): ActiveQuery
{
$class = $this->definition->getEntityFqcn();
return $class::find();
}

public function filterByDistribution(Distribution $distribution): self
{
$this->andWhere(['id_distribution' => $distribution->id]);

return $this;
}

public function filterByPointSale(PointSale $pointSale): self
{
$this->andWhere(['id_point_sale' => $pointSale->id]);

return $this;
}
}

+ 14
- 0
common/logic/Distribution/PointSaleDistribution/Service/PointSaleDistributionDefinition.php 查看文件

@@ -0,0 +1,14 @@
<?php

namespace common\logic\Distribution\PointSaleDistribution\Service;

use common\logic\AbstractDefinition;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;

class PointSaleDistributionDefinition extends AbstractDefinition
{
public function getEntityFqcn(): string
{
return PointSaleDistribution::class;
}
}

+ 8
- 2
common/logic/Distribution/PointSaleDistribution/Wrapper/PointSaleDistributionContainer.php 查看文件

@@ -3,25 +3,31 @@
namespace common\logic\Distribution\PointSaleDistribution\Wrapper;

use common\logic\AbstractContainer;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\Distribution\PointSaleDistribution\Repository\PointSaleDistributionRepository;
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder;
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionDefinition;

class PointSaleDistributionContainer extends AbstractContainer
{
public function getEntityFqcn(): string
{
return PointSaleDistribution::class;
return $this->getDefinition()->getEntityFqcn();
}

public function getServices(): array
{
return [
PointSaleDistributionDefinition::class,
PointSaleDistributionRepository::class,
PointSaleDistributionBuilder::class,
];
}

public function getDefinition(): PointSaleDistributionDefinition
{
return PointSaleDistributionDefinition::getInstance();
}

public function getRepository(): PointSaleDistributionRepository
{
return PointSaleDistributionRepository::getInstance();

+ 4
- 4
common/logic/Distribution/ProductDistribution/Repository/ProductDistributionRepository.php 查看文件

@@ -19,10 +19,10 @@ class ProductDistributionRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => ['product','distribution'],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
self::WITH => ['product','distribution'],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
] ;
}


+ 6
- 1
common/logic/Distribution/ProductDistribution/Repository/ProductDistributionRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Distribution\ProductDistribution\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution;
use yii\db\ActiveQuery;

class ProductDistributionRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return ProductDistribution::find();
}
}

+ 4
- 4
common/logic/Document/DeliveryNote/Repository/DeliveryNoteRepository.php 查看文件

@@ -17,10 +17,10 @@ class DeliveryNoteRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => ['user AS user_delivery_note', 'producer'],
'orderby' => 'date ASC',
'attribute_id_producer' => 'delivery_note.id_producer'
self::WITH => [],
self::JOIN_WITH => ['user AS user_delivery_note', 'producer'],
self::ORDER_BY => 'date ASC',
self::ATTRIBUTE_ID_PRODUCER => 'delivery_note.id_producer'
];
}


+ 6
- 1
common/logic/Document/DeliveryNote/Repository/DeliveryNoteRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Document\DeliveryNote\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use yii\db\ActiveQuery;

class DeliveryNoteRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return DeliveryNote::find();
}
}

+ 4
- 4
common/logic/Document/Invoice/Repository/InvoiceRepository.php 查看文件

@@ -17,10 +17,10 @@ class InvoiceRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => ['user AS user_invoice', 'producer'],
'orderby' => 'date ASC',
'attribute_id_producer' => 'invoice.id_producer'
self::WITH => [],
self::JOIN_WITH => ['user AS user_invoice', 'producer'],
self::ORDER_BY => 'date ASC',
self::ATTRIBUTE_ID_PRODUCER => 'invoice.id_producer'
];
}


+ 6
- 1
common/logic/Document/Invoice/Repository/InvoiceRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Document\Invoice\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Document\Invoice\Model\Invoice;
use yii\db\ActiveQuery;

class InvoiceRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return Invoice::find();
}
}

+ 4
- 4
common/logic/Document/Quotation/Repository/QuotationRepository.php 查看文件

@@ -17,10 +17,10 @@ class QuotationRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => ['user AS user_quotation', 'producer'],
'orderby' => 'date ASC',
'attribute_id_producer' => 'quotation.id_producer'
self::WITH => [],
self::JOIN_WITH => ['user AS user_quotation', 'producer'],
self::ORDER_BY => 'date ASC',
self::ATTRIBUTE_ID_PRODUCER => 'quotation.id_producer'
];
}


+ 6
- 1
common/logic/Document/Quotation/Repository/QuotationRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Document\Quotation\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Document\Quotation\Model\Quotation;
use yii\db\ActiveQuery;

class QuotationRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return Quotation::find();
}
}

+ 4
- 4
common/logic/Order/Order/Repository/OrderRepository.php 查看文件

@@ -41,20 +41,20 @@ class OrderRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [
self::WITH => [
'productOrder',
'productOrder.product',
'creditHistory',
'creditHistory.userAction',
'pointSale'
],
'join_with' => [
self::JOIN_WITH => [
'distribution',
'user',
'user.userProducer'
],
'orderby' => 'order.date ASC',
'attribute_id_producer' => 'distribution.id_producer'
self::ORDER_BY => 'order.date ASC',
self::ATTRIBUTE_ID_PRODUCER => 'distribution.id_producer'
];
}


+ 6
- 1
common/logic/Order/Order/Repository/OrderRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Order\Order\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Order\Order\Model\Order;
use yii\db\ActiveQuery;

class OrderRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return Order::find();
}
}

+ 4
- 4
common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepository.php 查看文件

@@ -16,10 +16,10 @@ class OrderStatusHistoryRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => ['order', 'orderStatus'],
'orderby' => 'date ASC',
'attribute_id_producer' => ''
self::WITH => [],
self::JOIN_WITH => ['order', 'orderStatus'],
self::ORDER_BY => 'date ASC',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}
}

+ 6
- 1
common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Order\OrderStatusHistory\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory;
use yii\db\ActiveQuery;

class OrderStatusHistoryRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return OrderStatusHistory::find();
}
}

+ 4
- 4
common/logic/Order/ProductOrder/Repository/ProductOrderRepository.php 查看文件

@@ -18,10 +18,10 @@ class ProductOrderRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => ['taxRate'],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
self::WITH => ['taxRate'],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}


+ 6
- 1
common/logic/Order/ProductOrder/Repository/ProductOrderRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Order\ProductOrder\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Order\ProductOrder\Model\ProductOrder;
use yii\db\ActiveQuery;

class ProductOrderRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return ProductOrder::find();
}
}

+ 4
- 4
common/logic/PointSale/PointSale/Repository/PointSaleRepository.php 查看文件

@@ -21,10 +21,10 @@ class PointSaleRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => 'is_bread_box ASC, name ASC',
'attribute_id_producer' => 'point_sale.id_producer'
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => 'is_bread_box ASC, name ASC',
self::ATTRIBUTE_ID_PRODUCER => 'point_sale.id_producer'
];
}


+ 6
- 1
common/logic/PointSale/PointSale/Repository/PointSaleRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\PointSale\PointSale\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\PointSale\PointSale\Model\PointSale;
use yii\db\ActiveQuery;

class PointSaleRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return PointSale::find();
}
}

+ 4
- 4
common/logic/PointSale/UserPointSale/Repository/UserPointSaleRepository.php 查看文件

@@ -19,10 +19,10 @@ class UserPointSaleRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
] ;
}


+ 6
- 1
common/logic/PointSale/UserPointSale/Repository/UserPointSaleRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\PointSale\UserPointSale\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\PointSale\UserPointSale\Model\UserPointSale;
use yii\db\ActiveQuery;

class UserPointSaleRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return UserPointSale::find();
}
}

+ 4
- 4
common/logic/Producer/Producer/Repository/ProducerRepository.php 查看文件

@@ -37,10 +37,10 @@ class ProducerRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => ['taxRate'],
'join_with' => [],
'orderby' => 'name ASC',
'attribute_id_producer' => 'id'
self::WITH => ['taxRate'],
self::JOIN_WITH => [],
self::ORDER_BY => 'name ASC',
self::ATTRIBUTE_ID_PRODUCER => 'id'
];
}


+ 6
- 1
common/logic/Producer/Producer/Repository/ProducerRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Producer\Producer\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Producer\Producer\Model\Producer;
use yii\db\ActiveQuery;

class ProducerRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return Producer::find();
}
}

+ 4
- 4
common/logic/Producer/ProducerPriceRange/Repository/ProducerPriceRangeRepository.php 查看文件

@@ -22,10 +22,10 @@ class ProducerPriceRangeRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}


+ 6
- 1
common/logic/Producer/ProducerPriceRange/Repository/ProducerPriceRangeRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Producer\ProducerPriceRange\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Producer\ProducerPriceRange\Model\ProducerPriceRange;
use yii\db\ActiveQuery;

class ProducerPriceRangeRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return ProducerPriceRange::find();
}
}

+ 4
- 4
common/logic/Product/Product/Repository/ProductRepository.php 查看文件

@@ -32,10 +32,10 @@ class ProductRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => ['taxRate', 'productPointSale'],
'join_with' => [],
'orderby' => 'order ASC',
'attribute_id_producer' => 'product.id_producer'
self::WITH => ['taxRate', 'productPointSale'],
self::JOIN_WITH => [],
self::ORDER_BY => 'order ASC',
self::ATTRIBUTE_ID_PRODUCER => 'product.id_producer'
];
}


+ 6
- 1
common/logic/Product/Product/Repository/ProductRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Product\Product\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Product\Product\Model\Product;
use yii\db\ActiveQuery;

class ProductRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return Product::find();
}
}

+ 4
- 4
common/logic/Product/ProductCategory/Repository/ProductCategoryRepository.php 查看文件

@@ -17,10 +17,10 @@ class ProductCategoryRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => 'id_producer'
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => 'id_producer'
];
}


+ 6
- 1
common/logic/Product/ProductCategory/Repository/ProductCategoryRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Product\ProductCategory\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Product\ProductCategory\Model\ProductCategory;
use yii\db\ActiveQuery;

class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return ProductCategory::find();
}
}

+ 4
- 4
common/logic/Product/ProductPointSale/Repository/ProductPointSaleRepository.php 查看文件

@@ -16,10 +16,10 @@ class ProductPointSaleRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => ['product', 'pointSale'],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
self::WITH => ['product', 'pointSale'],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
] ;
}
}

+ 6
- 1
common/logic/Product/ProductPointSale/Repository/ProductPointSaleRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Product\ProductPointSale\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Product\ProductPointSale\Model\ProductPointSale;
use yii\db\ActiveQuery;

class ProductPointSaleRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return ProductPointSale::find();
}
}

+ 4
- 4
common/logic/Product/ProductPrice/Repository/ProductPriceRepository.php 查看文件

@@ -24,10 +24,10 @@ class ProductPriceRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => ['user', 'pointSale', 'userGroup'],
'join_with' => ['product'],
'orderby' => '',
'attribute_id_producer' => 'product.id_producer'
self::WITH => ['user', 'pointSale', 'userGroup'],
self::JOIN_WITH => ['product'],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => 'product.id_producer'
];
}


+ 6
- 1
common/logic/Product/ProductPrice/Repository/ProductPriceRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Product\ProductPrice\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Product\ProductPrice\Model\ProductPrice;
use yii\db\ActiveQuery;

class ProductPriceRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return ProductPrice::find();
}
}

+ 3
- 1
common/logic/RepositoryQueryInterface.php 查看文件

@@ -2,7 +2,9 @@

namespace common\logic;

use yii\db\ActiveQuery;

interface RepositoryQueryInterface
{
public function baseQuery(): ActiveQuery;
}

+ 4
- 4
common/logic/Subscription/ProductSubscription/Repository/ProductSubscriptionRepository.php 查看文件

@@ -21,10 +21,10 @@ class ProductSubscriptionRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => ['product'],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
self::WITH => ['product'],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}


+ 6
- 1
common/logic/Subscription/ProductSubscription/Repository/ProductSubscriptionRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Subscription\ProductSubscription\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription;
use yii\db\ActiveQuery;

class ProductSubscriptionRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return ProductSubscription::find();
}
}

+ 4
- 4
common/logic/Subscription/Subscription/Repository/SubscriptionRepository.php 查看文件

@@ -22,10 +22,10 @@ class SubscriptionRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => ['producer'],
'join_with' => ['user', 'productSubscription', 'productSubscription.product', 'pointSale'],
'orderby' => 'user.name ASC',
'attribute_id_producer' => 'subscription.id_producer'
self::WITH => ['producer'],
self::JOIN_WITH => ['user', 'productSubscription', 'productSubscription.product', 'pointSale'],
self::ORDER_BY => 'user.name ASC',
self::ATTRIBUTE_ID_PRODUCER => 'subscription.id_producer'
];
}


+ 6
- 1
common/logic/Subscription/Subscription/Repository/SubscriptionRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\Subscription\Subscription\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Subscription\Subscription\Model\Subscription;
use yii\db\ActiveQuery;

class SubscriptionRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return Subscription::find();
}
}

+ 4
- 4
common/logic/User/CreditHistory/Repository/CreditHistoryRepository.php 查看文件

@@ -18,10 +18,10 @@ class CreditHistoryRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => CreditHistory::tableName() . '.date ASc',
'attribute_id_producer' => CreditHistory::tableName() . '.id_producer'
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => CreditHistory::tableName() . '.date ASc',
self::ATTRIBUTE_ID_PRODUCER => CreditHistory::tableName() . '.id_producer'
];
}


+ 6
- 1
common/logic/User/CreditHistory/Repository/CreditHistoryRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\User\CreditHistory\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\User\CreditHistory\Model\CreditHistory;
use yii\db\ActiveQuery;

class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return CreditHistory::find();
}
}

+ 4
- 4
common/logic/User/User/Repository/UserRepository.php 查看文件

@@ -36,10 +36,10 @@ class UserRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => ['userProducer', 'userUserGroup'],
'orderby' => 'user.name ASC, user.lastname ASC',
'attribute_id_producer' => ''
self::WITH => [],
self::JOIN_WITH => ['userProducer', 'userUserGroup'],
self::ORDER_BY => 'user.name ASC, user.lastname ASC',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}


+ 6
- 1
common/logic/User/User/Repository/UserRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\User\User\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\User\User\Model\User;
use yii\db\ActiveQuery;

class UserRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return User::find();
}
}

+ 4
- 4
common/logic/User/UserGroup/Repository/UserGroupRepository.php 查看文件

@@ -18,10 +18,10 @@ class UserGroupRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}


+ 6
- 1
common/logic/User/UserGroup/Repository/UserGroupRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\User\UserGroup\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\User\UserGroup\Model\UserGroup;
use yii\db\ActiveQuery;

class UserGroupRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return UserGroup::find();
}
}

+ 4
- 4
common/logic/User/UserProducer/Repository/UserProducerRepository.php 查看文件

@@ -19,10 +19,10 @@ class UserProducerRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => 'user_producer.id_producer'
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => 'user_producer.id_producer'
];
}


+ 6
- 1
common/logic/User/UserProducer/Repository/UserProducerRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\User\UserProducer\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\User\UserProducer\Model\UserProducer;
use yii\db\ActiveQuery;

class UserProducerRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return UserProducer::find();
}
}

+ 4
- 4
common/logic/User/UserUserGroup/Repository/UserUserGroupRepository.php 查看文件

@@ -18,10 +18,10 @@ class UserUserGroupRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
'with' => [],
'join_with' => [],
'orderby' => '',
'attribute_id_producer' => ''
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => ''
] ;
}


+ 6
- 1
common/logic/User/UserUserGroup/Repository/UserUserGroupRepositoryQuery.php 查看文件

@@ -3,8 +3,13 @@
namespace common\logic\User\UserUserGroup\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\User\UserUserGroup\Model\UserUserGroup;
use yii\db\ActiveQuery;

class UserUserGroupRepositoryQuery extends AbstractRepositoryQuery
{

public function baseQuery(): ActiveQuery
{
return UserUserGroup::find();
}
}

Loading…
取消
儲存