Browse Source

Refactoring Repo

packProduct
Guillaume 3 years ago
parent
commit
af5ab7c4ce
68 changed files with 1755 additions and 357 deletions
  1. +95
    -1
      Model/Address/AddressInterface.php
  2. +1
    -1
      Model/Address/AddressModel.php
  3. +13
    -1
      Model/Config/TaxRateInterface.php
  4. +1
    -1
      Model/Config/TaxRateModel.php
  5. +30
    -2
      Model/Config/UnitInterface.php
  6. +1
    -1
      Model/Config/UnitModel.php
  7. +2
    -1
      Model/File/DocumentModel.php
  8. +0
    -2
      Model/Newsletter/NewsletterModel.php
  9. +235
    -1
      Model/Order/OrderShopInterface.php
  10. +1
    -1
      Model/Order/OrderShopModel.php
  11. +42
    -1
      Model/Product/ProductCategoryInterface.php
  12. +1
    -1
      Model/Product/ProductCategoryModel.php
  13. +239
    -1
      Model/Product/ProductFamilyInterface.php
  14. +1
    -1
      Model/Product/ProductFamilyModel.php
  15. +60
    -1
      Model/Product/ProductInterface.php
  16. +1
    -1
      Model/Product/ProductModel.php
  17. +17
    -0
      Repository/Address/AddressStore.php
  18. +23
    -4
      Repository/Config/TaxRateStore.php
  19. +18
    -1
      Repository/Config/UnitStore.php
  20. +5
    -4
      Repository/Credit/CreditHistoryRepositoryQuery.php
  21. +22
    -6
      Repository/Credit/CreditHistoryStore.php
  22. +23
    -4
      Repository/File/DocumentStore.php
  23. +15
    -4
      Repository/Merchant/MerchantStore.php
  24. +2
    -1
      Repository/Newsletter/NewsletterRepositoryQuery.php
  25. +30
    -0
      Repository/Newsletter/NewsletterStore.php
  26. +17
    -0
      Repository/Order/OrderPaymentStore.php
  27. +17
    -0
      Repository/Order/OrderProductReductionCatalogStore.php
  28. +16
    -0
      Repository/Order/OrderProductRefundStore.php
  29. +17
    -0
      Repository/Order/OrderProductStore.php
  30. +17
    -0
      Repository/Order/OrderReductionCartStore.php
  31. +17
    -0
      Repository/Order/OrderReductionCreditStore.php
  32. +17
    -0
      Repository/Order/OrderRefundStore.php
  33. +2
    -2
      Repository/Order/OrderShopRepositoryQuery.php
  34. +124
    -34
      Repository/Order/OrderShopStore.php
  35. +17
    -0
      Repository/Order/OrderStatusHistoryStore.php
  36. +17
    -0
      Repository/Order/OrderStatusStore.php
  37. +18
    -0
      Repository/PointSale/PointSaleStore.php
  38. +18
    -0
      Repository/Product/ProductCategoryStore.php
  39. +72
    -1
      Repository/Product/ProductFamilyRepositoryQuery.php
  40. +83
    -3
      Repository/Product/ProductFamilyStore.php
  41. +64
    -0
      Repository/Product/ProductRepositoryQuery.php
  42. +32
    -0
      Repository/Product/ProductStore.php
  43. +21
    -52
      Repository/Reduction/ReductionCartStore.php
  44. +24
    -1
      Repository/Reduction/ReductionCatalogStore.php
  45. +23
    -1
      Repository/Reduction/ReductionCreditStore.php
  46. +3
    -39
      Repository/Reminder/ReminderStore.php
  47. +21
    -0
      Repository/Section/OpeningStore.php
  48. +7
    -0
      Repository/Section/SectionRepositoryQuery.php
  49. +28
    -7
      Repository/Section/SectionStore.php
  50. +21
    -0
      Repository/Setting/MerchantSettingStore.php
  51. +21
    -0
      Repository/Setting/SectionSettingStore.php
  52. +3
    -5
      Repository/Site/NewsStore.php
  53. +5
    -10
      Repository/Site/PageStore.php
  54. +3
    -17
      Repository/Ticket/TicketStore.php
  55. +9
    -0
      Repository/User/GroupUserStore.php
  56. +20
    -6
      Repository/User/UserMerchantStore.php
  57. +17
    -0
      Repository/User/UserPointSaleStore.php
  58. +7
    -0
      Repository/User/UserStore.php
  59. +18
    -1
      Repository/User/VisitorStore.php
  60. +0
    -2
      Resolver/OpeningResolver.php
  61. +0
    -48
      Resolver/ReductionResolver.php
  62. +11
    -4
      Resolver/SectionResolver.php
  63. +23
    -24
      Solver/Address/AddressSolver.php
  64. +2
    -2
      Solver/Order/OrderProductReductionCatalogSolver.php
  65. +8
    -4
      Solver/Order/OrderShopSolver.php
  66. +2
    -4
      Transformer/Order/OrderShopTransformer.php
  67. +15
    -15
      Twig/StoreTwigExtension.php
  68. +0
    -33
      Twig/TwigExtension.php

+ 95
- 1
Model/Address/AddressInterface.php View File

@@ -2,7 +2,101 @@

namespace Lc\CaracoleBundle\Model\Address;


use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\SovBundle\Model\User\UserInterface;

/**
* @ORM\MappedSuperclass()
*/
interface AddressInterface
{
public function getUser(): ?UserInterface;

public function setUser(?UserInterface $user): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getTitle(): ?string;

public function setTitle(string $title): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getType(): ?string;

public function setType(string $type): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getCivility(): ?bool;

public function setCivility(?bool $civility): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getLastname(): ?string;

public function setLastname(?string $lastname): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getFirstname(): ?string;

public function setFirstname(?string $firstname): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getAddress(): ?string;

public function setAddress(string $address): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getZip(): ?string;

public function setZip(string $zip): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getCity(): ?string;

public function setCity(string $city): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getCountry(): ?string;

public function setCountry(string $country): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getLatitude(): ?string;

public function setLatitude(?string $latitude): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getLongitude(): ?string;

public function setLongitude(?string $longitude): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getLatitudeOverride(): ?string;

public function setLatitudeOverride(?string $latitudeOverride): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getLongitudeOverride(): ?string;

public function setLongitudeOverride(?string $longitudeOverride): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getCompany(): ?string;

public function setCompany(?string $company): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getSiret(): ?string;

public function setSiret(?string $siret): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getTva(): ?string;

public function setTva(?string $tva): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getPhone(): ?array;

public function setPhone(?array $phone): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getComment(): ?string;

public function setComment(?string $comment): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getPointSale(): ?PointSaleInterface;

public function setPointSale(PointSaleInterface $pointSale): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getMerchant(): ?MerchantInterface;

public function setMerchant(MerchantInterface $merchant): \Lc\CaracoleBundle\Model\Address\AddressModel;

public function getDeliveryInfos(): ?string;

}
public function setDeliveryInfos(?string $deliveryInfos): \Lc\CaracoleBundle\Model\Address\AddressModel;
}

+ 1
- 1
Model/Address/AddressModel.php View File

@@ -13,7 +13,7 @@ use Lc\SovBundle\Model\User\UserInterface;
/**
* @ORM\MappedSuperclass()
*/
abstract class AddressModel extends AbstractLightEntity implements StatusInterface
abstract class AddressModel extends AbstractLightEntity implements StatusInterface, AddressInterface
{
use StatusTrait;


+ 13
- 1
Model/Config/TaxRateInterface.php View File

@@ -2,7 +2,19 @@

namespace Lc\CaracoleBundle\Model\Config;


/**
* @ORM\MappedSuperclass()
*/
interface TaxRateInterface
{
public function getBehaviorTaxRateChoices(): array;

public function getTitle(): ?string;

public function setTitle(string $title): \Lc\CaracoleBundle\Model\Config\TaxRateModel;

public function getValue(): ?float;

}
public function setValue(float $value): \Lc\CaracoleBundle\Model\Config\TaxRateModel;
}

+ 1
- 1
Model/Config/TaxRateModel.php View File

