Przeglądaj źródła

Refactoring services

packProduct
Guillaume 3 lat temu
rodzic
commit
57ac2f81a1
27 zmienionych plików z 837 dodań i 366 usunięć
  1. +1
    -1
      Model/Order/OrderReductionCartModel.php
  2. +372
    -5
      Model/Order/OrderShopModel.php
  3. +15
    -0
      Model/Order/OrderStatusModel.php
  4. +35
    -0
      Model/PointSale/PointSaleModel.php
  5. +102
    -1
      Model/Product/ProductFamilyModel.php
  6. +66
    -0
      Model/Product/ProductModel.php
  7. +52
    -0
      Model/Reduction/ReductionCreditModel.php
  8. +15
    -9
      Model/User/UserModel.php
  9. +1
    -0
      Repository/Config/TaxRateStore.php
  10. +0
    -1
      Repository/Credit/CreditHistoryRepositoryQuery.php
  11. +2
    -1
      Repository/File/DocumentRepositoryQuery.php
  12. +2
    -1
      Repository/File/DocumentStore.php
  13. +0
    -9
      Repository/Merchant/MerchantStore.php
  14. +1
    -2
      Repository/MerchantRepositoryQueryTrait.php
  15. +8
    -172
      Repository/Order/OrderShopRepositoryQuery.php
  16. +52
    -87
      Repository/Order/OrderShopStore.php
  17. +0
    -3
      Repository/PointSale/PointSaleRepositoryQuery.php
  18. +0
    -5
      Repository/Product/ProductCategoryRepositoryQuery.php
  19. +0
    -5
      Repository/Product/ProductFamilyRepositoryQuery.php
  20. +5
    -9
      Repository/RepositoryTrait.php
  21. +1
    -1
      Repository/SectionRepositoryQueryTrait.php
  22. +0
    -5
      Repository/Site/PageRepositoryQuery.php
  23. +0
    -26
      Repository/StatusRepositoryQueryTrait.php
  24. +0
    -22
      Repository/TreeRepositoryQueryTrait.php
  25. +56
    -1
      Solver/Order/OrderShopSolver.php
  26. +39
    -0
      Solver/PointSale/PointSaleSolver.php
  27. +12
    -0
      Solver/User/UserSolver.php

+ 1
- 1
Model/Order/OrderReductionCartModel.php Wyświetl plik

@@ -37,7 +37,7 @@ abstract class OrderReductionCartModel implements ReductionInterface, ReductionC
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $codeUsed;
protected $codeUsed;

