Przeglądaj źródła

Refactoring services

packProduct
Guillaume 3 lat temu
rodzic
commit
4ed14dec1c
30 zmienionych plików z 265 dodań i 250 usunięć
  1. +34
    -0
      Model/Order/OrderShopModel.php
  2. +2
    -2
      Repository/Config/TaxRateStore.php
  3. +2
    -2
      Repository/Config/UnitStore.php
  4. +4
    -4
      Repository/Credit/CreditHistoryStore.php
  5. +7
    -0
      Repository/Merchant/MerchantStore.php
  6. +1
    -1
      Repository/MerchantRepositoryQueryTrait.php
  7. +64
    -29
      Repository/Order/OrderShopRepositoryQuery.php
  8. +80
    -37
      Repository/Order/OrderShopStore.php
  9. +2
    -0
      Repository/Product/ProductCategoryRepository.php
  10. +1
    -5
      Repository/Product/ProductCategoryRepositoryQuery.php
  11. +1
    -41
      Repository/Product/ProductCategoryStore.php
  12. +5
    -5
      Repository/Reduction/ReductionCartStore.php
  13. +0
    -6
      Repository/Reduction/ReductionCatalogRepositoryQuery.php
  14. +1
    -1
      Repository/Reduction/ReductionCatalogStore.php
  15. +0
    -5
      Repository/Reduction/ReductionCreditRepositoryQuery.php
  16. +0
    -30
      Repository/Reduction/ReductionCreditStore.php
  17. +8
    -0
      Repository/Reminder/ReminderStore.php
  18. +1
    -1
      Repository/SectionRepositoryQueryTrait.php
  19. +12
    -0
      Repository/SectionStoreTrait.php
  20. +2
    -2
      Repository/Site/NewsRepositoryQuery.php
  21. +4
    -4
      Repository/Site/NewsStore.php
  22. +1
    -1
      Repository/Site/PageStore.php
  23. +2
    -2
      Repository/Ticket/TicketRepositoryQuery.php
  24. +14
    -31
      Repository/Ticket/TicketStore.php
  25. +5
    -4
      Repository/User/UserMerchantStore.php
  26. +1
    -1
      Repository/User/UserRepositoryQuery.php
  27. +0
    -14
      Repository/User/UserStore.php
  28. +2
    -4
      Repository/User/VisitorStore.php
  29. +1
    -1
      Resolver/MerchantResolver.php
  30. +8
    -17
      Resolver/OpeningResolver.php

+ 34
- 0
Model/Order/OrderShopModel.php Wyświetl plik

@@ -125,6 +125,15 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
*/
protected $cycleNumber;

/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $orderShopCreatedAt;

/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $idValidOrder;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Address\Address")
*/
@@ -610,6 +619,31 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
return $this;
}

public function getOrderShopCreatedAt(): ?\DateTimeInterface
{
return $this->orderShopCreatedAt;
}

public function setOrderShopCreatedAt(?\DateTimeInterface $orderShopCreatedAt): self
{
$this->orderShopCreatedAt = $orderShopCreatedAt;

return $this;
}

public function getIdValidOrder(): ?int
{
return $this->idValidOrder;
}

public function setIdValidOrder(?int $idValidOrder): self
{
$this->idValidOrder = $idValidOrder;

return $this;
}


public function getDeliveryAddress(): ?AddressInterface
{
return $this->deliveryAddress;

+ 2
- 2
Repository/Config/TaxRateStore.php Wyświetl plik

@@ -15,9 +15,9 @@ class TaxRateStore extends AbstractStore
$this->query = $query;
}

public function getAsArray(MerchantInterface $merchant)
public function getAsArray(MerchantInterface $merchant, $query = null)
{
$taxRates = $this->query->create()->find();
$taxRates = $this->createQuery($query)->find();

$taxRatesList = [];


+ 2
- 2
Repository/Config/UnitStore.php Wyświetl plik

@@ -13,9 +13,9 @@ class UnitStore extends AbstractStore
$this->query = $query;
}

public function getAsArray()
public function getAsArray($query = null)
{
$query = $this->query->create();
$query = $this->createQuery($query);

foreach ($query->find() as $unit) {
$unitsList[$unit->getId()]['unit'] = $unit->getUnit();

+ 4
- 4
Repository/Credit/CreditHistoryStore.php Wyświetl plik

@@ -19,9 +19,9 @@ class CreditHistoryStore extends AbstractStore
}

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

$query
->filterByJoinUserMerchant($this->merchant)
@@ -33,9 +33,9 @@ class CreditHistoryStore extends AbstractStore
}

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