@@ -8,7 +8,7 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
/**
* @ORM\MappedSuperclass()
*/
abstract class TaxRateModel extends AbstractLightEntity
abstract class TaxRateModel extends AbstractLightEntity implements TaxRateInterface
{

const BEHAVIOR_TAX_RATE_INCLUDED = 'tax-included';

+ 30
- 2
Model/Config/UnitInterface.php View File

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

namespace Lc\CaracoleBundle\Model\Config ;
namespace Lc\CaracoleBundle\Model\Config;


/**
* @ORM\MappedSuperclass
*/
interface UnitInterface
{
public function getUnitAmountChoices(): array;

public function getUnit(): ?string;

public function setUnit(string $unit): \Lc\CaracoleBundle\Model\Config\UnitModel;

public function getWording(): ?string;

public function setWording(string $wording): \Lc\CaracoleBundle\Model\Config\UnitModel;

public function getWordingUnit(): ?string;

public function setWordingUnit(string $wordingUnit): \Lc\CaracoleBundle\Model\Config\UnitModel;

public function getWordingShort(): ?string;

public function setWordingShort(string $wordingShort): \Lc\CaracoleBundle\Model\Config\UnitModel;

public function getCoefficient(): ?int;

public function setCoefficient(int $coefficient): \Lc\CaracoleBundle\Model\Config\UnitModel;

public function getUnitReference(): ?self;

}
public function setUnitReference(?self $unitReference): \Lc\CaracoleBundle\Model\Config\UnitModel;
}

+ 1
- 1
Model/Config/UnitModel.php View File