public function __toString()
{

+ 372
- 5
Model/Order/OrderShopModel.php Wyświetl plik

@@ -8,12 +8,9 @@ use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
use Lc\SovBundle\Model\Ticket\TicketInterface;
@@ -28,6 +25,9 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
{
use BlameableNullableTrait;

const DELIVERY_TYPE_HOME = 'home';
const DELIVERY_TYPE_POINTSALE = 'point-sale';

/**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orderShops", fetch="EAGER")
*/
@@ -120,6 +120,106 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
*/
protected $cycleId;

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

/**
* @ORM\ManyToOne(targetEntity="App\Entity\Address\Address")
*/
protected $deliveryAddress;

/**
* @ORM\ManyToOne(targetEntity="App\Entity\PointSale\PointSale")
*/
protected $deliveryPointSale;

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

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $deliveryType;

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

/**
* @ORM\ManyToOne(targetEntity="App\Entity\Config\TaxRate")
*/
protected $deliveryTaxRate;

/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
protected $reference;

/**
* @ORM\ManyToOne(targetEntity="App\Entity\Order\OrderShop", inversedBy="complementaryOrderShops")
*/
protected $mainOrderShop;

/**
* @ORM\OneToMany(targetEntity="App\Entity\Order\OrderShop", mappedBy="mainOrderShop")
*/
protected $complementaryOrderShops;

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

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

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

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

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

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

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

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

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

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

public function __construct()
{
$this->orderStatusHistories = new ArrayCollection();
@@ -128,6 +228,8 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
$this->orderReductionCarts = new ArrayCollection();
$this->orderReductionCredits = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->complementaryOrderShops = new ArrayCollection();
$this->tickets = new ArrayCollection();
}

public function __toString()
@@ -496,4 +598,269 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
return $this;
}

public function getCycleNumber(): ?int
{
return $this->cycleNumber;
}

public function setCycleNumber(?int $cycleNumber): self
{
$this->cycleNumber = $cycleNumber;

return $this;
}

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

public function setDeliveryAddress(?AddressInterface $deliveryAddress): self
{
$this->deliveryAddress = $deliveryAddress;

return $this;
}

public function getDeliveryAddressText(): ?string
{
return $this->deliveryAddressText;
}

public function setDeliveryAddressText(string $deliveryAddressText): self
{
$this->deliveryAddressText = $deliveryAddressText;

return $this;
}

public function getDeliveryPointSale(): ?PointSaleInterface
{
return $this->deliveryPointSale;
}

public function setDeliveryPointSale(?PointSaleInterface $deliveryPointSale): self
{
$this->deliveryPointSale = $deliveryPointSale;

return $this;
}

public function getDeliveryType(): ?string
{
return $this->deliveryType;
}

public function setDeliveryType(?string $deliveryType): self
{
$this->deliveryType = $deliveryType;

return $this;
}

public function getDeliveryPrice(): ?float
{
return $this->deliveryPrice;
}

public function setDeliveryPrice(?float $deliveryPrice): self
{
$this->deliveryPrice = $deliveryPrice;

return $this;
}

public function getDeliveryTaxRate(): ?TaxRateInterface
{
return $this->deliveryTaxRate;
}

public function setDeliveryTaxRate(?TaxRateInterface $deliveryTaxRate): self
{
$this->deliveryTaxRate = $deliveryTaxRate;

return $this;
}

public function getReference(): ?string
{
return $this->reference;
}

public function setReference(?string $reference): self
{
$this->reference = $reference;

return $this;
}

public function getMainOrderShop(): ?self
{
return $this->mainOrderShop;
}

public function setMainOrderShop(?self $mainOrderShop): self
{
$this->mainOrderShop = $mainOrderShop;

return $this;
}

/**
* @return Collection|OrderShopInterface[]
*/
public function getComplementaryOrderShops(): Collection
{
$arrayComplementaryOrderShops = new ArrayCollection();
foreach ($this->complementaryOrderShops as $complementaryOrderShop) {
if ($complementaryOrderShop->isValid()) {
$arrayComplementaryOrderShops[] = $complementaryOrderShop;
}
}
return $arrayComplementaryOrderShops;
}

public function addComplementaryOrderShop(self $complementaryOrderShop): self
{
if (!$this->complementaryOrderShops->contains($complementaryOrderShop)) {
$this->complementaryOrderShops[] = $complementaryOrderShop;
$complementaryOrderShop->setMainOrderShop($this);
}

return $this;
}

public function removeComplementaryOrderShop(self $complementaryOrderShop): self
{
if ($this->complementaryOrderShops->contains($complementaryOrderShop)) {
$this->complementaryOrderShops->removeElement($complementaryOrderShop);
// set the owning side to null (unless already changed)
if ($complementaryOrderShop->getMainOrderShop() === $this) {
$complementaryOrderShop->setMainOrderShop(null);
}
}

return $this;
}

public function getDeclineComplementaryOrderShop(): ?bool
{
return $this->declineComplementaryOrderShop;
}

public function setDeclineComplementaryOrderShop(?bool $declineComplementaryOrderShop): self
{
$this->declineComplementaryOrderShop = $declineComplementaryOrderShop;

return $this;
}

public function getOrderAllowByAdmin(): ?bool
{
return $this->orderAllowByAdmin;
}

public function setOrderAllowByAdmin(?bool $orderAllowByAdmin): self
{
$this->orderAllowByAdmin = $orderAllowByAdmin;

return $this;
}

public function getHasReach(): ?int
{
return $this->hasReach;
}

public function setHasReach(?int $hasReach): self
{
$this->hasReach = $hasReach;

return $this;
}


public function getStatTotal(): ?float
{
return $this->statTotal;
}

public function setStatTotal(?float $statTotal): self
{
$this->statTotal = $statTotal;

return $this;
}

public function getStatTotalWithTax(): ?float
{
return $this->statTotalWithTax;
}

public function setStatTotalWithTax(?float $statTotalWithTax): self
{
$this->statTotalWithTax = $statTotalWithTax;

return $this;
}

public function getStatTotalOrderProductsWithReductions(): ?float
{
return $this->statTotalOrderProductsWithReductions;
}

public function setStatTotalOrderProductsWithReductions(?float $statTotalOrderProductsWithReductions): self
{
$this->statTotalOrderProductsWithReductions = $statTotalOrderProductsWithReductions;

return $this;
}

public function getStatTotalOrderProductsWithTaxAndReductions(): ?float
{
return $this->statTotalOrderProductsWithTaxAndReductions;
}

public function setStatTotalOrderProductsWithTaxAndReductions(?float $statTotalOrderProductsWithTaxAndReductions): self
{
$this->statTotalOrderProductsWithTaxAndReductions = $statTotalOrderProductsWithTaxAndReductions;

return $this;
}

public function getStatMarginOrderProductsWithReductions(): ?float
{
return $this->statMarginOrderProductsWithReductions;
}

public function setStatMarginOrderProductsWithReductions(?float $statMarginOrderProductsWithReductions): self
{
$this->statMarginOrderProductsWithReductions = $statMarginOrderProductsWithReductions;

return $this;
}

public function getStatDeliveryPriceWithReduction(): ?float
{
return $this->statDeliveryPriceWithReduction;
}

public function setStatDeliveryPriceWithReduction(?float $statDeliveryPriceWithReduction): self
{
$this->statDeliveryPriceWithReduction = $statDeliveryPriceWithReduction;

return $this;
}

public function getStatDeliveryPriceWithTaxAndReduction(): ?float
{
return $this->statDeliveryPriceWithTaxAndReduction;
}

public function setStatDeliveryPriceWithTaxAndReduction(?float $statDeliveryPriceWithTaxAndReduction): self
{
$this->statDeliveryPriceWithTaxAndReduction = $statDeliveryPriceWithTaxAndReduction;

return $this;
}
}

+ 15
- 0
Model/Order/OrderStatusModel.php Wyświetl plik

@@ -69,6 +69,11 @@ abstract class OrderStatusModel implements EntityInterface
*/
protected $alias;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $color;

public function __toString()
{
return $this->title . ' [' . $this->alias . ']';
@@ -141,5 +146,15 @@ abstract class OrderStatusModel implements EntityInterface
return $this;
}

public function getColor(): ?string
{
return $this->color;
}

public function setColor(?string $color): self
{
$this->color = $color;

return $this;
}
}