$query
->filterByUserMerchant($userMerchant)

+ 7
- 0
Repository/Merchant/MerchantStore.php Wyświetl plik

@@ -14,4 +14,11 @@ class MerchantStore extends AbstractStore
$this->query = $query;
}

public function getOnline($query = null)
{
$query = $this->createQuery($query);
$query->filterIsOnline();
return $query->find();
}

}

+ 1
- 1
Repository/MerchantRepositoryQueryTrait.php Wyświetl plik

@@ -10,4 +10,4 @@ trait MerchantRepositoryQueryTrait
{
return $this->andWhereMerchant($this->id, $merchant);
}
}
}

+ 64
- 29
Repository/Order/OrderShopRepositoryQuery.php Wyświetl plik

@@ -9,6 +9,8 @@ use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Model\User\UserInterface;
@@ -24,6 +26,8 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
protected bool $isJoinOrderReductionCredits = false;
protected bool $isJoinOrderReductionCarts = false;
protected bool $isJoinOrderStatus = false;
protected bool $isJoinMerchant = false;
protected bool $isJoinSection = false;
protected bool $isJoinComplementaryOrderShops = false;
protected bool $isJoinDeliveryPointSale = false;

@@ -36,48 +40,56 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
public function selectParam($select): self
{
return $this
->addSelect($select);
->addSelect($select);
}

public function selectCount(): self
{
return $this
->select('count(r.id) as total');
->select('count(r.id) as total');
}

public function filterByUser(UserInterface $user): self
{
return $this
->andWhere('.user = :user')
->setParameter('user', $user);
->andWhere('.user = :user')
->setParameter('user', $user);
}

public function filterIsMerchantOnline(): self
{
$this->joinMerchant();
return $this
->andWhere('merchant.status = :status')
->setParameter(':status', 1);
}

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

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

public function filterByVisitor(VisitorInterface $visitor): self
{
return $this
->andWhere('.visitor = :visitor')
->setParameter('visitor', $visitor);
->andWhere('.visitor = :visitor')
->setParameter('visitor', $visitor);
}

public function filterByAddress(AddressInterface $address): self
{
return $this
->andWhere('.deliveryAddress = :address OR .invoiceAddress = :address')
->setParameter('address', $address);
->andWhere('.deliveryAddress = :address OR .invoiceAddress = :address')
->setParameter('address', $address);
}

public function filterByStatus(array $statusArray): self
@@ -85,45 +97,45 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
$this->joinOrderStatus();

return $this
->andWhere('os.alias IN (:alias)')
->setParameter('alias', $statusArray);
->andWhere('os.alias IN (:alias)')
->setParameter('alias', $statusArray);
}

public function filterByReductionCredit(OrderReductionCreditInterface $reductionCredit): self
public function filterByReductionCredit(ReductionCreditInterface $reductionCredit): self
{
$this->joinOrderReductionCredits();

return $this
->andWhere('orc.reductionCredit = :reductionCredit')
->setParameter('reductionCredit', $reductionCredit);
->andWhere('orc.reductionCredit = :reductionCredit')
->setParameter('reductionCredit', $reductionCredit);
}

public function filterByReductionCart(OrderReductionCartInterface $reductionCart): self
public function filterByReductionCart(ReductionCartInterface $reductionCart): self
{
$this->joinOrderReductionCarts();

return $this
->andWhere('orcart.reductionCart = :reductionCart')
->setParameter('reductionCart', $reductionCart);
->andWhere('orcart.reductionCart = :reductionCart')
->setParameter('reductionCart', $reductionCart);
}

public function filterByCycleNumber(int $cycleNumber): self
{
return $this
->andWhere('.cycleNumber = :cycleNumber')
->setParameter('cycleNumber', $cycleNumber);
->andWhere('.cycleNumber = :cycleNumber')
->setParameter('cycleNumber', $cycleNumber);
}

public function filterIsNotMainOrderShop(): self
{
return $this
->andWhere('.mainOrderShop = false OR .mainOrderShop IS NULL');
->andWhere('.mainOrderShop = false OR .mainOrderShop IS NULL');
}