@@ -8,7 +8,7 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
/**
* @ORM\MappedSuperclass
*/
abstract class UnitModel extends AbstractLightEntity
abstract class UnitModel extends AbstractLightEntity implements UnitInterface
{

const UNIT_PERCENT = 'percent';

+ 2
- 1
Model/File/DocumentModel.php View File

@@ -7,6 +7,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderRefundInterface;
@@ -18,7 +19,7 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
/**
* @ORM\MappedSuperclass()
*/
abstract class DocumentModel extends AbstractFullEntity implements FilterMerchantInterface
abstract class DocumentModel extends AbstractFullEntity implements FilterSectionInterface
{
use BlameableNullableTrait;


+ 0
- 2
Model/Newsletter/NewsletterModel.php View File

@@ -3,9 +3,7 @@
namespace Lc\CaracoleBundle\Model\Newsletter;

use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\Newsletter\NewsletterModel as SovNewsletterModel;


+ 235
- 1
Model/Order/OrderShopInterface.php View File

@@ -2,7 +2,241 @@

namespace Lc\CaracoleBundle\Model\Order;


use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\User\UserInterface;

/**
* @ORM\MappedSuperclass()
*/
interface OrderShopInterface
{
public function getValidationDate(): ?\DateTimeInterface;

public function setValidationDate(\DateTimeInterface $validationDate
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getUser(): ?UserInterface;

public function setUser(?UserInterface $user): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getInvoiceAddress(): ?AddressInterface;

public function setInvoiceAddress(?AddressInterface $invoiceAddress): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getInvoiceAddressText(): ?string;

public function setInvoiceAddressText(string $invoiceAddressText): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getComment(): ?string;

public function setComment(?string $comment): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getMeanPayment(): ?string;

public function setMeanPayment(string $meanPayment): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

/**
* @return Collection|OrderStatusHistoryInterface[]
*/
public function getOrderStatusHistories(): Collection;

public function addOrderStatusHistory(OrderStatusHistoryInterface $orderStatusHistory
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function removeOrderStatusHistory(OrderStatusHistoryInterface $orderStatusHistory
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

/**
* @return Collection|OrderPaymentInterface[]
*/
public function getOrderPayments($meanPayment = null): Collection;

public function addOrderPayment(OrderPaymentInterface $orderPayment): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function removeOrderPayment(OrderPaymentInterface $orderPayment
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

/**
* @return Collection|OrderProductInterface[]
*/
public function getOrderProducts(): Collection;

public function addOrderProduct(OrderProductInterface $orderProduct): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function removeOrderProduct(OrderProductInterface $orderProduct
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getVisitor(): ?VisitorInterface;

public function setVisitor(?VisitorInterface $visitor): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getDeliveryInfos(): ?string;

public function setDeliveryInfos(?string $deliveryInfos): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getOrderStatus(): ?OrderStatusInterface;

public function setOrderStatusProtected(?OrderStatusInterface $orderStatus
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

/**
* @return Collection|OrderReductionCartInterface[]
*/
public function getOrderReductionCarts(): Collection;

public function addOrderReductionCart(OrderReductionCartInterface $orderReductionCart
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function removeOrderReductionCart(OrderReductionCartInterface $orderReductionCart
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

/**
* @return Collection|OrderReductionCreditInterface[]
*/
public function getOrderReductionCredits(): Collection;

public function addOrderReductionCredit(OrderReductionCreditInterface $orderReductionCredit
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function removeOrderReductionCredit(OrderReductionCreditInterface $orderReductionCredit
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

/**
* @return Collection|DocumentInterface[]
*/
public function getDocuments(): Collection;

public function addDocument(DocumentInterface $document): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function removeDocument(DocumentInterface $document): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

/**
* @return Collection|TicketInterface[]
*/
public function getTickets(): Collection;

public function addTicket(TicketInterface $ticket): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function removeTicket(TicketInterface $ticket): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getSection(): ?SectionInterface;

public function setSection(?SectionInterface $section): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getCycleId(): ?int;

public function setCycleId(?int $cycleId): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getCycleNumber(): ?int;

public function setCycleNumber(?int $cycleNumber): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getOrderShopCreatedAt(): ?\DateTimeInterface;

public function setOrderShopCreatedAt(?\DateTimeInterface $orderShopCreatedAt
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getIdValidOrder(): ?int;

public function setIdValidOrder(?int $idValidOrder): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getDeliveryAddress(): ?AddressInterface;

public function setDeliveryAddress(?AddressInterface $deliveryAddress
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getDeliveryAddressText(): ?string;

public function setDeliveryAddressText(string $deliveryAddressText): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getDeliveryPointSale(): ?PointSaleInterface;

public function setDeliveryPointSale(?PointSaleInterface $deliveryPointSale
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getDeliveryType(): ?string;

public function setDeliveryType(?string $deliveryType): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getDeliveryPrice(): ?float;

public function setDeliveryPrice(?float $deliveryPrice): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getDeliveryTaxRate(): ?TaxRateInterface;

public function setDeliveryTaxRate(?TaxRateInterface $deliveryTaxRate
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getReference(): ?string;

public function setReference(?string $reference): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getMainOrderShop(): ?self;

public function setMainOrderShop(?self $mainOrderShop): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

/**
* @return Collection|OrderShopInterface[]
*/
public function getComplementaryOrderShops(): Collection;

public function addComplementaryOrderShop(self $complementaryOrderShop
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function removeComplementaryOrderShop(self $complementaryOrderShop
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getDeclineComplementaryOrderShop(): ?bool;

public function setDeclineComplementaryOrderShop(?bool $declineComplementaryOrderShop
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getOrderAllowByAdmin(): ?bool;

public function setOrderAllowByAdmin(?bool $orderAllowByAdmin): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getHasReach(): ?int;

public function setHasReach(?int $hasReach): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getStatTotal(): ?float;

public function setStatTotal(?float $statTotal): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getStatTotalWithTax(): ?float;

public function setStatTotalWithTax(?float $statTotalWithTax): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getStatTotalOrderProductsWithReductions(): ?float;

public function setStatTotalOrderProductsWithReductions(?float $statTotalOrderProductsWithReductions
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getStatTotalOrderProductsWithTaxAndReductions(): ?float;

public function setStatTotalOrderProductsWithTaxAndReductions(?float $statTotalOrderProductsWithTaxAndReductions
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getStatMarginOrderProductsWithReductions(): ?float;

public function setStatMarginOrderProductsWithReductions(?float $statMarginOrderProductsWithReductions
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getStatDeliveryPriceWithReduction(): ?float;

public function setStatDeliveryPriceWithReduction(?float $statDeliveryPriceWithReduction
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;

public function getStatDeliveryPriceWithTaxAndReduction(): ?float;

}
public function setStatDeliveryPriceWithTaxAndReduction(?float $statDeliveryPriceWithTaxAndReduction
): \Lc\CaracoleBundle\Model\Order\OrderShopModel;
}

+ 1
- 1
Model/Order/OrderShopModel.php View File

@@ -21,7 +21,7 @@ use Lc\SovBundle\Model\User\UserInterface;
/**
* @ORM\MappedSuperclass()
*/
abstract class OrderShopModel extends AbstractLightEntity implements FilterSectionInterface
abstract class OrderShopModel extends AbstractLightEntity implements FilterSectionInterface, OrderShopInterface
{
use BlameableNullableTrait;


+ 42
- 1
Model/Product/ProductCategoryInterface.php View File

@@ -2,7 +2,48 @@

namespace Lc\CaracoleBundle\Model\Product;


use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

/**
* @ORM\MappedSuperclass()
*/
interface ProductCategoryInterface
{
public function getSection(): SectionInterface;

public function setSection(SectionInterface $section): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel;

public function getParent(): ?self;

public function setParent(?self $productCategory): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel;

public function getParentCategory();

/**
* @return Collection|self[]
*/
public function getChildrens(): Collection;

public function addChildren(self $productCategory): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel;

public function removeChildren(self $productCategory): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel;

/**
* @return Collection|ProductFamilyInterface[]
*/
public function getProductFamilies(): Collection;

public function addProductFamily(ProductFamilyInterface $productFamily
): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel;

public function removeProductFamily(ProductFamilyInterface $productFamily
): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel;

public function countProductFamilies($status = null);

public function getSaleStatus(): ?bool;

}
public function setSaleStatus(bool $saleStatus): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel;
}

+ 1
- 1
Model/Product/ProductCategoryModel.php View File

@@ -13,7 +13,7 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
/**
* @ORM\MappedSuperclass()
*/
abstract class ProductCategoryModel extends AbstractFullEntity implements TreeInterface, FilterSectionInterface
abstract class ProductCategoryModel extends AbstractFullEntity implements TreeInterface, FilterSectionInterface, ProductCategoryInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")

+ 239
- 1
Model/Product/ProductFamilyInterface.php View File

@@ -2,7 +2,245 @@

namespace Lc\CaracoleBundle\Model\Product;


use Doctrine\Common\Collections\Collection;
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\File\FileInterface;

/**
* @ORM\MappedSuperclass()
*/
interface ProductFamilyInterface
{
public function getBehaviorCountStockChoices(): array;

public function getBehaviorDisplaySaleChoices(): array;

public function getBehaviorStockCycleChoices(): array;

public function getWaringMessageTypeChoices(): array;

public function getBehaviorAddToCartChoices(): array;

public function getBehaviorPriceChoices(): array;

public function getPropertyOrganicLabelChoices(): array;

public function getTypeExpirationDateChoices(): array;

public function getBehaviorExpirationDateChoices(): array;

public function getSection(): SectionInterface;

public function setSection(SectionInterface $section): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getAvailableQuantityInherited();

public function getTaxRateInherited();

public function getActiveProducts(): ?bool;

public function setActiveProducts(bool $activeProducts): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getProductsQuantityAsTitle(): ?bool;

public function setProductsQuantityAsTitle(bool $productsQuantityAsTitle
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getProductsType(): ?string;

public function setProductsType(?string $productsType): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getQuantityLabel(): ?string;

public function setQuantityLabel(?string $quantityLabel): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

/**
* @return Collection|ProductInterface[]
*/
public function getProducts(): Collection;

public function getProductsOnline(): Collection;

public function addProduct(ProductInterface $product): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function removeProduct(ProductInterface $product): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getReductionCatalog(): ?ReductionCatalogInterface;

public function getReductionCatalogInherited(): ?ReductionCatalogInterface;

public function setReductionCatalog(?ReductionCatalogInterface $reductionCatalog
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

/**
* @return Collection|ProductCategoryInterface[]
*/
public function getProductCategories(): Collection;

public function initProductCategories();

public function addProductCategory(ProductCategoryInterface $productCategory
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function removeProductCategory(ProductCategoryInterface $productCategory
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getProductCategoryParent();

public function getProductCategoryChild();

public function getSubtitle(): ?string;

public function setSubtitle(?string $subtitle): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getWarningMessage(): ?string;

public function setWarningMessage(?string $warningMessage): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getWarningMessageType(): ?string;

public function setWarningMessageType(?string $warningMessageType
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getNote(): ?string;

public function setNote(?string $note): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getBehaviorOutOfStock(): ?string;

public function setBehaviorOutOfStock(?string $behaviorOutOfStock
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getBehaviorCountStock(): ?string;

public function setBehaviorCountStock(string $behaviorCountStock
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getExportTitle(): ?string;

public function setExportTitle(?string $exportTitle): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getExportNote(): ?string;

public function setExportNote(?string $exportNote): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getBehaviorStockWeek(): ?string;

public function setBehaviorStockWeek(string $behaviorStockWeek
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getAvailabilityRenewedThisWeek(): ?bool;

public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getBehaviorDisplaySale(): ?string;

public function setBehaviorDisplaySale(string $behaviorDisplaySale
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function isPropertyNoveltyOnline(): ?bool;

public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface;

public function setPropertyNoveltyExpirationDate(?\DateTimeInterface $propertyNoveltyExpirationDate
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyOrganicLabel(): ?string;

public function setPropertyOrganicLabel(?string $propertyOrganicLabel
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyAllergens(): ?string;

public function setPropertyAllergens(?string $propertyAllergens
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyComposition(): ?string;

public function setPropertyComposition(?string $propertyComposition
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyFragrances(): ?string;

public function setPropertyFragrances(?string $propertyFragrances
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function countProperties(): bool;

public function getBehaviorExpirationDate(): ?string;

public function setBehaviorExpirationDate(?string $behaviorExpirationDate
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getTypeExpirationDate(): ?string;

public function setTypeExpirationDate(?string $typeExpirationDate
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyWeight(): ?string;

public function setPropertyWeight(?string $propertyWeight): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyQuantity(): ?string;

public function setPropertyQuantity(?string $propertyQuantity): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyVariety(): ?string;

public function setPropertyVariety(?string $propertyVariety): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyFeature(): ?string;

public function setPropertyFeature(?string $propertyFeature): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyAlcoholLevel(): ?string;

public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyPackaging(): ?string;

public function setPropertyPackaging(?string $propertyPackaging
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getPropertyCharacteristics(): ?string;

public function setPropertyCharacteristics(?string $propertyCharacteristics
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getBehaviorAddToCart(): ?string;

public function setBehaviorAddToCart(?string $behaviorAddToCart
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getBehaviorPrice(): ?string;

public function getBehaviorPriceInherited();

public function setBehaviorPrice(?string $behaviorPrice): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function hasProductsWithVariousWeight();

public function getProductsGroupByTitle();

public function getOriginProduct();

public function getOriginProductOnline();

public function hasOneProductOnline();

public function getSaleStatus(): ?bool;

public function setSaleStatus(bool $saleStatus): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;

public function getFieldBuyingPrice();

public function getFieldPrice();

public function getImage(): ?FileInterface;

}
public function setImage(?FileInterface $image): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
}

+ 1
- 1
Model/Product/ProductFamilyModel.php View File

@@ -21,7 +21,7 @@ use Lc\SovBundle\Model\File\FileInterface;
* @ORM\MappedSuperclass()
*/
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface,
FilterSectionInterface
FilterSectionInterface, ProductFamilyInterface
{
use ProductPropertyTrait;
use BlameableNullableTrait;

+ 60
- 1
Model/Product/ProductInterface.php View File

@@ -2,7 +2,66 @@

namespace Lc\CaracoleBundle\Model\Product;


use Lc\CaracoleBundle\Model\Order\OrderShopInterface;

/**
* @ORM\MappedSuperclass()
*/
interface ProductInterface
{
public function getQuantityMaxAddCart(OrderShopInterface $orderShop);

public function getProductQuantity();

public function getBuyingPriceInherited();

public function getBuyingPriceByRefUnitInherited();

public function getPriceInherited();

public function getPriceByRefUnitInherited();

public function getBehaviorPriceInherited();

public function getReductionCatalogInherited();

public function getUnitInherited();

public function getTitleInherited();

public function getQuantityInherited();

public function getQuantityLabelInherited();

public function getQuantityTitle($productFamily);

public function getAvailableQuantityInherited();

public function getTaxRateInherited();

public function getProductFamily(): ?ProductFamilyInterface;

public function setProductFamily(?ProductFamilyInterface $productFamily
): \Lc\CaracoleBundle\Model\Product\ProductModel;

public function getTitle(): ?string;

public function setTitle(?string $title): \Lc\CaracoleBundle\Model\Product\ProductModel;

public function getOriginProduct(): ?bool;

public function setOriginProduct(?bool $originProduct): \Lc\CaracoleBundle\Model\Product\ProductModel;

public function getExportTitle(): ?string;

public function getExportTitleInherited(): ?string;

public function setExportTitle(?string $exportTitle): \Lc\CaracoleBundle\Model\Product\ProductModel;

public function getExportNote(): ?string;

public function getExportNoteInherited(): ?string;

}
public function setExportNote(?string $exportNote): \Lc\CaracoleBundle\Model\Product\ProductModel;
}

+ 1
- 1
Model/Product/ProductModel.php View File

@@ -19,7 +19,7 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
* @ORM\MappedSuperclass()
*/
abstract class ProductModel extends AbstractLightEntity implements SortableInterface, ProductPropertyInterface,
PriceInterface
PriceInterface, ProductInterface
{
use SortableTrait;
use ProductPropertyTrait;

+ 17
- 0
Repository/Address/AddressStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Address;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class AddressStore extends AbstractStore
{
@@ -12,4 +13,20 @@ class AddressStore extends AbstractStore
{
$this->query = $query;
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterIsOnlineAndOffline();
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 23
- 4
Repository/Config/TaxRateStore.php View File

@@ -3,21 +3,40 @@
namespace Lc\CaracoleBundle\Repository\Config;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class TaxRateStore extends AbstractStore
{
use MerchantStoreTrait;

protected TaxRateRepositoryQuery $query;

public function __construct(TaxRateRepositoryQuery $query)
{
$this->query = $query;
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

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

$taxRatesList = [];

@@ -26,8 +45,8 @@ class TaxRateStore extends AbstractStore
$taxRatesList[$taxRate->getId()]['value'] = $taxRate->getValue();
}

$taxRatesList['default']['title'] = $merchant->getTaxRate()->getTitle();
$taxRatesList['default']['value'] = $merchant->getTaxRate()->getValue();
$taxRatesList['default']['title'] = $this->merchant->getTaxRate()->getTitle();
$taxRatesList['default']['value'] = $this->merchant->getTaxRate()->getValue();

return $taxRatesList;
}

+ 18
- 1
Repository/Config/UnitStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Config;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

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

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

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

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

+ 5
- 4
Repository/Credit/CreditHistoryRepositoryQuery.php View File

@@ -5,6 +5,8 @@ namespace Lc\CaracoleBundle\Repository\Credit;
use App\Entity\Merchant\Merchant;
use App\Entity\User\UserMerchant;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
use DateTime;

@@ -28,15 +30,14 @@ class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

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

public function filterByUserMerchant(UserMerchant $userMerchant): self
public function filterByUserMerchant(UserMerchantInterface $userMerchant): self
{
return $this
->andWhere('.userMerchant = :userMerchant')

+ 22
- 6
Repository/Credit/CreditHistoryStore.php View File

@@ -6,6 +6,7 @@ use App\Entity\User\UserMerchant;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use DateTime;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class CreditHistoryStore extends AbstractStore
{
@@ -18,16 +19,31 @@ class CreditHistoryStore extends AbstractStore
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('createdAt');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterByMerchant($this->merchant);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

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

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

return $query->find();
}
@@ -35,11 +51,11 @@ class CreditHistoryStore extends AbstractStore
//findAllByUserMerchant
public function getByUserMerchant(UserMerchant $userMerchant, $query = null): array
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

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

return $query->find();
}

+ 23
- 4
Repository/File/DocumentStore.php View File

@@ -6,6 +6,7 @@ use App\Entity\Address\Address;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class DocumentStore extends AbstractStore
{
@@ -18,6 +19,25 @@ class DocumentStore extends AbstractStore
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterIsOnlineAndOffline();
$query->filterBySection($this->section);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}


public function getOneLatestByType(string $documentType, $query = null)
{
// @TODO : à écrire
@@ -26,18 +46,17 @@ class DocumentStore extends AbstractStore
// findLastInvoice
public function getOneLastInvoice($query = null)
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$query
->filterBySection($this->section)
->orderBy('.createdAt', 'DESC');
->orderBy('createdAt', 'DESC');

return $query->findOne();
}

public function getByBuyerAddress(Address $buyerAddress, $query = null)
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);
$query->filterByBuyerAddress($buyerAddress);
return $query->find();
}

+ 15
- 4
Repository/Merchant/MerchantStore.php View File

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Repository\Merchant;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

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

public function getOnline($query = null)
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query = $this->createQuery($query);
$query->filterIsOnline();
return $query->find();
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterIsOnlineAndOffline();
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

}

+ 2
- 1
Repository/Newsletter/NewsletterRepositoryQuery.php View File

@@ -3,9 +3,10 @@
namespace Lc\CaracoleBundle\Repository\Newsletter;

use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\Newsletter\NewsletterRepositoryQuery as SovNewsletterRepositoryQuery;

class NewsletterRepositoryQuery extends SovNewsletterRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;
}

+ 30
- 0
Repository/Newsletter/NewsletterStore.php View File

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

namespace Lc\CaracoleBundle\Repository\Newsletter;

use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\Newsletter\NewsletterStore as SovNewsletterStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class NewsletterStore extends SovNewsletterStore
{
use SectionStoreTrait;

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('position');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
$query->filterIsOnlineAndOffline();
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Order/OrderPaymentStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderPaymentStore extends AbstractStore
{
@@ -12,4 +13,20 @@ class OrderPaymentStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Order/OrderProductReductionCatalogStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderProductReductionCatalogStore extends AbstractStore
{
@@ -12,4 +13,20 @@ class OrderProductReductionCatalogStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 16
- 0
Repository/Order/OrderProductRefundStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderProductRefundStore extends AbstractStore
{
@@ -12,4 +13,19 @@ class OrderProductRefundStore extends AbstractStore
{
$this->query = $query;
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Order/OrderProductStore.php View File

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Repository\Order;
use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderProductStore extends AbstractStore
{
@@ -14,4 +15,20 @@ class OrderProductStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Order/OrderReductionCartStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderReductionCartStore extends AbstractStore
{
@@ -12,4 +13,20 @@ class OrderReductionCartStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Order/OrderReductionCreditStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderReductionCreditStore extends AbstractStore
{
@@ -12,4 +13,20 @@ class OrderReductionCreditStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Order/OrderRefundStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderRefundStore extends AbstractStore
{
@@ -12,4 +13,20 @@ class OrderRefundStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 2
- 2
Repository/Order/OrderShopRepositoryQuery.php View File

@@ -126,10 +126,10 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->setParameter('cycleNumber', $cycleNumber);
}

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

public function filterIsNullMainOrderShop(): self

+ 124
- 34
Repository/Order/OrderShopStore.php View File

@@ -11,6 +11,7 @@ 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\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
@@ -19,8 +20,10 @@ use Lc\CaracoleBundle\Resolver\OpeningResolver;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -34,6 +37,7 @@ class OrderShopStore extends AbstractStore
protected PriceSolver $priceSolver;
protected DocumentBuilder $documentBuilder;
protected ReductionCreditStore $reductionCreditStore;
protected ReductionCartSolver $reductionCartSolver;
protected SectionStore $sectionStore;
protected OrderProductStore $orderProductStore;
protected MerchantStore $merchantStore;
@@ -49,6 +53,7 @@ class OrderShopStore extends AbstractStore
PriceSolver $priceSolver,
DocumentBuilder $documentBuilder,
ReductionCreditStore $reductionCreditStore,
ReductionCartSolver $reductionCartSolver,
SectionStore $sectionStore,
OrderProductStore $orderProductStore,
MerchantStore $merchantStore,
@@ -63,6 +68,7 @@ class OrderShopStore extends AbstractStore
$this->priceSolver = $priceSolver;
$this->documentBuilder = $documentBuilder;
$this->reductionCreditStore = $reductionCreditStore;
$this->reductionCartSolver = $reductionCartSolver;
$this->sectionStore = $sectionStore;
$this->orderProductStore = $orderProductStore;
$this->merchantStore = $merchantStore;
@@ -73,13 +79,29 @@ class OrderShopStore extends AbstractStore
$this->orderShopSolver = $orderShopSolver;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

// getOrderShopsOfWeek
public function getByCurrentCycle($params = [], $query = null)
{
$orderShops = $this->getBy(
array_merge(
[
'section' => $this->section,
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'isValid' => true,
],
@@ -176,7 +198,6 @@ class OrderShopStore extends AbstractStore
[
'user' => $user,
'isValid' => true,
'section' => $this->section,
'excludeComplementaryOrderShops' => true
],
$query
@@ -189,7 +210,6 @@ class OrderShopStore extends AbstractStore
[
'cycleNumber' => $this->getCycleNumberCurrentOrder($this->section),
'isValid' => true,
'section' => $this->section,
'excludeComplementaryOrderShops' => true
],
$query
@@ -202,7 +222,7 @@ class OrderShopStore extends AbstractStore
UserInterface $user = null,
$query = null
): int {
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

if ($user) {
$query->filterByUser($user);
@@ -211,8 +231,7 @@ class OrderShopStore extends AbstractStore
$query
->selectCount()
->filterByReductionCredit($reductionCredit)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterBySection($this->section);
->filterByStatus(OrderStatusModel::$statusAliasAsValid);

return $query->count();
}
@@ -222,13 +241,12 @@ class OrderShopStore extends AbstractStore
ReductionCartInterface $reductionCart,
$query = null
): int {
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$query
->selectCount()
->filterByReductionCart($reductionCart)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterBySection($this->section);
->filterByStatus(OrderStatusModel::$statusAliasAsValid);

return $query->count();
}
@@ -239,34 +257,33 @@ class OrderShopStore extends AbstractStore
UserInterface $user,
$query = null
): int {
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$query
->selectCount()
->filterByUser($user)
->filterByReductionCart($reductionCart)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterBySection($this->section);
->filterByStatus(OrderStatusModel::$statusAliasAsValid);

return $query->count();
}

// findCartCurrent
public function getCartCurrent(array $params, $query = null): ?OrderShopInterface
public function getOneCartCurrent(array $params, $query = null): ?OrderShopInterface
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

if (isset($params['user'])) {
$query->filterByUser($params['user']);
}

if (isset($params['visitor'])) {
$query->filterByVisitor($params['visitor']);
}

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

return $query->findOne();
}
@@ -274,14 +291,13 @@ class OrderShopStore extends AbstractStore
// findLastOrderValidOfWeek
public function getOneLastValidByCycle(int $cycleNumber, $query = null): ?OrderShopInterface
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$query
->filterByCycleNumber($cycleNumber)
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterIsNotMainOrderShop()
->orderBy('.cycleId', 'DESC')
->filterBySection($this->section);
->filterIsNotComplementaryOrderShop()
->orderBy('.cycleId', 'DESC');

return $query->findOne();
}
@@ -289,20 +305,19 @@ class OrderShopStore extends AbstractStore
//findLastOrderValid
public function getOneLastValid($query = null): ?OrderShopInterface
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$query
->filterByStatus(OrderStatusModel::$statusAliasAsValid)
->filterIsNotMainOrderShop()
->orderBy('.idValidOrder', 'DESC')
->filterBySection($this->section);
->filterIsNotComplementaryOrderShop()
->orderBy('.idValidOrder', 'DESC');

return $query->findOne();
}

public function countBy(array $params = [], $query = null)
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$query
->selectCount()
@@ -314,7 +329,7 @@ class OrderShopStore extends AbstractStore

public function getBy(array $params = [], $query = null): array
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$this->applyGetByFilters($query);

@@ -330,12 +345,6 @@ class OrderShopStore extends AbstractStore

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

if (isset($params['isMerchantOnline'])) {
$query->filterIsMerchantOnline();
}
@@ -415,12 +424,93 @@ class OrderShopStore extends AbstractStore
}
}

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

public function getReductionCreditsAvailableByUser(UserInterface $user): array
{
$reductionCredits = $this->reductionCreditStore->getByTypeAndUser(ReductionCreditModel::TYPE_CREDIT, $user);

$reductionCreditsArray = [];
foreach ($reductionCredits as $reductionCredit) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)) {
$reductionCreditsArray[] = $reductionCredit;
}
}

return $reductionCreditsArray;
}

public function getReductionGiftsAvailableByUser($user): array
{
$reductionGifts = $this->reductionCreditStore->getByTypeAndUser(ReductionCreditModel::TYPE_GIFT, $user);

$reductionGiftsArray = [];
foreach ($reductionGifts as $reductionGift) {
if (!$this->countValidWithReductionCredit($reductionGift)) {
$reductionGiftsArray[] = $reductionGift;
}
}

return $reductionGiftsArray;
}

// getReductionCartRemainingQuantity
public function getReductionCartRemainingQuantity(ReductionCartInterface $reductionCart): float
{
return $reductionCart->getAvailableQuantity() - $this->countValidWithReductionCart(
$reductionCart
);
}

// getReductionCartUsedQuantityPerUser
public function getReductionCartUsedQuantityByUser(ReductionCartInterface $reductionCart, UserInterface $user): float
{
return $this->countValidWithReductionCartByUser($reductionCart, $user);
}

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

// getReductionCartRemainingQuantityPerUser
public function getReductionCartRemainingQuantityByUser(ReductionCartInterface $reductionCart, UserInterface $user): float
{
if ($reductionCart->getAvailableQuantityPerUser()) {
return $reductionCart->getAvailableQuantityPerUser(
) - $this->countValidWithReductionCartByUser($reductionCart, $user);
}

return false;
}

// findAllAvailableForUser / getReductionCartsAvailableByUser
public function getReductionCartAvailableByUser(UserInterface $user, $query = null)
{
$query = $this->createQuery($query);
$reductionCarts = $query->find();

$reductionCartsArray = [];
foreach ($reductionCarts as $reductionCart) {
if ($this->reductionCartSolver->matchWithUser($user)
&& $this->reductionCartSolver->matchWithGroupUser($user)
&& $this->getRemainingQuantityByUser($reductionCart, $user)
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) {
$reductionCartsArray[] = $reductionCart;
}
}

return $reductionCartsArray;
}
}

+ 17
- 0
Repository/Order/OrderStatusHistoryStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderStatusHistoryStore extends AbstractStore
{
@@ -12,4 +13,20 @@ class OrderStatusHistoryStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Order/OrderStatusStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Order;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OrderStatusStore extends AbstractStore
{
@@ -12,4 +13,20 @@ class OrderStatusStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 18
- 0
Repository/PointSale/PointSaleStore.php View File

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Repository\PointSale;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class PointSaleStore extends AbstractStore
{
@@ -15,4 +16,21 @@ class PointSaleStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('position');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterByMerchant($this->merchant);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 18
- 0
Repository/Product/ProductCategoryStore.php View File

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Repository\Product;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ProductCategoryStore extends AbstractStore
{
@@ -16,4 +17,21 @@ class ProductCategoryStore extends AbstractStore
{
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('position');
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
return $query;
}

public function relationsDefault($query): RepositoryQueryInterface
{
$query->joinProductFamilies();
return $query;
}
}

+ 72
- 1
Repository/Product/ProductFamilyRepositoryQuery.php View File

@@ -3,13 +3,84 @@
namespace Lc\CaracoleBundle\Repository\Product;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery implements RepositoryQuery
{
protected bool $isJoinProductCategories;
protected bool $isJoinProducts;

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

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

return $this
->leftJoin('.productCategories', 'cat');
//$query->addSelect('cat') ; ???
}
return $this;
}


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

return $this
->innerJoin('.products', 'pfp');
// $query->addSelect('pfp') ; ?????
}
return $this;
}

public function orderByPosition(): self
{
$this->orderBy('e.position', 'ASC');
return $this;
}

public function filterByProductCategory(ProductCategoryInterface $category): self
{
$this->joinProductCategories();
return $this
->andWhere(':category MEMBER OF .productCategories')
->setParameter('category', $category->getId());
}


public function filterByPropertyNoveltyExpirationDate($dateTime = null): self
{
if (is_null($dateTime)) {
$dateTime = new \DateTime();
}

return $this->andWhere(':now <= e.propertyNoveltyExpirationDate')
->setParameter('now', $dateTime);
}

public function filterPropertyLargeVolume(): self
{
return $this->andWhere('.propertyLargeVolume = 1');
}

public function filterPropertyOrganicLabel(): self
{
return $this->andWhere('.propertyOrganicLabel IS NOT NULL');
}

public function filterByTerms($terms): self
{
$this->andWhere('.title LIKE :terms OR cat.title LIKE :terms');
$this->setParameter(':terms', '%'.$terms.'%') ;
return $this;
}

}

+ 83
- 3
Repository/Product/ProductFamilyStore.php View File

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

namespace Lc\CaracoleBundle\Repository\Product;

use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ProductFamilyStore extends AbstractStore
{
@@ -21,4 +20,85 @@ class ProductFamilyStore extends AbstractStore
$this->query = $query;
$this->priceSolver = $priceSolver;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('position');
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface

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

public function relationsDefault($query): RepositoryQueryInterface
{
$query->joinProductCategories();
$query->joinProducts();
return $query;
}

//getProductFamiliesByCategory
public function getByCategory(ProductCategoryInterface $productCategory, $query = null)
{
$query = $this->createDefaultQuery($query);

$query
->filterIsOnline()
->filterByProductCategory($productCategory);

return $query->find();
}
//getProductFamiliesNovelties
public function getByNovelties($query = null)
{
$query = $this->createDefaultQuery($query);

$query
->filterByPropertyNoveltyExpirationDate()
->filterIsOnline();

return $query->find();
}
//getProductFamiliesLargeVolumes
public function getLargeVolumes($query = null)
{
$query = $this->createDefaultQuery($query);

$query
->filterPropertyLargeVolume()
->filterIsOnline();

return $query->find();
}
//getProductFamiliesOrganics
public function getOrganics($query = null)
{
$query = $this->createDefaultQuery($query);

$query
->filterPropertyOrganicLabel()
->filterIsOnline();

return $query->find();
}
//findByTerms
public function getByTerms($terms, $maxResults = false, $query = null)
{
$query = $this->createDefaultQuery($query);

$query->filterIsOnline();
$query->groupBy('id');

if($maxResults) {
$query->limit($maxResults);
}

return $query->find();
}



}

+ 64
- 0
Repository/Product/ProductRepositoryQuery.php View File

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

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ProductRepositoryQuery extends AbstractRepositoryQuery
{
protected bool $isJoinProductFamily;

public function __construct(ProductRepository $repository, PaginatorInterface $paginator)
{
parent::__construct($repository, 'r', $paginator);
}
public function orderByDefault(): \Lc\SovBundle\Repository\AbstractRepositoryQuery
{
return $this->orderBy('position', 'ASC');
}

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

return $this
->innerJoin('.productFamily', 'pf');
//$qb->addSelect('pf'); ???
}
return $this;
}

public function filterBySection(SectionInterface $section):self
{
$this->joinProductFamily();
$this->andWhereSection('pf', $section);
return $this;
}

public function filterIsOnline():self
{
$this->joinProductFamily();
$this->andWhereStatus('pf', 1);
return $this;
}

public function filterBehaviorCountStock() :self
{
$this->andWhere(
$this->expr()->orX(
$this->expr()->andX(
$this->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantity < 0 '
),
$this->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'e.availableQuantity < 0 '
)
)
);
$this->setParameter(
'behaviorCountStockByProductFamily',
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
);
$this->setParameter('behaviorCountStockByMeasure', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
$this->setParameter('behaviorCountStockByProduct', ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);
return $this;
}


}

+ 32
- 0
Repository/Product/ProductStore.php View File

@@ -2,14 +2,46 @@

namespace Lc\CaracoleBundle\Repository\Product;

use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ProductStore extends AbstractStore
{
use SectionStoreTrait;

protected ProductRepositoryQuery $query;

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

public function orderByDefault(RepositoryQueryInterface $query) :RepositoryQueryInterface
{
return $query;
}

public function filtersDefault($query):RepositoryQueryInterface
{
$query->filterIsOnlineAndOffline();
$query->filterBySection($this->section);
}

public function relationsDefault($query):RepositoryQueryInterface
{
return $query->joinProductFamily();
}

//findProductByAvailabilitiesNegative
public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array
{
$query = $this->createDefaultQuery($query);
$query->filterIsOnline();
$query->filterBehaviorCountStock();
$query->groupBy('pf.id');
return $query->find();
}


}

+ 21
- 52
Repository/Reduction/ReductionCartStore.php View File

@@ -4,97 +4,66 @@ namespace Lc\CaracoleBundle\Repository\Reduction;

use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;

class ReductionCartStore extends AbstractStore
{
use SectionStoreTrait;

protected ReductionCartRepositoryQuery $query;
protected ReductionCartSolver $reductionCartSolver;
protected OrderShopStore $orderShopStore;
protected PriceSolver $priceSolver;
protected FlashBagInterface $flashBag;

public function __construct(
ReductionCartRepositoryQuery $query,
ReductionCartSolver $reductionCartSolver,
OrderShopStore $orderShopStore,
PriceSolver $priceSolver,
FlashBagInterface $flashBag,
) {
$this->query = $query;
$this->reductionCartSolver = $reductionCartSolver;
$this->orderShopStore = $orderShopStore;
$this->priceSolver = $priceSolver;
$this->flashBag = $flashBag;
}

// getReductionCartByCode
public function getByCode(string $code, $query = null)
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query = $this->createQuery($query);
$query->filterByCode($code);
$reductionCarts = $query->find();

$findReductionCart = null;
foreach ($reductionCarts as $reductionCart) {
if ($reductionCart && in_array($code, $reductionCart->getCodes())) {
$findReductionCart = $reductionCart;
}
}
return $findReductionCart;
$query->orderBy('id');
return $query;
}

// getReductionCartRemainingQuantity
public function getRemainingQuantity(ReductionCartInterface $reductionCart): float
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $reductionCart->getAvailableQuantity() - $this->orderShopStore->countValidWithReductionCart(
$reductionCart
);
$query->filterBySection($this->section);
$query->filterIsOnlineAndOffline();
return $query;
}

// getReductionCartUsedQuantityPerUser
public function getUsedQuantityByUser(ReductionCartInterface $reductionCart, UserInterface $user): float
public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $this->orderShopStore->countValidWithReductionCartByUser($reductionCart, $user);
return $query;
}

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

// getReductionCartRemainingQuantityPerUser
public function getRemainingQuantityByUser(ReductionCartInterface $reductionCart, UserInterface $user): float
{
if ($reductionCart->getAvailableQuantityPerUser()) {
return $reductionCart->getAvailableQuantityPerUser(
) - $this->orderShopStore->countValidWithReductionCartByUser($reductionCart, $user);
}

return false;
}

// findAllAvailableForUser / getReductionCartsAvailableByUser
public function getAvailableByUser(UserInterface $user, $query = null)
// getReductionCartByCode
public function getByCode(string $code, $query = null)
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);
$query->filterByCode($code);
$reductionCarts = $query->find();

$reductionCartsArray = [];
$findReductionCart = null;
foreach ($reductionCarts as $reductionCart) {
if ($this->reductionCartSolver->matchWithUser($user)
&& $this->reductionCartSolver->matchWithGroupUser($user)
&& $this->getRemainingQuantityByUser($reductionCart, $user)
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) {
$reductionCartsArray[] = $reductionCart;
if ($reductionCart && in_array($code, $reductionCart->getCodes())) {
$findReductionCart = $reductionCart;
}
}

return $reductionCartsArray;
return $findReductionCart;
}
}

+ 24
- 1
Repository/Reduction/ReductionCatalogStore.php View File

@@ -3,10 +3,14 @@
namespace Lc\CaracoleBundle\Repository\Reduction;

use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ReductionCatalogStore extends AbstractStore
{
use SectionStoreTrait;

protected ReductionCatalogRepositoryQuery $query;

public function __construct(ReductionCatalogRepositoryQuery $query)
@@ -14,9 +18,28 @@ class ReductionCatalogStore extends AbstractStore
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
$query->filterIsOnlineAndOffline();
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null)
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$query
->filterProductFamily($productFamily)
->filterIsOnline();

+ 23
- 1
Repository/Reduction/ReductionCreditStore.php View File

@@ -6,11 +6,15 @@ use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ReductionCreditStore extends AbstractStore
{
use SectionStoreTrait;

protected ReductionCreditRepositoryQuery $query;

public function __construct(
@@ -19,10 +23,28 @@ class ReductionCreditStore extends AbstractStore
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
$query->filterIsOnlineAndOffline();
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

// findReductionCreditsByUser
public function getByTypeAndUser(string $type, UserInterface $user, $query = null)
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);

$query
->filterByType($type)

+ 3
- 39
Repository/Reminder/ReminderStore.php View File

@@ -6,51 +6,15 @@ use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class ReminderStore extends SovReminderStore
{
use SectionStoreTrait;
use MerchantStoreTrait;

public function get($params = [], $query = null)
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query = $this->createQuery($query);

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

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

return parent::get($params, $query);
}

public function getByUser(UserInterface $user, $query = null): array
{
$query = $this->createQuery($query);

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

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

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

public function getByEasyAdminConfigAndUser(
string $crudAction,
string $crudControllerFqcn,
UserInterface $user,
int $entityId = null,
$query = null
): array {
$query = $this->createQuery($query);

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}
@@ -59,6 +23,6 @@ class ReminderStore extends SovReminderStore
$query->filterBySection($this->section);
}

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

+ 21
- 0
Repository/Section/OpeningStore.php View File

@@ -2,14 +2,35 @@

namespace Lc\CaracoleBundle\Repository\Section;

use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class OpeningStore extends AbstractStore
{
use SectionStoreTrait;

protected OpeningRepositoryQuery $query;

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

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('day');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 7
- 0
Repository/Section/SectionRepositoryQuery.php View File

@@ -15,4 +15,11 @@ class SectionRepositoryQuery extends AbstractRepositoryQuery
parent::__construct($repository, 'r', $paginator);
}

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

}

+ 28
- 7
Repository/Section/SectionStore.php View File

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

namespace Lc\CaracoleBundle\Repository\Section;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class SectionStore extends AbstractStore
@@ -20,16 +22,34 @@ class SectionStore extends AbstractStore
$this->query = $query;
}

// getSection
public function getOneByDevAlias(string $devAlias, $query = null): ?SectionInterface
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query = $this->createQuery($query);
$query->orderBy('position');
return $query;
}

$query
->filterByMerchant($this->merchant)
->filterByDevAlias($devAlias);
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterByMerchant($this->merchant);
return $query;
}

$section = $query->findOne();
public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function getOneDefault($query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByIsDefault(true);
return $query->findOne();
}

// getSection
public function getOneByDevAlias(string $devAlias, bool $isOnline = true, $query = null): ?SectionInterface
{
$section = parent::getOneByDevAlias($devAlias, $isOnline, $query);

if (!$section) {
throw new NotFoundHttpException('La section ' . $devAlias . ' est introuvable');
@@ -42,4 +62,5 @@ class SectionStore extends AbstractStore
{
// @TODO : à implémenter avec le nouveau système d'ouverture des commandes
}

}

+ 21
- 0
Repository/Setting/MerchantSettingStore.php View File

@@ -2,14 +2,35 @@

namespace Lc\CaracoleBundle\Repository\Setting;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class MerchantSettingStore extends AbstractStore
{
use MerchantStoreTrait;

protected MerchantSettingRepositoryQuery $query;

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

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterByMerchant($this->merchant);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 21
- 0
Repository/Setting/SectionSettingStore.php View File

@@ -2,14 +2,35 @@

namespace Lc\CaracoleBundle\Repository\Setting;

use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class SectionSettingStore extends AbstractStore
{
use SectionStoreTrait;

protected SectionSettingRepositoryQuery $query;

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

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 3
- 5
Repository/Site/NewsStore.php View File

@@ -3,19 +3,17 @@
namespace Lc\CaracoleBundle\Repository\Site;

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

class NewsStore extends SovNewsStore
{
use SectionStoreTrait;

public function getLatests(int $maxResults = 0, $query = null): array
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query = $this->createQuery($query);

$query->filterBySection($this->section);

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

}

+ 5
- 10
Repository/Site/PageStore.php View File

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Repository\Site;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\Site\PageInterface;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Repository\Site\PageStore as SovPageStore;

class PageStore extends SovPageStore
@@ -16,16 +17,10 @@ class PageStore extends SovPageStore
parent::__construct($query);
}

// findPage
public function getOneByDevAlias(string $devAlias, $query = null): ?PageInterface
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query = $this->createQuery($query);

$query
->filterIsOnline()
->filterByDevAlias($devAlias)
->filterBySection($this->section);

return $query->findOne();
$query->filterBySection($this->section);
return parent::filtersDefault($query);
}

}

+ 3
- 17
Repository/Ticket/TicketStore.php View File

@@ -4,31 +4,17 @@ namespace Lc\CaracoleBundle\Repository\Ticket;

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

class TicketStore extends SovTicketStore
{
use SectionStoreTrait;

public function getByUser(UserInterface $user, $query = null): array
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query = $this->createQuery($query);
$query->filterBySection($this->section);
return parent::getByUser($user, $query);
}

public function getOpen(int $limit = 0, $query = null): array
{
$query = $this->createQuery($query);
$query->filterBySection($this->section);
return parent::getOpen($limit, $query);
}

public function countOpen($query = null): string
{
$query = $this->createQuery($query);
$query->filterBySection($this->section);
return parent::countOpen($query);
return $query;
}

}

+ 9
- 0
Repository/User/GroupUserStore.php View File

@@ -2,9 +2,18 @@

namespace Lc\CaracoleBundle\Repository\User;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Repository\User\GroupUserStore as SovGroupUserStore;

class GroupUserStore extends SovGroupUserStore
{
use MerchantStoreTrait;

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterByMerchant($this->merchant);
return parent::filtersDefault($query);
}

}

+ 20
- 6
Repository/User/UserMerchantStore.php View File

@@ -8,6 +8,7 @@ use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Solver\User\UserMerchantSolver;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class UserMerchantStore extends AbstractStore
{
@@ -22,15 +23,28 @@ class UserMerchantStore extends AbstractStore
$this->userMerchantSolver = $userMerchantSolver;
}

// getUserMerchant
public function getOneByUser(UserInterface $user, $query = null): UserMerchantInterface
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query = $this->createQuery($query);
$query->orderBy('id');
return $query;
}

$query
->filterByMerchant($this->merchant)
->filterByUser($user);
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterByMerchant($this->merchant);
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

// getUserMerchant
public function getOneByUser(UserInterface $user, $query = null): UserMerchantInterface
{
$query = $this->createDefaultQuery($query);
$query->filterByUser($user);
return $query->findOne();
}


+ 17
- 0
Repository/User/UserPointSaleStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\User;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

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

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

}

+ 7
- 0
Repository/User/UserStore.php View File

@@ -4,10 +4,17 @@ namespace Lc\CaracoleBundle\Repository\User;

use App\Entity\Newsletter\Newsletter;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Repository\User\UserStore as SovUserStore;

class UserStore extends SovUserStore
{
use MerchantStoreTrait;

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterByMerchant($this->merchant);
return $query;
}

}

+ 18
- 1
Repository/User/VisitorStore.php View File

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Repository\User;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class VisitorStore extends AbstractStore
{
@@ -13,9 +14,25 @@ class VisitorStore extends AbstractStore
$this->query = $query;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}

public function getOneByCookie(string $cookie, $query = null)
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);
$query->filterByCookie($cookie);
return $query->findOne();
}

+ 0
- 2
Resolver/OpeningResolver.php View File

@@ -94,11 +94,9 @@ class OpeningResolver
return false;
}


// isMaximumOrderWeekAchieved
public function isMaximumOrderCycleAchieved(SectionInterface $section)
{

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

+ 0
- 48
Resolver/ReductionResolver.php View File

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

namespace Lc\CaracoleBundle\Resolver;

use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
use Lc\SovBundle\Model\User\UserInterface;

class ReductionResolver
{
protected OrderShopStore $orderShopStore;
protected ReductionCreditStore $reductionCreditStore;

public function __construct(OrderShopStore $orderShopStore, ReductionCreditStore $reductionCreditStore)
{
$this->orderShopStore = $orderShopStore;
$this->reductionCreditStore = $reductionCreditStore;
}

public function getReductionCreditsAvailableByUser(UserInterface $user)
{
$reductionCredits = $this->reductionCreditStore->getByTypeAndUser(ReductionCreditModel::TYPE_CREDIT, $user);

$reductionCreditsArray = [];
foreach ($reductionCredits as $reductionCredit) {
if (!$this->orderShopStore->countValidOrderWithReductionCredit($reductionCredit, $user)) {
$reductionCreditsArray[] = $reductionCredit;
}
}

return $reductionCreditsArray;
}

public function getReductionGiftsAvailableByUser($user)
{
$reductionGifts = $this->reductionCreditStore->getByTypeAndUser(ReductionCreditModel::TYPE_GIFT, $user);

$reductionGiftsArray = [];
foreach ($reductionGifts as $reductionGift) {
if (!$this->orderShopStore->countValidOrderWithReductionCredit($reductionGift)) {
$reductionGiftsArray[] = $reductionGift;
}
}

return $reductionGiftsArray;
}
}

+ 11
- 4
Resolver/SectionResolver.php View File

@@ -8,19 +8,22 @@ namespace Lc\CaracoleBundle\Resolver;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Resolver\UrlResolver;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security;

class SectionResolver
{
protected $sectionRepository;
protected $merchantResolver;
protected EntityManagerInterface $entityManager;
protected MerchantResolver $merchantResolver;
protected SectionStore $sectionStore;

public function __construct(MerchantResolver $merchantResolver, EntityManagerInterface $em)
public function __construct(EntityManagerInterface $entityManager, MerchantResolver $merchantResolver, SectionStore $sectionStore)
{
$this->em = $em;
$this->entityManager = $entityManager;
$this->merchantResolver = $merchantResolver;
$this->sectionStore = $sectionStore;
}

public function getCurrent(): SectionInterface
@@ -34,6 +37,10 @@ class SectionResolver

if ($currentAdminSection === null) {
$currentAdminSection = $this->em->getRepository(SectionInterface::class)->findOneBy(array('isDefault' => true));
$currentAdminSection = $this->sectionStore
->setMerchant($userMerchant->getMerchant())
->getOneDefault();

if ($currentAdminSection === null) {
throw new \ErrorException('Aucune section par défaut définie pour ce merchant');
}

+ 23
- 24
Solver/Address/AddressSolver.php View File

@@ -2,37 +2,38 @@

namespace Lc\CaracoleBundle\Solver\Address;

use Lc\CaracoleBundle\Model\Address\AddressInterface;

class AddressSolver
{

// getAddressSummary
public function getSummaryShort()
public function getSummaryShort(AddressInterface $address): string
{
return $this->getAddress() . ' - ' . $this->getZip() . ' ' . $this->getCity();
return $address->getAddress() . ' - ' . $address->getZip() . ' ' . $address->getCity();
}

public function getSummary($withTitle = true)
public function getSummary(AddressInterface $address, $withTitle = true): string
{
$html = '';

if ($this->getTitle() && $withTitle) {
$html .= $this->getTitle() . '<br />';
if ($address->getTitle() && $withTitle) {
$html .= $address->getTitle() . '<br />';
}

if ($this->getLastname() || $this->getFirstname()) {
$html .= $this->getLastname() . ' ' . $this->getFirstname() . '<br />';
if ($address->getLastname() || $address->getFirstname()) {
$html .= $address->getLastname() . ' ' . $address->getFirstname() . '<br />';
}

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

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

if ($this->getPhone()) {
foreach ($this->getPhone() as $phone) {
if ($address->getPhone()) {
foreach ($address->getPhone() as $phone) {
$html .= 'Tél. ' . $phone . '<br />';
}
}
@@ -40,23 +41,21 @@ class AddressSolver
return $html;
}


public function getLongitudeInherit()
public function getLongitudeInherit(AddressInterface $address): ?string
{
if ($this->getLongitudeOverride()) {
return $this->getLongitudeOverride();
if ($address->getLongitudeOverride()) {
return $address->getLongitudeOverride();
} else {
return $this->getLongitude();
return $address->getLongitude();
}
}


public function getLatitudeInherit()
public function getLatitudeInherit(AddressInterface $address): ?string
{
if ($this->getLatitudeOverride()) {
return $this->getLatitudeOverride();
if ($address->getLatitudeOverride()) {
return $address->getLatitudeOverride();
} else {
return $this->getLatitude();
return $address->getLatitude();
}
}


+ 2
- 2
Solver/Order/OrderProductReductionCatalogSolver.php View File

@@ -7,7 +7,7 @@ use Lc\CaracoleBundle\Model\Order\OrderProductReductionCatalogInterface;
class OrderProductReductionCatalogSolver
{
// getSummaryOrderProductReductionCatalog
public function getSummary(OrderProductReductionCatalogInterface $orderProductReductionCatalog)
public function getSummary(OrderProductReductionCatalogInterface $orderProductReductionCatalog): string
{
$text = '';

@@ -26,7 +26,7 @@ class OrderProductReductionCatalogSolver
public function compare(
OrderProductReductionCatalogInterface $orderProductReductionCatalog,
OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare
) {
): bool {
return $orderProductReductionCatalogCompare
&& $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit()
&& (string)$orderProductReductionCatalog->getValue(

+ 8
- 4
Solver/Order/OrderShopSolver.php View File

@@ -103,9 +103,11 @@ class OrderShopSolver
public function getTotalOrderPayments(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): float
{
$totalAmount = floatval(0);

foreach ($orderShop->getOrderPayments() as $orderPayment) {
$totalAmount = $orderPayment->getAmount() + $totalAmount;
}

if ($mergeComplementaryOrderShop) {
foreach ($orderShop->getComplementaryOrderShops() as $complementaryOrderShop) {
foreach ($complementaryOrderShop->getOrderPayments() as $orderPayment) {
@@ -125,6 +127,7 @@ class OrderShopSolver
public function getOrderStatusHistory(OrderShopInterface $orderShop, OrderStatusInterface $status)
{
$orderStatusHistories = $orderShop->getOrderStatusHistories();

if (count($orderStatusHistories) > 0) {
foreach ($orderStatusHistories as $orderStatusHistory) {
if ($orderStatusHistory->getOrderStatus() === $status) {
@@ -159,12 +162,13 @@ class OrderShopSolver

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


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

if ($orderShop->getComplementaryOrderShops()) {

+ 2
- 4
Transformer/Order/OrderShopTransformer.php View File

@@ -12,13 +12,11 @@ class OrderShopTransformer
{
protected PriceSolver $priceSolver;
protected OrderShopSolver $orderShopSolver;
protected ReductionResolver $reductionResolver;

public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver, ReductionResolver $reductionResolver)
public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver)
{
$this->priceSolver = $priceSolver;
$this->orderShopSolver = $orderShopSolver;
$this->reductionResolver = $reductionResolver;
}

// getOrderDatas

+ 15
- 15
Twig/StoreTwigExtension.php View File

@@ -5,10 +5,12 @@ namespace Lc\CaracoleBundle\Twig;
use Lc\CaracoleBundle\Repository\Config\TaxRateStore;
use Lc\CaracoleBundle\Repository\Config\UnitStore;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\Reminder\ReminderStore;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryQuery;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\ShopBundle\Context\UnitInterface;
@@ -17,8 +19,8 @@ use Twig\TwigFunction;

class StoreTwigExtension extends AbstractExtension
{
protected MerchantRepositoryQuery $merchantRepositoryQuery;
protected SectionRepositoryQuery $sectionRepositoryQuery;
protected MerchantStore $merchantStore;
protected SectionStore $sectionStore;
protected ReminderStore $reminderStore;
protected MerchantResolver $merchantResolver;
protected SectionResolver $sectionResolver;
@@ -28,16 +30,16 @@ class StoreTwigExtension extends AbstractExtension
public function __construct(
MerchantResolver $merchantResolver,
SectionResolver $sectionResolver,
MerchantRepositoryQuery $merchantRepositoryQuery,
SectionRepositoryQuery $sectionRepositoryQuery,
MerchantStore $merchantStore,
SectionStore $sectionStore,
ReminderStore $reminderStore,
UnitStore $unitStore,
TaxRateStore $taxRateStore
) {
$this->merchantResolver = $merchantResolver;
$this->sectionResolver = $sectionResolver;
$this->merchantRepositoryQuery = $merchantRepositoryQuery;
$this->sectionRepositoryQuery = $sectionRepositoryQuery;
$this->merchantStore = $merchantStore;
$this->sectionStore = $sectionStore;
$this->reminderStore = $reminderStore;
$this->unitStore = $unitStore;
$this->taxRateStore = $taxRateStore;
@@ -56,14 +58,12 @@ class StoreTwigExtension extends AbstractExtension

public function getSections()
{
return $this->sectionRepositoryQuery
->filterByMerchant($this->merchantResolver->getCurrent())
->find();
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOnline();
}

public function getMerchants()
{
return $this->merchantRepositoryQuery->find();
return $this->merchantStore->getOnline();
}

public function getReminders($params = [])
@@ -74,14 +74,14 @@ class StoreTwigExtension extends AbstractExtension
->get($params);
}

public function getUnits(){
public function getUnits()
{
return $this->unitStore->getAsArray();
}

public function getTaxRates(){
return $this->taxRateStore->getAsArray();
public function getTaxRates()
{
return $this->taxRateStore->setMerchant($this->merchantResolver->getCurrent())->getAsArray();
}

}

+ 0
- 33
Twig/TwigExtension.php View File

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

namespace Lc\CaracoleBundle\Twig;

use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantButtonAdminFormType;
use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
use Lc\CaracoleBundle\Form\Section\SwitchSectionFormType;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class TwigExtension extends AbstractExtension
{

public function __construct() {

}

public function getFilters()
{
return [];
}

public function getFunctions()
{
return [];
}

}

Loading…
Cancel
Save