+ 35
- 0
Model/PointSale/PointSaleModel.php Wyświetl plik

@@ -33,6 +33,16 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip
*/
protected $code;

/**
* @ORM\Column(type="float")
*/
protected $deliveryPrice;

/**
* @ORM\Column(type="boolean")
*/
protected $isPublic;

/**
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
@@ -98,6 +108,31 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip
return $this;
}


public function getDeliveryPrice(): ?float
{
return $this->deliveryPrice;
}

public function setDeliveryPrice(float $deliveryPrice): self
{
$this->deliveryPrice = $deliveryPrice;

return $this;
}

public function getIsPublic(): ?bool
{
return $this->isPublic;
}

public function setIsPublic(bool $isPublic): self
{
$this->isPublic = $isPublic;

return $this;
}

public function getAddress(): ?AddressInterface
{
return $this->address;

+ 102
- 1
Model/Product/ProductFamilyModel.php Wyświetl plik

@@ -14,6 +14,7 @@ use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
use Lc\SovBundle\Model\File\FileInterface;


/**
@@ -132,7 +133,8 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family';
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product';

public function getBehaviorExpirationDateChoices():array{
public function getBehaviorExpirationDateChoices(): array
{
return [
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY,
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT
@@ -203,11 +205,31 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
*/
protected $behaviorCountStock;

/**
* @ORM\Column(type="string", length=255)
*/
protected $behaviorStockWeek;

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

/**
* @ORM\Column(type="string", length=255)
*/
protected $behaviorDisplaySale;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $exportTitle;

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

/**
* @ORM\Column(type="date", nullable=true)
*/
@@ -300,6 +322,11 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
*/
protected $section;

/**
* @ORM\ManyToOne((targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
*/
protected $image;

public function __construct()
{
$this->productCategories = new ArrayCollection();
@@ -322,6 +349,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP

return $this;
}

//TODO move
public function getAvailableQuantityInherited()
{
@@ -348,6 +376,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP

return $availableQuantity;
}

//TODO move
public function getTaxRateInherited()
{
@@ -413,6 +442,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
{
return $this->products;
}

//TODO move
public function getProductsOnline(): Collection
{
@@ -455,6 +485,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
{
return $this->reductionCatalog;
}

//TODO move
public function getReductionCatalogInherited(): ?ReductionCatalogInterface
{
@@ -498,6 +529,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP

return $this;
}

//TODO move
public function getProductCategoryParent()
{
@@ -598,6 +630,54 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
return $this;
}

public function getExportTitle(): ?string
{
return $this->exportTitle;
}

public function setExportTitle(?string $exportTitle): self
{
$this->exportTitle = $exportTitle;

return $this;
}

public function getExportNote(): ?string
{
return $this->exportNote;
}

public function setExportNote(?string $exportNote): self
{
$this->exportNote = $exportNote;

return $this;
}

public function getBehaviorStockWeek(): ?string
{
return $this->behaviorStockWeek;
}

public function setBehaviorStockWeek(string $behaviorStockWeek): self
{
$this->behaviorStockWeek = $behaviorStockWeek;

return $this;
}

public function getAvailabilityRenewedThisWeek(): ?bool
{
return $this->availabilityRenewedThisWeek;
}

public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek): self
{
$this->availabilityRenewedThisWeek = $availabilityRenewedThisWeek;

return $this;
}

public function getBehaviorDisplaySale(): ?string
{
return $this->behaviorDisplaySale;
@@ -609,6 +689,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP

return $this;
}

//TODO move
public function isPropertyNoveltyOnline(): ?bool
{
@@ -681,6 +762,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP

return $this;
}

//TODO move
public function countProperties(): bool
{
@@ -830,6 +912,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
{
return $this->behaviorPrice;
}

//TODO move
public function getBehaviorPriceInherited()
{
@@ -868,6 +951,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP

return false;
}

//TODO move
public function getProductsGroupByTitle()
{
@@ -886,6 +970,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP

return $arrayProductsGroupByTitle;
}

//TODO move
public function getOriginProduct()
{
@@ -897,6 +982,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
}
}
}

//TODO move
public function getOriginProductOnline()
{
@@ -908,6 +994,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
return false;
}
}

//TODO move
public function hasOneProductOnline()
{
@@ -950,4 +1037,18 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
return 'priceByRefUnit';
}
}


public function getImage(): ?FileInterface
{
return $this->image;
}

public function setImage(?FileInterface $image): self
{
$this->image = $image;

return $this;
}

}

+ 66
- 0
Model/Product/ProductModel.php Wyświetl plik

@@ -42,6 +42,16 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter
*/
protected $originProduct;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $exportTitle;

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

public function __construct()
{
$this->orderProducts = new ArrayCollection();
@@ -248,4 +258,60 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter

return $this;
}


public function getExportTitle(): ?string
{
return $this->exportTitle;
}
//TODO move
public function getExportTitleInherited(): ?string
{
$exportTitle = $this->getExportTitle();
if ($exportTitle && strlen($exportTitle)) {
return $exportTitle;
} else {
$productFamily = $this->getProductFamily();
if ($productFamily) {
return $productFamily->getExportTitle();
}
}

return null;
}

public function setExportTitle(?string $exportTitle): self
{
$this->exportTitle = $exportTitle;

return $this;
}

public function getExportNote(): ?string
{
return $this->exportNote;
}