public function filterIsNullMainOrderShop(): self
{
return $this
->andWhere('.mainOrderShop IS NULL');
->andWhere('.mainOrderShop IS NULL');
}

public function selectOrderReductionCarts(): self
@@ -139,7 +151,7 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinOrderReductionCredits = true;

return $this
->innerJoin('.orderReductionCredits', 'orc');
->innerJoin('.orderReductionCredits', 'orc');
}
return $this;
}
@@ -150,7 +162,7 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinOrderStatus = true;

return $this
->leftJoin('.orderStatus', 'os');
->leftJoin('.orderStatus', 'os');
}
return $this;
}
@@ -161,7 +173,30 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinOrderReductionCarts = true;

return $this
->leftJoin('.orderReductionCarts', 'orcart');
->leftJoin('.orderReductionCarts', 'orcart');
}
return $this;
}

public function joinMerchant(): self
{
$this->joinSection();
if (!$this->isJoinMerchant) {
$this->isJoinMerchant = true;

return $this
->leftJoin('s.merchant', 'merchant');
}
return $this;
}

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

return $this
->leftJoin('.section', 's');
}
return $this;
}
@@ -172,7 +207,7 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinComplementaryOrderShops = true;

return $this
->leftJoin('.complementaryOrderShops', 'complementaryOrderShops');
->leftJoin('.complementaryOrderShops', 'complementaryOrderShops');
}
return $this;
}
@@ -183,7 +218,7 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinDeliveryPointSale = true;

return $this
->leftJoin('.deliveryPointSale', 'pointSale');
->leftJoin('.deliveryPointSale', 'pointSale');
}
return $this;
}

+ 80
- 37
Repository/Order/OrderShopStore.php Wyświetl plik

@@ -9,6 +9,8 @@ use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
@@ -72,13 +74,13 @@ class OrderShopStore extends AbstractStore
}

// getOrderShopsOfWeek
public function getByCycle(SectionInterface $section, $params = [])
public function getByCurrentCycle($params = [])
{
$orderShops = $this->getBy(
array_merge(
[
'section' => $section,
'cycleNumber' => $this->getCycleNumberCurrentOrder($section),
'section' => $this->section,
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'isValid' => true,
],
$params
@@ -89,14 +91,13 @@ class OrderShopStore extends AbstractStore
}

// getOrderShopsOfWeekByUser
public function getByCycleAndUser(SectionInterface $section, UserInterface $user, array $params = [])
public function getByCurrentCycleAndUser(UserInterface $user, array $params = [])
{
return $this->getByCycle(
$section,
return $this->getByCurrentCycle(
array_merge(
[
'user' => $user,
'cycleNumber' => $this->getCycleNumberCurrentOrder($section),
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'excludeComplementaryOrderShops' => true
],
$params
@@ -106,10 +107,9 @@ class OrderShopStore extends AbstractStore

//public $countOrderShopsOfWeek = null;

public function countByCycle(SectionInterface $section, bool $excludeComplementaryOrderShops = true)
public function countByCurrentCycle(bool $excludeComplementaryOrderShops = true)
{
return $this->getByCycle(
$section,
return $this->getByCurrentCycle(
[
'count' => true,
'excludeComplementaryOrderShops' => $excludeComplementaryOrderShops
@@ -119,7 +119,7 @@ class OrderShopStore extends AbstractStore

// @TODO : optimisation à remettre en place
/*if (is_null($this->countOrderShopsOfWeek)) {
$this->countOrderShopsOfWeek = $this->getByCycle(
$this->countOrderShopsOfWeek = $this->getByCurrentCycle(
$section,
[
'count' => true,
@@ -156,33 +156,46 @@ class OrderShopStore extends AbstractStore
// countValidOrderShopByUserAllMerchant
public function countValidByUserAllMerchant($user): int
{
$totalOrder = 0;

foreach ($this->merchantStore->getRepositoryQuery()->findAll() as $merchant) {
$totalOrder += $this->countValidByUser($user, $merchant);
}

return $totalOrder;
return $this->countBy(
[
'user' => $user,
'isValid' => true,
// @TODO : à tester
'isMerchantOnline' => true,
'excludeComplementaryOrderShops' => true
]
);
}

public function countValidByUser(UserInterface $user, MerchantInterface $merchant = null): int
public function countValidByUser(UserInterface $user): int
{
return $this->getBy(
return $this->countBy(
[
'user' => $user,
'isValid' => true,
'merchant' => $merchant,
'excludeComplementaryOrderShops' => true,
'count' => true
'section' => $this->section,
'excludeComplementaryOrderShops' => true
]
);
}

public function countValidByCurrentCycle(): int
{
return $this->countBy(
[
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'isValid' => true,
'section' => $this->section,
'excludeComplementaryOrderShops' => true
]
);
}

// countValidOrderWithReductionCredit
public function countValidWithReductionCredit(
OrderReductionCreditInterface $reductionCredit,
ReductionCreditInterface $reductionCredit,
UserInterface $user = null
): string {
): int {
$query = $this->query->create();

if ($user) {
@@ -199,7 +212,7 @@ class OrderShopStore extends AbstractStore

// countValidOrderWithReductionCart
public function countValidWithReductionCart(
OrderReductionCartInterface $reductionCart
ReductionCartInterface $reductionCart
): int {
$query = $this->query->create();
$query
@@ -212,10 +225,10 @@ class OrderShopStore extends AbstractStore
}

// countValidOrderWithReductionCartPerUser
public function countValidWithReductionCartPerUser(
OrderReductionCartInterface $reductionCart,
public function countValidWithReductionCartByUser(
ReductionCartInterface $reductionCart,
UserInterface $user
): string {
): int {
$query = $this->query->create();

$query
@@ -247,17 +260,12 @@ class OrderShopStore extends AbstractStore
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterBySection($this->section);

$results = $query->find();

if ($results) {
return $results[0];
}
return $query->findOne();

return null;
}

// findLastOrderValidOfWeek
public function getOneLastValidOfCycle(int $cycleNumber): ?OrderShopInterface
public function getOneLastValidByCycle(int $cycleNumber): ?OrderShopInterface
{
$query = $this->query->create();

@@ -265,7 +273,7 @@ class OrderShopStore extends AbstractStore
->filterByCycleNumber($cycleNumber)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterIsNotMainOrderShop()
->orderBy('.weekId', 'DESC')
->orderBy('.cycleId', 'DESC')
->filterBySection($this->section);

return $query->findOne();
@@ -321,6 +329,10 @@ class OrderShopStore extends AbstractStore
$query->filterBySection($this->section);
}

if (isset($params['isMerchantOnline'])) {
$query->filterIsMerchantOnline();
}

if (isset($params['select'])) {
$query->selectParam($params['select']);
}
@@ -389,6 +401,37 @@ class OrderShopStore extends AbstractStore



public function isReductionGiftUsed(ReductionCreditInterface $reductionGift)
{
if ($this->countValidWithReductionCredit($reductionGift)) {
return true;
} else {
return false;
}
}

public function isReductionCreditUsed(ReductionCreditInterface $reductionCredit, UserInterface $user = null)
{
if ($this->countValidWithReductionCredit($reductionCredit, $user)) {
return true;
} else {
return false;
}
}

public function isReductionCreditAddedToOrder(
OrderShopInterface $orderShop,
ReductionCreditInterface $reductionCredit
) {
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
if ($orderReductionCredit->getReductionCredit() == $reductionCredit) {
return true;
}
}

return false;
}

/*
public function getCartCurrent(SectionInterface $section, UserInterface $user = null, VisitorInterface $visitor = null)
{

+ 2
- 0
Repository/Product/ProductCategoryRepository.php Wyświetl plik

@@ -14,4 +14,6 @@ class ProductCategoryRepository extends AbstractRepository
{
parent::__construct($registry, ProductCategory::class);
}


}

+ 1
- 5
Repository/Product/ProductCategoryRepositoryQuery.php Wyświetl plik

@@ -35,9 +35,5 @@ class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
return $this->andWhere('pf.status = 1');
}

public function filterByCurrentDay(): self
{
return $this->andWhere('e.displaySpecificDay IS NULL OR e.displaySpecificDay = :dayToday')
->setParameter('dayToday', date('N'));
}

}

+ 1
- 41
Repository/Product/ProductCategoryStore.php Wyświetl plik

@@ -16,46 +16,6 @@ class ProductCategoryStore extends AbstractStore
{
$this->query = $query;
}

public function getParents()
{
$query = $this->query->create();
if ($this->section) {
$query->filterBySection($this->section);
}
$query->filterIsParent();

return $query->find();
}

//findAllByParent
public function getByParent(
ProductCategoryInterface $parentCategory,
bool $withOffline = false,
bool $withEmptyCategories = true,
bool $filterBySpecificDay = false
): array {

$query = $this->query->create();
$query->filterByParent($parentCategory);

if ($withOffline) {
$query->filterIsOnlineAndOffline();
} else {
$query->filterIsOnline();
}

if (!$withEmptyCategories) {
$query->hasProductFamilyOnline();
}

if ($filterBySpecificDay) {
$query->filterBySpecificDay();
}

$query->orderBy('position', 'asc');

return $query->find();
}

}

+ 5
- 5
Repository/Reduction/ReductionCartStore.php Wyświetl plik

@@ -48,7 +48,7 @@ class ReductionCartStore extends AbstractStore
// getReductionCartRemainingQuantity
public function getRemainingQuantity(ReductionCartInterface $reductionCart): float
{
return $reductionCart->getAvailableQuantity() - $this->orderShopStore->countValidOrderWithReductionCart(
return $reductionCart->getAvailableQuantity() - $this->orderShopStore->countValidWithReductionCart(
$reductionCart
);
}
@@ -56,13 +56,13 @@ class ReductionCartStore extends AbstractStore
// getReductionCartUsedQuantityPerUser
public function getUsedQuantityByUser(ReductionCartInterface $reductionCart, UserInterface $user): float
{
return $this->orderShopStore->countValidWithReductionCartPerUser($reductionCart, $user);
return $this->orderShopStore->countValidWithReductionCartByUser($reductionCart, $user);
}

// getReductionCartUsedQuantity
public function getUsedQuantity(ReductionCartInterface $reductionCart): float
{
return $this->orderShopStore->countValidWithReductionCartPerUser($reductionCart);
return $this->orderShopStore->countValidWithReductionCart($reductionCart);
}

// getReductionCartRemainingQuantityPerUser
@@ -70,14 +70,14 @@ class ReductionCartStore extends AbstractStore
{
if ($reductionCart->getAvailableQuantityPerUser()) {
return $reductionCart->getAvailableQuantityPerUser(
) - $this->orderShopStore->countValidWithReductionCartPerUser($reductionCart, $user);
) - $this->orderShopStore->countValidWithReductionCartByUser($reductionCart, $user);
}

return false;
}

// findAllAvailableForUser / getReductionCartsAvailableByUser
public function getAvailablesByUser(UserInterface $user)
public function getAvailableByUser(UserInterface $user)
{
$reductionCarts = $this->query->find();


+ 0
- 6
Repository/Reduction/ReductionCatalogRepositoryQuery.php Wyświetl plik

@@ -23,10 +23,4 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
->setParameter(':productFamily', $productFamily);
}

public function filterStatus(bool $status)
{
return $this
->andWhere('.status = :status')
->setParameter(':status', $status);
}
}

+ 1
- 1
Repository/Reduction/ReductionCatalogStore.php Wyświetl plik

@@ -16,7 +16,7 @@ class ReductionCatalogStore extends AbstractStore
public function getByProductFamily($productFamily){
$query = $this->query->create();
$query->filterProductFamily($productFamily);
$query->filterStatus(true);
$query->filterIsOnline();
return $query->findOne();

}

+ 0
- 5
Repository/Reduction/ReductionCreditRepositoryQuery.php Wyświetl plik

@@ -17,11 +17,6 @@ class ReductionCreditRepositoryQuery extends AbstractRepositoryQuery
parent::__construct($repository, 'r', $paginator);
}

public function filterStatusOnline()
{
return $this->andWhere('.status = 1');
}

public function filterByUser(UserInterface $user)
{
return $this

+ 0
- 30
Repository/Reduction/ReductionCreditStore.php Wyświetl plik

@@ -25,41 +25,11 @@ class ReductionCreditStore extends AbstractStore
$query = $this->query->create();

$query
->filterStatusOnline()
->filterByType($type)
->filterByUser($user);

return $query->find();
}

public function isReductionGiftUsed(ReductionCreditInterface $reductionGift)
{
if ($this->orderShopStore->countValidOrderWithReductionCredit($reductionGift)) {
return true;
} else {
return false;
}
}

public function isReductionCreditUsed(ReductionCreditInterface $reductionCredit, UserInterface $user = null)
{
if ($this->orderShopStore->countValidOrderWithReductionCredit($reductionCredit, $user)) {
return true;
} else {
return false;
}
}

public function isReductionCreditAddedToOrder(
OrderShopInterface $orderShop,
ReductionCreditInterface $reductionCredit
) {
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
if ($orderReductionCredit->getReductionCredit() == $reductionCredit) {
return true;
}
}

return false;
}
}

+ 8
- 0
Repository/Reminder/ReminderStore.php Wyświetl plik

@@ -39,6 +39,10 @@ class ReminderStore extends SovReminderStore
$query->filterByMerchant($this->merchant);
}

if ($this->section) {
$query->filterBySection($this->section);
}

return parent::getByUser($user, $query);
}

@@ -57,6 +61,10 @@ class ReminderStore extends SovReminderStore
$query->filterByMerchant($this->merchant);
}

if ($this->section) {
$query->filterBySection($this->section);
}

return parent::getByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId, $query);
}
}

+ 1
- 1
Repository/SectionRepositoryQueryTrait.php Wyświetl plik

@@ -10,4 +10,4 @@ trait SectionRepositoryQueryTrait
{
return $this->andWhereSection($this->id, $section);
}
}
}

+ 12
- 0
Repository/SectionStoreTrait.php Wyświetl plik

@@ -14,4 +14,16 @@ trait SectionStoreTrait

return $this;
}

public function getParents()
{
$query = $this->query->create();
if ($this->section) {
$query->filterBySection($this->section);
}
$query->filterIsParent();

return $query->find();
}

}

+ 2
- 2
Repository/Site/NewsRepositoryQuery.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Repository\Site;

use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\Site\NewsRepositoryQuery as SovNewsRepositoryQuery;

class NewsRepositoryQuery extends SovNewsRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

}

+ 4
- 4
Repository/Site/NewsStore.php Wyświetl plik

@@ -2,12 +2,12 @@

namespace Lc\CaracoleBundle\Repository\Site;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\Site\NewsStore as SovNewsStore;

class NewsStore extends SovNewsStore
{
use MerchantStoreTrait;
use SectionStoreTrait;

public function getLatests(int $maxResults = 0, $query = null): array
{
@@ -15,8 +15,8 @@ class NewsStore extends SovNewsStore
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
if ($this->section) {
$query->filterBySection($this->section);
}

return parent::getLatests($maxResults, $query);

+ 1
- 1
Repository/Site/PageStore.php Wyświetl plik

@@ -17,7 +17,7 @@ class PageStore extends SovPageStore
}

// findPage
public function getOnePage(string $devAlias): ?PageInterface
public function getOneByDevAlias(string $devAlias): ?PageInterface
{
$query = $this->query->create();


+ 2
- 2
Repository/Ticket/TicketRepositoryQuery.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Repository\Ticket;

use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\Ticket\TicketRepositoryQuery as SovTicketRepositoryQuery;

class TicketRepositoryQuery extends SovTicketRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

}

+ 14
- 31
Repository/Ticket/TicketStore.php Wyświetl plik

@@ -2,50 +2,33 @@

namespace Lc\CaracoleBundle\Repository\Ticket;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\Ticket\TicketStore as SovTicketStore;

class TicketStore extends SovTicketStore
{
use MerchantStoreTrait;
use SectionStoreTrait;

public function getByUser($user, $query = null): array
public function getByUser(UserInterface $user, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

$query = $this->createQuery($query);
$query->filterBySection($this->section);
return parent::getByUser($user, $query);
}

public function getAllOpen(int $limit = 0, $query = null): array
public function getOpen(int $limit = 0, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getAllOpen($limit, $query);
$query = $this->createQuery($query);
$query->filterBySection($this->section);
return parent::getOpen($limit, $query);
}

public function countAllOpen($query = null): string
public function countOpen($query = null): string
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::countAllOpen($query);
$query = $this->createQuery($query);
$query->filterBySection($this->section);
return parent::countOpen($query);
}

}

+ 5
- 4
Repository/User/UserMerchantStore.php Wyświetl plik

@@ -23,9 +23,9 @@ class UserMerchantStore extends AbstractStore
}

// getUserMerchant
public function getOneByUser(UserInterface $user): UserMerchantInterface
public function getOneByUser(UserInterface $user, $query = null): UserMerchantInterface
{
$query = $this->query->create();
$query = $this->createQuery($query);

$query
->filterByMerchant($this->merchant)
@@ -34,9 +34,10 @@ class UserMerchantStore extends AbstractStore
return $query->findOne();
}

public function isCreditActiveByUser(UserInterface $user): bool
public function isCreditActiveByUser(UserInterface $user, $query = null): bool
{
$userMerchant = $this->getOneByUser($user);
$userMerchant = $this->getOneByUser($user, $query);
return $this->userMerchantSolver->isCreditActive($userMerchant);
}
}

+ 1
- 1
Repository/User/UserRepositoryQuery.php Wyświetl plik

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

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

+ 0
- 14
Repository/User/UserStore.php Wyświetl plik

@@ -10,18 +10,4 @@ class UserStore extends SovUserStore
{
use MerchantStoreTrait;

public function getByNewsletter(Newsletter $newsletter, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

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

return parent::getByNewsletter($newsletter, $query);
}
}

+ 2
- 4
Repository/User/VisitorStore.php Wyświetl plik

@@ -13,12 +13,10 @@ class VisitorStore extends AbstractStore
$this->query = $query;
}

public function getOneByCookie(string $cookie)
public function getOneByCookie(string $cookie, $query = null)
{
$query = $this->query->create();

$query = $this->createQuery($query);
$query->filterByCookie($cookie);

return $query->findOne();
}
}

+ 1
- 1
Resolver/MerchantResolver.php Wyświetl plik

@@ -132,7 +132,7 @@ class MerchantResolver

public function getMerchantUser(UserInterface $user = null)
{
$merchants = $this->merchantStore->findAll();
$merchants = $this->merchantStore->getOnline();

if ($user) {
return $user->getMerchant();

+ 8
- 17
Resolver/OpeningResolver.php Wyświetl plik

@@ -15,17 +15,17 @@ class OpeningResolver
protected array $messages = [];
protected SectionResolver $sectionResolver;
protected Security $security;
//protected OrderShopStore $orderShopStore;
protected OrderShopStore $orderShopStore;

public function __construct(SectionResolver $sectionResolver, Security $security /*, OrderShopStore $orderShopStore*/)
public function __construct(SectionResolver $sectionResolver, Security $security, OrderShopStore $orderShopStore)
{
$this->sectionResolver = $sectionResolver;
$this->security = $security;
//$this->orderShopStore = $orderShopStore;
$this->orderShopStore = $orderShopStore;
}

public function isOpenSale(
SectionInterface $section = null,
SectionInterface $section,
UserInterface $user = null,
\DateTime $date = null,
string $context = null
@@ -33,14 +33,6 @@ class OpeningResolver
// Initialisation
$this->messages = [];

if (is_null($section)) {
$section = $this->sectionResolver->getCurrent();
}

if (is_null($user)) {
$user = $this->security->getUser();
}

if (is_null($date)) {
$date = new \DateTime();
}
@@ -65,7 +57,7 @@ class OpeningResolver
}

// Période de fermeture des commandes issue de la configuration de la section (congés)
if($this->isClosingPeriod($section)) {
if($this->isClosingPeriod($section, $date)) {
$this->addMessage(
'Les commandes sont fermées (période de fermeture des commandes dans la configuration de la section).'
);
@@ -90,7 +82,7 @@ class OpeningResolver
}

// isHolidays
public function isClosingPeriod(Section $section, \DateTime $date)
public function isClosingPeriod(SectionInterface $section, \DateTime $date)
{
$orderClosedStart = $section->getSettingValue(SectionSettingDefinition::SETTING_ORDER_CLOSED_START);
$orderClosedEnd = $section->getSettingValue(SectionSettingDefinition::SETTING_ORDER_CLOSED_END);
@@ -106,9 +98,8 @@ class OpeningResolver
// isMaximumOrderWeekAchieved
public function isMaximumOrderCycleAchieved(SectionInterface $section)
{
// @TODO : countValidByCycle
//$countOrderShopCycle = $this->orderShopStore->countValidByCycle($section);
$countOrderShopCycle = 0 ;

$countOrderShopCycle = $this->orderShopStore->countValidByCurrentCycle();
$orderMaximumPerCycle = $section->getSettingValue(SectionSettingDefinition::SETTING_ORDER_MAXIMUM_PER_CYCLE);
if ($orderMaximumPerCycle && $countOrderShopCycle >= $orderMaximumPerCycle) {
return true;

Ładowanie…
Anuluj
Zapisz