//TODO move
public function getExportNoteInherited(): ?string
{
$exportNote = $this->getExportNote();
if ($exportNote && strlen($exportNote)) {
return $exportNote;
} else {
$productFamily = $this->getProductFamily();
if ($productFamily) {
return $productFamily->getExportNote();
}
}

return null;
}

public function setExportNote(?string $exportNote): self
{
$this->exportNote = $exportNote;

return $this;
}
}

+ 52
- 0
Model/Reduction/ReductionCreditModel.php Wyświetl plik

@@ -60,6 +60,22 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc
*/
protected $owner;

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

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $ownerName;

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


public function __construct()
{
$this->users = new ArrayCollection();
@@ -156,4 +172,40 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc

return $this;
}

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

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

return $this;
}

public function getOwnerName(): ?string
{
return $this->ownerName;
}

public function setOwnerName(?string $ownerName): self
{
$this->ownerName = $ownerName;

return $this;
}

public function getOwnerMessage(): ?string
{
return $this->ownerMessage;
}

public function setOwnerMessage(?string $ownerMessage): self
{
$this->ownerMessage = $ownerMessage;

return $this;
}
}

+ 15
- 9
Model/User/UserModel.php Wyświetl plik

@@ -27,6 +27,12 @@ abstract class UserModel extends SovUserModel
*/
protected $behaviorDisplayPrice;

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


/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
*/
@@ -69,6 +75,7 @@ abstract class UserModel extends SovUserModel

public function __construct()
{
parent::__construct();
$this->addresses = new ArrayCollection();
$this->orderShops = new ArrayCollection();
$this->groupUsers = new ArrayCollection();
@@ -80,30 +87,29 @@ abstract class UserModel extends SovUserModel

}

public function getPhone(): ?string
public function getBehaviorDisplayPrice(): ?string
{
return $this->phone;
return $this->behaviorDisplayPrice;
}

public function setPhone(?string $phone): self
public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
{
$this->phone = $phone;
$this->behaviorDisplayPrice = $behaviorDisplayPrice;

return $this;
}

public function getBehaviorDisplayPrice(): ?string
public function getIsSaleAlwaysOpen(): ?bool
{
return $this->behaviorDisplayPrice;
return $this->isSaleAlwaysOpen;
}

public function setBehaviorDisplayPrice(?string $behaviorDisplayPrice): self
public function setIsSaleAlwaysOpen(?bool $isSaleAlwaysOpen): self
{
$this->behaviorDisplayPrice = $behaviorDisplayPrice;
$this->isSaleAlwaysOpen = $isSaleAlwaysOpen;

return $this;
}

public function getFavoriteMerchant(): ?MerchantInterface
{
return $this->favoriteMerchant;

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

@@ -18,6 +18,7 @@ class TaxRateStore extends AbstractStore
public function getAsArray(MerchantInterface $merchant)
{
$taxRates = $this->query->create()->find();

$taxRatesList = [];

foreach ($taxRates as $taxRate) {

+ 0
- 1
Repository/Credit/CreditHistoryRepositoryQuery.php Wyświetl plik

@@ -5,7 +5,6 @@ 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;


+ 2
- 1
Repository/File/DocumentRepositoryQuery.php Wyświetl plik

@@ -5,11 +5,12 @@ namespace Lc\CaracoleBundle\Repository\File;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class DocumentRepositoryQuery extends AbstractRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

public function __construct(DocumentRepository $repository, PaginatorInterface $paginator)
{

+ 2
- 1
Repository/File/DocumentStore.php Wyświetl plik

@@ -4,11 +4,12 @@ namespace Lc\CaracoleBundle\Repository\File;

use App\Entity\Address\Address;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;

class DocumentStore extends AbstractStore
{
use MerchantStoreTrait;
use SectionStoreTrait;

protected DocumentRepositoryQuery $query;


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

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

public function getOneByDevAlias(string $devAlias): ?MerchantInterface
{
$query = $this->query->create();

$query->filterByDevAlias($devAlias);

return $query->findOne();
}

}

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

@@ -3,12 +3,11 @@
namespace Lc\CaracoleBundle\Repository;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

trait MerchantRepositoryQueryTrait
{
public function filterByMerchant(MerchantInterface $merchant)
{
return $this->andWhere('.merchant = :merchant')->setParameter(':merchant', $merchant);
return $this->andWhereMerchant($this->id, $merchant);
}
}

+ 8
- 172
Repository/Order/OrderShopRepositoryQuery.php Wyświetl plik

@@ -19,23 +19,20 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
{
use SectionRepositoryQueryTrait;

protected $isJoinOrderReductionCredits = false;
protected $isJoinOrderReductionCarts = false;
protected $isJoinOrderStatus = false;
protected $isJoinComplementaryOrderShops = false;
protected $isJoinDeliveryPointSale = false;
protected $isJoinDeliveryAvailabilityZone = false;
protected $isJoinDeliverySlotZone = false;
protected $isJoinDeliveryAvailabilityPointSale = false;
protected $isJoinDeliverySlotPointSale = false;
protected $isHorsTournee = false;
protected $isGiftVoucher = false;
protected bool $isJoinProduct = false;
protected bool $isJoinOrderProduct = false;
protected bool $isJoinOrderReductionCredits = false;
protected bool $isJoinOrderReductionCarts = false;
protected bool $isJoinOrderStatus = false;
protected bool $isJoinComplementaryOrderShops = false;
protected bool $isJoinDeliveryPointSale = false;

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

// @TODO : nécessaire ?
public function selectParam($select): self
{
return $this
@@ -69,34 +66,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->setParameter('dateEnd', $dateEnd);
}

public function filterByEstimatedDeliveryDateStart(string $dateStart): self
{
return $this
->andWhere('.estimatedDeliveryDateTime >= :deliveryDateStart')
->setParameter('deliveryDateStart', $dateStart);
}

public function filterByEstimatedDeliveryDateEnd(string $dateEnd): self
{
return $this
->andWhere('.estimatedDeliveryDateTime < :deliveryDateEnd')
->setParameter('deliveryDateEnd', $dateEnd);
}

public function filterByDeliveryDateStart(string $dateStart): self
{
return $this
->andWhere('.deliveryDate >= :deliveryDateStart')
->setParameter('deliveryDateStart', $dateStart);
}

public function filterByDeliveryDateEnd(string $dateEnd): self
{
return $this
->andWhere('.deliveryDate < :deliveryDateEnd')
->setParameter('deliveryDateEnd', $dateEnd);
}

public function filterByVisitor(VisitorInterface $visitor): self
{
return $this
@@ -111,13 +80,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->setParameter('address', $address);
}

public function filterByWeekDeliveryTruck(string $weekDeliveryTrucks): self
{
return $this
->andWhere('.weekDeliveryTruck IN (:weekDeliveryTrucks)')
->setParameter('weekDeliveryTrucks', $weekDeliveryTrucks);
}

public function filterByStatus(array $statusArray): self
{
$this->joinOrderStatus();
@@ -145,20 +107,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->setParameter('reductionCart', $reductionCart);
}

public function filterByAvailabilityPointZone(DeliveryAvailabilityPointSale $deliveryAvailabilityPointSale): self
{
return $this
->andWhere('.deliveryAvailabilityPointSale = :deliveryAvailabilityPointSale')
->setParameter('deliveryAvailabilityPointSale', $deliveryAvailabilityPointSale);
}

public function filterByAvailabilityPointSale(DeliveryAvailabilityPointSale $deliveryAvailabilityPointSale): self
{
return $this
->andWhere('.deliveryAvailabilityPointSale = :deliveryAvailabilityPointSale')
->setParameter('deliveryAvailabilityPointSale', $deliveryAvailabilityPointSale);
}

public function filterByCycleNumber(int $cycleNumber): self
{
return $this
@@ -178,48 +126,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->andWhere('.mainOrderShop IS NULL');
}

public function filterIsNullDeliveryPointSale(): self
{
$this
->joinDeliveryPointSale()
->andWhere(
'.deliveryPointSale IS NULL OR (pointSale.isDepository = 0 AND (pointSale.devAlias IS NULL OR (pointSale.devAlias != :devAliasHorsTournee AND pointSale.devAlias != :devAliasGiftVoucher)))'
)
->setParameterGiftVoucher()
->setParameterHorsTournee();

return $this;
}

public function filterIsNotNullDeliveryPointSale(): self
{
$this
->joinDeliveryPointSale()
->andWhere(
'pointSale IS NOT NULL AND pointSale.isDepository = 1 AND (pointSale.devAlias IS NULL OR (pointSale.devAlias != :devAliasHorsTournee AND pointSale.devAlias != :devAliasGiftVoucher))'
)
->setParameterGiftVoucher()
->setParameterHorsTournee();

return $this;
}


public function filterIsPointSale(string $devAlias = 'devAliasHorsTournee'): self
{
$this
->joinDeliveryPointSale()
->andWhere('pointSale IS NOT NULL AND pointSale.devAlias = :' . $devAlias);

if($devAlias == 'devAliasHorsTournee'){
$this->setParameterHorsTournee();
} elseif($devAlias == 'devAliasGiftVoucher') {
$this->setParameterGiftVoucher();
}

return $this;
}

public function selectOrderReductionCarts(): self
{
$this->joinOrderReductionCarts();
@@ -227,28 +133,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
return $this->addSelect('orcart');
}

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

return $this
->setParameter('devAliasGiftVoucher', PointSale::DEV_ALIAS_GIFT_VOUCHER);
}
return $this;
}

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

return $this
->setParameter('devAliasHorsTournee', PointSale::DEV_ALIAS_OFF_CIRCUIT);
}
return $this;
}

public function joinOrderReductionCredits(): self
{
if (!$this->isJoinOrderReductionCredits) {
@@ -260,54 +144,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

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

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

public function joinDeliverySlotZone(): self
{
$this->joinDeliveryAvailabilityZone();

if (!$this->isJoinDeliverySlotZone) {
$this->isJoinDeliverySlotZone = true;

return $this
->leftJoin('deliveryAvailabilityZone.deliverySlot', 'deliverySlotZone');
}
return $this;
}

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

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

public function joinDeliverySlotPointSale(): self
{
$this->joinDeliveryAvailabilityPointSale();

if (!$this->isJoinDeliverySlotPointSale) {
$this->isJoinDeliverySlotPointSale = true;

return $this
->leftJoin('deliveryAvailabilityPointSale.deliverySlot', 'deliverySlotPointSale');
}
return $this;
}

public function joinOrderStatus(): self
{
if (!$this->isJoinOrderStatus) {

+ 52
- 87
Repository/Order/OrderShopStore.php Wyświetl plik

@@ -2,23 +2,20 @@

namespace Lc\CaracoleBundle\Repository\Order;

use App\Entity\Delivery\DeliveryAvailabilityPointSale;
use App\Entity\Delivery\DeliveryAvailabilityZone;
use App\Entity\Order\OrderStatus;
use App\Entity\Section\Section;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
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\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Resolver\OpeningResolver;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractStore;
@@ -42,6 +39,7 @@ class OrderShopStore extends AbstractStore
protected OpeningResolver $openingResolver;
protected ParameterBagInterface $parameterBag;
protected UrlGeneratorInterface $router;
protected OrderShopSolver $orderShopSolver;

public function __construct(
OrderShopRepositoryQuery $query,
@@ -55,7 +53,8 @@ class OrderShopStore extends AbstractStore
FlashBagInterface $flashBag,
OpeningResolver $openingResolver,
ParameterBagInterface $parameterBag,
UrlGeneratorInterface $router
UrlGeneratorInterface $router,
OrderShopSolver $orderShopSolver
) {
$this->query = $query;
$this->entityManager = $entityManager;
@@ -69,6 +68,7 @@ class OrderShopStore extends AbstractStore
$this->openingResolver = $openingResolver;
$this->parameterBag = $parameterBag;
$this->router = $router;
$this->orderShopSolver = $orderShopSolver;
}

// getOrderShopsOfWeek
@@ -96,7 +96,7 @@ class OrderShopStore extends AbstractStore
array_merge(
[
'user' => $user,
'weekNumber' => $this->getCycleNumberCurrentOrder($section),
'cycleNumber' => $this->getCycleNumberCurrentOrder($section),
'excludeComplementaryOrderShops' => true
],
$params
@@ -132,9 +132,9 @@ class OrderShopStore extends AbstractStore
}

// getNextWeekId
public function getNextCycleId(SectionInterface $section, int $cycleNumber): int
public function getNextCycleId(int $cycleNumber): int
{
$lastOrder = $this->getOneLastOrderValidOfCycle($section, $cycleNumber);
$lastOrder = $this->getOneLastValidOfCycle($cycleNumber);
if ($lastOrder) {
return intval($lastOrder->getCycleId() + 1);
} else {
@@ -142,9 +142,9 @@ class OrderShopStore extends AbstractStore
}
}

public function getNextIdValidOrder(Section $section)
public function getNextIdValidOrder(): int
{
$lastOrder = $this->getOneLastValid($section);
$lastOrder = $this->getOneLastValid();

if ($lastOrder) {
return intval($lastOrder->getIdValidOrder() + 1);
@@ -154,7 +154,7 @@ class OrderShopStore extends AbstractStore
}

// countValidOrderShopByUserAllMerchant
public function countValidByUserAllMerchant($user)
public function countValidByUserAllMerchant($user): int
{
$totalOrder = 0;

@@ -165,7 +165,7 @@ class OrderShopStore extends AbstractStore
return $totalOrder;
}

public function countValidByUser(UserInterface $user, MerchantInterface $merchant = null)
public function countValidByUser(UserInterface $user, MerchantInterface $merchant = null): int
{
return $this->getBy(
[
@@ -191,7 +191,7 @@ class OrderShopStore extends AbstractStore
$query
->selectCount()
->filterByReductionCredit($reductionCredit)
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterBySection($this->section);

return $query->count();
@@ -205,7 +205,7 @@ class OrderShopStore extends AbstractStore
$query
->selectCount()
->filterByReductionCart($reductionCart)
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterBySection($this->section);

return $query->count();
@@ -222,7 +222,7 @@ class OrderShopStore extends AbstractStore
->selectCount()
->filterByUser($user)
->filterByReductionCart($reductionCart)
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterBySection($this->section);

return $query->count();
@@ -244,7 +244,7 @@ class OrderShopStore extends AbstractStore

$query
->selectOrderReductionCarts()
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterBySection($this->section);

$results = $query->find();
@@ -263,7 +263,7 @@ class OrderShopStore extends AbstractStore

$query
->filterByCycleNumber($cycleNumber)
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterIsNotMainOrderShop()
->orderBy('.weekId', 'DESC')
->filterBySection($this->section);
@@ -277,7 +277,7 @@ class OrderShopStore extends AbstractStore
$query = $this->query->create();

$query
->filterByStatus(OrderStatus::$statusAliasAsValid)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterIsNotMainOrderShop()
->orderBy('.idValidOrder', 'DESC')
->filterBySection($this->section);
@@ -285,25 +285,44 @@ class OrderShopStore extends AbstractStore
return $query->findOne();
}

// @TODO : Fonction à tester
public function countBy(array $params = [])
{
$query = $this->query->create();

$query->selectCount();

$query = $this->applyGetByFilters($query);

return $query->count();
}


// findAllBy
public function getBy(array $params = [])
public function getBy(array $params = []): array
{
$query = $this->query->create();

$query = $this->applyGetByFilters($query);

$orderShops = $query->find();

if (isset($params['mergeComplementaryOrderShops'])) {
foreach ($orderShops as $orderShop) {
$this->orderShopSolver->mergeComplentaryOrderShops($orderShop);
}
}
return $orderShops;
}

protected function applyGetByFilters($query)
{
if (isset($params['section'])) {
$query->filterBySection($params['section']);
} else {
$query->filterBySection($this->section);
}

if (isset($params['count']) && $params['count']) {
$query->selectCount();
} else {
if (isset($params['select'])) {
$query->selectParam($params['select']);
}
if (isset($params['select'])) {
$query->selectParam($params['select']);
}

if (isset($params['dateStart']) || isset($params['dateEnd'])) {
@@ -323,15 +342,15 @@ class OrderShopStore extends AbstractStore
}

if (isset($params['isCart'])) {
$query->filterByStatus(OrderStatus::$statusAliasAsCart);
$query->filterByStatus(OrderStatusModel::$statusAliasAsCart);
}

if (isset($params['isValid'])) {
$query->filterByStatus(OrderStatus::$statusAliasAsValid);
$query->filterByStatus(OrderStatusModel::$statusAliasAsValid);
}

if (isset($params['isWaitingDelivery'])) {
$query->filterByStatus(OrderStatus::$statusAliasWaitingDelivery);
$query->filterByStatus(OrderStatusModel::$statusAliasWaitingDelivery);
}

if (isset($params['orderStatus'])) {
@@ -346,24 +365,6 @@ class OrderShopStore extends AbstractStore
$query->filterByAddress($params['address']);
}

if (isset($params['weekDeliveryTrucks'])) {
$query->filterByWeekDeliveryTruck($params['weekDeliveryTrucks']);
}

if (isset($params['estimatedDeliveryDateTime'])) {
$date = clone $params['estimatedDeliveryDateTime'];
$query
->filterByEstimatedDeliveryDateStart($date->format('Y-m-d 00:00:00'))
->filterByEstimatedDeliveryDateEnd($date->modify('+1 day')->format('Y-m-d 00:00:00'));
}

if (isset($params['deliveryDate'])) {
$date = clone $params['deliveryDate'];
$query
->filterByDeliveryDateStart($date->format('Y-m-d 00:00:00'))
->filterByDeliveryDateEnd($date->modify('+1 day')->format('Y-m-d 00:00:00'));
}

if (isset($params['mergeComplementaryOrderShops'])) {
$query
->joinComplementaryOrderShops();
@@ -373,39 +374,6 @@ class OrderShopStore extends AbstractStore
$query->filterIsNullMainOrderShop();
}

if (isset($params['isCircuit'])) {
$query->filterIsNullDeliveryPointSale();
}

if (isset($params['isDepository'])) {
$query->filterIsNotNullDeliveryPointSale();
}

if (isset($params['isOffCircuit'])) {
$query->filterIsPointSale('devAliasHorsTournee');
}

if (isset($params['isGiftVoucher'])) {
$query->filterIsPointSale('devAliasGiftVoucher');
}

if (isset($params['deliveryAvailability'])) {
$deliveryAvailability = $params['deliveryAvailability'];
$deliveryAvailabilityZone = ($deliveryAvailability instanceof DeliveryAvailabilityZone) ? $deliveryAvailability : false;
$deliveryAvailabilityPointSale = ($deliveryAvailability instanceof DeliveryAvailabilityPointSale) ? $deliveryAvailability : false;

if ($deliveryAvailabilityZone) {
$query->filterByAvailabilityPointZone($deliveryAvailabilityZone);
}

if ($deliveryAvailabilityPointSale) {
$query->filterByAvailabilityPointZone($deliveryAvailabilityPointSale);
}
} else {
$query->joinDeliverySlotZone();
$query->joinDeliverySlotPointSale();
}

if (isset($params['orderBy'])) {
$sort = isset($params['orderByDirection']) ? $params['orderByDirection'] : 'DESC';
$query->orderBy($params['orderBy'], $sort);
@@ -416,13 +384,10 @@ class OrderShopStore extends AbstractStore
if (isset($params['groupBy'])) {
$query->groupBy($params['groupBy']);
}
return $query;
}

if (isset($params['count']) && $params['count']) {
return $query->count();
}

return $query->find();
}

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

+ 0
- 3
Repository/PointSale/PointSaleRepositoryQuery.php Wyświetl plik

@@ -4,13 +4,10 @@ namespace Lc\CaracoleBundle\Repository\PointSale;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class PointSaleRepositoryQuery extends AbstractRepositoryQuery
{
use StatusRepositoryQueryTrait;

public function __construct(PointSaleRepository $repository, PaginatorInterface $paginator)
{

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

@@ -4,19 +4,14 @@ namespace Lc\CaracoleBundle\Repository\Product;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\TreeRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductCategoryRepositoryQuery extends AbstractRepositoryQuery
{
use SectionRepositoryQueryTrait;
use StatusRepositoryQueryTrait;
use TreeRepositoryQueryTrait;

protected $isJoinProductFamilies = false;


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

+ 0
- 5
Repository/Product/ProductFamilyRepositoryQuery.php Wyświetl plik

@@ -3,15 +3,10 @@
namespace Lc\CaracoleBundle\Repository\Product;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
{
use SectionRepositoryQueryTrait;
use StatusRepositoryQueryTrait;

public function __construct(ProductFamilyRepository $repository, PaginatorInterface $paginator)
{

+ 5
- 9
Repository/RepositoryTrait.php Wyświetl plik

@@ -2,18 +2,17 @@

namespace Lc\CaracoleBundle\Repository;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Repository\AbstractRepository as SovAbstractRepository;

// @TODO : à supprimer à terme, certainement
trait RepositoryTrait
{
protected $merchantResolver;
protected $sectionResolver;
protected MerchantResolver $merchantResolver;
protected SectionResolver $sectionResolver;

public function __construct(
ManagerRegistry $managerRegistry,
@@ -25,11 +24,8 @@ trait RepositoryTrait
$this->sectionResolver = $sectionResolver;
}


protected function setCriteria(array $criteria) :array
/*protected function setCriteria(array $criteria) :array
{
$criteria = parent::setCriteria($criteria);

$className = $this->getClassMetadata()->getName();
$entity = new $className;

@@ -51,6 +47,6 @@ trait RepositoryTrait
}
}
return $criteria;
}
}*/

}

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

@@ -8,6 +8,6 @@ trait SectionRepositoryQueryTrait
{
public function filterBySection(SectionInterface $section)
{
$this->andWhereSection($this->id, $section);
return $this->andWhereSection($this->id, $section);
}
}

+ 0
- 5
Repository/Site/PageRepositoryQuery.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Repository\Site;

use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\StatusRepositoryQueryTrait;
use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery;

class PageRepositoryQuery extends SovPageRepositoryQuery
{
use SectionRepositoryQueryTrait;
use StatusRepositoryQueryTrait;



}

+ 0
- 26
Repository/StatusRepositoryQueryTrait.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Repository;

trait StatusRepositoryQueryTrait
{
public function filterByStatus(int $status):self
{
return $this->andWhere('.status = :status')->setParameter(':status', $status);
}

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

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

public function filterIsOnlineAndOffline():self
{
return $this->andWhere('.status >= 0');
}
}

+ 0
- 22
Repository/TreeRepositoryQueryTrait.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Repository;


use Lc\SovBundle\Doctrine\EntityInterface;

trait TreeRepositoryQueryTrait
{
public function filterIsParent(){
return $this->andWhere('.parent is NULL');
}

public function filterIsChildren(){
return $this->andWhere('.parent is NOT NULL');
}

public function filterByParent(EntityInterface $parent){
return $this->andWhere('.parent = :parent')->setParameter('parent', $parent);
}

}

+ 56
- 1
Solver/Order/OrderShopSolver.php Wyświetl plik

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

namespace Lc\CaracoleBundle\Solver\Order;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopModel;
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
@@ -15,10 +17,12 @@ use Lc\CaracoleBundle\Solver\Price\PriceSolver;
class OrderShopSolver
{
protected PriceSolver $priceSolver;
protected EntityManagerInterface $entityManager;

public function __construct(PriceSolver $priceSolver)
public function __construct(PriceSolver $priceSolver, EntityManagerInterface $entityManager)
{
$this->priceSolver = $priceSolver;
$this->entityManager = $entityManager;
}

public function countQuantities(OrderShopInterface $orderShop): int
@@ -142,4 +146,55 @@ class OrderShopSolver
return null;
}

public function isDeliveryHome(OrderShopInterface $orderShop): bool
{
return $orderShop->getDeliveryType() == OrderShopModel::DELIVERY_TYPE_HOME;
}

public function isDeliveryPointSale(OrderShopInterface $orderShop): bool
{
return $orderShop->getDeliveryType() == OrderShopModel::DELIVERY_TYPE_POINTSALE;
}

public function isComplementaryOrderShop(OrderShopInterface $orderShop): bool
{
return (bool) $orderShop->getMainOrderShop() ;
}


public function mergeComplentaryOrderShops(OrderShopInterface $orderShop, bool $combineProducts = true) :OrderShopInterface
{
$this->entityManager->refresh($orderShop);

if ($orderShop->getComplementaryOrderShops()) {
foreach ($orderShop->getComplementaryOrderShops() as $complementaryOrderShop) {
foreach ($complementaryOrderShop->getOrderProducts() as $orderProductAdd) {
$updated = false;
foreach ($orderShop->getOrderProducts() as $orderProduct) {
if ($combineProducts && $orderProduct->getProduct()->getId() == $orderProductAdd->getProduct(
)->getId()
&& (string)$orderProduct->getPrice() == (string)$orderProductAdd->getPrice()
) {
$orderProduct->setUpdatedOnMergeComplementaryOrderShop(true);
$orderProduct->setQuantityOrder(
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder()
);

$updated = true;
}
}

if (!$updated) {
$orderProductAdd->setOnMergeComplementaryOrderShop($complementaryOrderShop);
$orderProductAdd->setCreatedOnMergeComplementaryOrderShop(true);
$orderShop->addOrderProduct($orderProductAdd);
}
}
}
}

return $orderShop;
}


}

+ 39
- 0
Solver/PointSale/PointSaleSolver.php Wyświetl plik

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


namespace Lc\CaracoleBundle\Solver\PointSale;


use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;

class PointSaleSolver
{

public function labelAdminChoice(PointSaleInterface $pointSale): string
{
if ($pointSale->getIsPublic()) {
return '[Public] ' . $pointSale->getTitle();
} else {
return '[Privée] ' . $pointSale->getTitle();
}
}

public function getSummary(PointSaleInterface $pointSale): string
{
$html = '';

if ($pointSale->getTitle()) {
$html .= $pointSale->getTitle() . '<br />';
}

if ($pointSale->getAddress()) {
$html .= $pointSale->getAddress()->getAddress() . '<br />';
}

if ($pointSale->getAddress()->getZip() || $pointSale->getAddress()->getCity()) {
$html .= $pointSale->getAddress()->getZip() . ' ' . $pointSale->getAddress()->getCity() . '<br />';
}

return $html;
}
}

+ 12
- 0
Solver/User/UserSolver.php Wyświetl plik

@@ -19,4 +19,16 @@ class UserSolver extends SovUserSolver

return false;
}


public function getAge(UserInterface $user): ?int
{
if ($user->getBirthdate()) {
$now = new \DateTime();
$interval = $now->diff($user->getBirthdate());
return $interval->y;
} else {
return null;
}
}
}

Ładowanie…
Anuluj
Zapisz