Sfoglia il codice sorgente

Intégration app order

packProduct
Fabien Normand 3 anni fa
parent
commit
ae3e930e62
24 ha cambiato i file con 229 aggiunte e 92 eliminazioni
  1. +8
    -4
      Builder/File/DocumentBuilder.php
  2. +18
    -4
      Builder/Order/OrderShopBuilder.php
  3. +9
    -0
      Container/Order/OrderProductContainer.php
  4. +11
    -10
      Controller/Credit/CreditHistoryAdminController.php
  5. +1
    -1
      Form/Order/OrderProductsType.php
  6. +1
    -3
      Model/Order/OrderShopModel.php
  7. +5
    -0
      Repository/File/DocumentRepositoryQuery.php
  8. +19
    -3
      Repository/File/DocumentStore.php
  9. +47
    -0
      Repository/MerchantStoreTrait.php
  10. +0
    -19
      Repository/Order/OrderShopRepositoryQuery.php
  11. +5
    -9
      Repository/Order/OrderShopStore.php
  12. +1
    -0
      Repository/Product/ProductFamilyRepositoryQuery.php
  13. +10
    -1
      Repository/Product/ProductFamilyStore.php
  14. +7
    -0
      Repository/Reduction/ReductionCreditRepositoryQuery.php
  15. +10
    -2
      Repository/Reduction/ReductionCreditStore.php
  16. +21
    -0
      Repository/SectionRepositoryQueryTrait.php
  17. +27
    -0
      Repository/SectionStoreTrait.php
  18. +4
    -3
      Resolver/MerchantResolver.php
  19. +5
    -19
      Resolver/SectionResolver.php
  20. +1
    -2
      Solver/Order/OrderProductReductionCatalogSolver.php
  21. +1
    -1
      Solver/Order/OrderShopSolver.php
  22. +12
    -1
      Solver/Product/ProductFamilySolver.php
  23. +0
    -10
      Solver/Product/ProductSolver.php
  24. +6
    -0
      Twig/StoreTwigExtension.php

+ 8
- 4
Builder/File/DocumentBuilder.php Vedi File

@@ -6,14 +6,17 @@ use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator;
use Lc\CaracoleBundle\Solver\Address\AddressSolver;

class DocumentBuilder
{
protected DocumentReferenceGenerator $documentReferenceGenerator;
protected AddressSolver $addressSolver;

public function __construct(DocumentReferenceGenerator $documentReferenceGenerator)
public function __construct(DocumentReferenceGenerator $documentReferenceGenerator, AddressSolver $addressSolver)
{
$this->documentReferenceGenerator = $documentReferenceGenerator;
$this->addressSolver = $addressSolver;
}

public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop) :DocumentInterface
@@ -21,11 +24,12 @@ class DocumentBuilder
$merchantAddress = $orderShop->getSection()->getMerchant()->getAddress();
$buyerAddress = $orderShop->getInvoiceAddress();
//TODO a discuter, doit on garder le lien avec merchant pr la référence ou le mettre par section ? Est-ce que le nom de cette fonction est approprié. on fait une invoice et ça s'appele initFromOrderShop
$document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getSection()->getMerchant(), DocumentModel::TYPE_INVOICE)) ;
$document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getSection()->getMerchant(), $document->getType())) ;

$document->setMerchantAddress($merchantAddress);
$document->setBuyerAddress($buyerAddress);
$document->setMerchantAddressText($merchantAddress->getSummary());
$document->setBuyerAddressText($buyerAddress->getSummary());
$document->setMerchantAddressText($this->addressSolver->getSummary($merchantAddress));
$document->setBuyerAddressText($this->addressSolver->getSummary($buyerAddress));
$document->addOrderShop($orderShop);
$document->setCreatedBy($orderShop->getUser());


+ 18
- 4
Builder/Order/OrderShopBuilder.php Vedi File

@@ -35,6 +35,7 @@ use Lc\CaracoleBundle\Repository\Order\OrderStatusStore;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Resolver\OpeningResolver;
use Lc\CaracoleBundle\Resolver\OrderShopResolver;
use Lc\CaracoleBundle\Solver\Order\OrderProductReductionCatalogSolver;
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Product\ProductSolver;
@@ -59,6 +60,7 @@ class OrderShopBuilder
protected OpeningResolver $openingResolver;
protected ProductSolver $productSolver;
protected OrderShopResolver $orderShopResolver;
protected OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver;

public function __construct(
EntityManagerInterface $entityManager,
@@ -74,7 +76,8 @@ class OrderShopBuilder
FlashBagInterface $flashBag,
OpeningResolver $openingResolver,
ProductSolver $productSolver,
OrderShopResolver $orderShopResolver
OrderShopResolver $orderShopResolver,
OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver
) {
$this->entityManager = $entityManager;
$this->orderShopStore = $orderShopStore;
@@ -90,6 +93,7 @@ class OrderShopBuilder
$this->openingResolver = $openingResolver;
$this->productSolver = $productSolver;
$this->orderShopResolver = $orderShopResolver;
$this->orderProductReductionCatalogSolver = $orderProductReductionCatalogSolver;
}

public function create(
@@ -202,7 +206,10 @@ class OrderShopBuilder
&& $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery()
&& (string)$this->priceSolver->getPrice($orderProduct)
== (string)$this->priceSolver->getPrice($orderProductAdd)
&& $orderProduct->getOrderProductReductionCatalog()->compare(
&& $orderProduct->getOrderProductReductionCatalog()
&& $orderProductAdd->getOrderProductReductionCatalog()
&& $this->orderProductReductionCatalogSolver->compare(
$orderProduct->getOrderProductReductionCatalog(),
$orderProductAdd->getOrderProductReductionCatalog()
)) {
$orderProduct->setQuantityOrder(
@@ -372,7 +379,9 @@ class OrderShopBuilder
public function createDocumentInvoice(OrderShopInterface $orderShop): DocumentInterface
{
$documentFactory = new DocumentFactory();
$document = $documentFactory->create($orderShop->getSection(),DocumentModel::TYPE_INVOICE);

$document = $documentFactory->create($orderShop->getSection(), DocumentModel::TYPE_INVOICE);

$this->documentBuilder->initFromOrderShop($document, $orderShop);
return $document;
}
@@ -586,7 +595,12 @@ class OrderShopBuilder

public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2)
{
$productsSalesStatistic = new ProductsSalesStatistic($this->entityManager, $entity, $nbWeek, $this->productSolver);
$productsSalesStatistic = new ProductsSalesStatistic(
$this->entityManager,
$entity,
$nbWeek,
$this->productSolver
);

$productsSalesStatistic->init($section, $this->orderShopSolver, $this->openingResolver);
$productsSalesStatistic->populateProperties($this->orderShopStore);

+ 9
- 0
Container/Order/OrderProductContainer.php Vedi File

@@ -6,21 +6,25 @@ use Lc\CaracoleBundle\Builder\Order\OrderProductBuilder;
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory;
use Lc\CaracoleBundle\Repository\Order\OrderProductRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
use Lc\CaracoleBundle\Solver\Order\OrderProductSolver;

class OrderProductContainer
{
protected OrderProductFactory $factory;
protected OrderProductSolver $solver;
protected OrderProductBuilder $builder;
protected OrderProductRepositoryQuery $repositoryQuery;
protected OrderProductStore $store;

public function __construct(
OrderProductFactory $factory,
OrderProductSolver $solver,
OrderProductBuilder $builder,
OrderProductRepositoryQuery $repositoryQuery,
OrderProductStore $store
) {
$this->factory = $factory;
$this->solver = $solver;
$this->builder = $builder;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
@@ -31,6 +35,11 @@ class OrderProductContainer
return $this->factory;
}

public function getSolver(): OrderProductSolver
{
return $this->solver;
}

public function getBuilder(): OrderProductBuilder
{
return $this->builder;

+ 11
- 10
Controller/Credit/CreditHistoryAdminController.php Vedi File

@@ -25,6 +25,7 @@ use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel;
use Lc\CaracoleBundle\Model\Order\OrderPaymentModel;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Translation\TranslatorAdmin;
@@ -111,29 +112,29 @@ abstract class CreditHistoryAdminController extends AbstractAdminController
ChoiceField::new('meanPayment')->setChoices(
array(
$translatorAdmin->transField(
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CASH,
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_CASH,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_CASH,
) => OrderPaymentModel::MEAN_PAYMENT_CASH,

$translatorAdmin->transField(
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CHEQUE,
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_CHEQUE,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_CHEQUE,
) => OrderPaymentModel::MEAN_PAYMENT_CHEQUE,

$translatorAdmin->transField(
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CREDIT,
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_CREDIT,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT,
) => OrderPaymentModel::MEAN_PAYMENT_CREDIT,

$translatorAdmin->transField(
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD,
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_CREDIT_CARD,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD,
) => OrderPaymentModel::MEAN_PAYMENT_CREDIT_CARD,

$translatorAdmin->transField(
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_TRANSFER,
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_TRANSFER,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_TRANSFER,
) => OrderPaymentModel::MEAN_PAYMENT_TRANSFER,
)
),
TextField::new('reference'),

+ 1
- 1
Form/Order/OrderProductsType.php Vedi File

@@ -55,7 +55,7 @@ class OrderProductsType extends AbstractType
} else {
$product = null;
if ($productFamily->getActiveProducts()) {
$products = $productFamily->getProductsOnline();
$products = $this->productFamilySolver->getProductsOnline($productFamily);
if ($products && count($products) > 0) {
$product = $products[0];
}

+ 1
- 3
Model/Order/OrderShopModel.php Vedi File

@@ -22,8 +22,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
const DELIVERY_TYPE_HOME = 'home';
const DELIVERY_TYPE_POINTSALE = 'point-sale';



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

/**
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\File\DocumentInterface", inversedBy="orderShops")
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\File\DocumentInterface", inversedBy="orderShops", cascade={"persist"})
*/
protected $documents;


+ 5
- 0
Repository/File/DocumentRepositoryQuery.php Vedi File

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

public function filterByType($type)
{
return $this->andWhereEqual('type', $type);
}

public function filterByBuyerAddress(AddressInterface $buyerAddress)
{
return $this

+ 19
- 3
Repository/File/DocumentStore.php Vedi File

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

use App\Entity\Address\Address;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractStore;
@@ -11,6 +12,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;
class DocumentStore extends AbstractStore
{
use SectionStoreTrait;
use MerchantStoreTrait;

protected DocumentRepositoryQuery $query;

@@ -28,7 +30,15 @@ class DocumentStore extends AbstractStore
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterIsOnlineAndOffline();
$query->filterBySection($this->section);

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

if(isset($this->merchant) && $this->merchant) {
$query->filterByMerchantViaSection($this->merchant);
}

return $query;
}

@@ -38,9 +48,15 @@ class DocumentStore extends AbstractStore
}


public function getOneLatestByType(string $documentType, $query = null)
public function getOneLatestByType(string $documentType, $query = null): DocumentInterface
{
// @TODO : à écrire
$query = $this->createDefaultQuery($query);

$query
->filterByType($documentType)
->orderBy('createdAt', 'DESC');

return $query->findOne();
}

// findLastInvoice

+ 47
- 0
Repository/MerchantStoreTrait.php Vedi File

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

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

trait MerchantStoreTrait
{
@@ -14,4 +16,49 @@ trait MerchantStoreTrait

return $this;
}

public function isMerchantDefined(): bool
{
return isset($this->merchant) && $this->merchant;
}

public function addFilterByMerchantOptionnal(RepositoryQueryInterface $query): StoreInterface
{
if($this->isMerchantDefined()) {
$query->filterByMerchant($this->merchant);
}

return $this;
}

public function addFilterByMerchantRequired(RepositoryQueryInterface $query): StoreInterface
{
$this->addFilterByMerchantOptionnal($query);

if(!$this->isMerchantDefined()) {
throw new \ErrorException('Le Merchant doit être définie dans '.get_class($this));
}

return $this;
}

public function addFilterByMerchantViaSectionOptionnal(RepositoryQueryInterface $query): StoreInterface
{
if($this->isMerchantDefined()) {
$query->filterByMerchantViaSection($this->merchant);
}

return $this;
}

public function addFilterByMerchantViaSectionRequired(RepositoryQueryInterface $query): StoreInterface
{
$this->addFilterByMerchantOptionnal($query);

if(!$this->isMerchantDefined()) {
throw new \ErrorException('Le Merchant doit être définie dans '.get_class($this));
}

return $this;
}
}

+ 0
- 19
Repository/Order/OrderShopRepositoryQuery.php Vedi File

@@ -28,7 +28,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
protected bool $isJoinOrderReductionCarts = false;
protected bool $isJoinOrderStatus = false;
protected bool $isJoinMerchant = false;
protected bool $isJoinSection = false;
protected bool $isJoinComplementaryOrderShops = false;
protected bool $isJoinDeliveryPointSale = false;

@@ -50,13 +49,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->select('count(r.id) as total');
}

public function filterByMerchant(MerchantInterface $merchant)
{
$this->joinMerchant();
return $this->andWhere('s.merchant = :merchant')
->setParameter('merchant', $merchant);
}

public function filterByUser(UserInterface $user): self
{
return $this
@@ -209,17 +201,6 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

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

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

public function joinComplementaryOrderShops(): self
{
if (!$this->isJoinComplementaryOrderShops) {

+ 5
- 9
Repository/Order/OrderShopStore.php Vedi File

@@ -88,13 +88,9 @@ class OrderShopStore extends AbstractStore

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

if(isset($this->merchant) && $this->merchant) {
$query->filterByMerchant($this->merchant);
}
$this
->addFilterBySectionOptionnal($query)
->addFilterByMerchantViaSectionOptionnal($query);

return $query;
}
@@ -391,7 +387,7 @@ class OrderShopStore extends AbstractStore
}

if (isset($params['orderStatus'])) {
$query->filterByStatus($params['orderStatus']);
$query->filterByStatus([$params['orderStatus']]);
}

if (isset($params['user'])) {
@@ -452,7 +448,7 @@ class OrderShopStore extends AbstractStore
$reductionCreditsArray = [];
foreach ($reductionCredits as $reductionCredit) {
if (!$this->countValidWithReductionCredit($reductionCredit, $user)
&& (!$this->merchant || $reductionCredit->getSection()->getMerchant() == $this->merchant)) {
&& ($reductionCredit->getSection()->getMerchant() == $this->merchant)) {
$reductionCreditsArray[] = $reductionCredit;
}
}

+ 1
- 0
Repository/Product/ProductFamilyRepositoryQuery.php Vedi File

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

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

+ 10
- 1
Repository/Product/ProductFamilyStore.php Vedi File

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Repository\Product;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Model\User\UserInterface;
@@ -14,6 +15,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;
class ProductFamilyStore extends AbstractStore
{
use SectionStoreTrait;
use MerchantStoreTrait;

protected ProductFamilyRepositoryQuery $query;
protected PriceSolver $priceSolver;
@@ -32,7 +34,14 @@ class ProductFamilyStore extends AbstractStore

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

if(isset($this->merchant) && $this->merchant) {
$query->filterByMerchantViaSection($this->merchant);
}

return $query;
}


+ 7
- 0
Repository/Reduction/ReductionCreditRepositoryQuery.php Vedi File

@@ -25,6 +25,13 @@ class ReductionCreditRepositoryQuery extends AbstractRepositoryQuery
->setParameter('user', $user);
}

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

public function filterByType(string $type = ReductionCreditModel::TYPE_CREDIT)
{
return $this

+ 10
- 2
Repository/Reduction/ReductionCreditStore.php Vedi File

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Repository\Reduction;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\User\UserInterface;
@@ -14,6 +15,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;
class ReductionCreditStore extends AbstractStore
{
use SectionStoreTrait;
use MerchantStoreTrait;

protected ReductionCreditRepositoryQuery $query;

@@ -34,7 +36,13 @@ class ReductionCreditStore extends AbstractStore
if($this->section) {
$query->filterBySection($this->section);
}

if(isset($this->merchant) && $this->merchant) {
$query->filterByMerchantViaSection($this->merchant);
}

$query->filterIsOnlineAndOffline();

return $query;
}

@@ -69,7 +77,7 @@ class ReductionCreditStore extends AbstractStore
{
/// @TODO : à écrire
$query = $this->createDefaultQuery($query);
$query->filterByUser($user);
$query->filterByOwner($user);
return $query->find();
}

@@ -78,7 +86,7 @@ class ReductionCreditStore extends AbstractStore
{
/// @TODO : à écrire
$query = $this->createDefaultQuery($query);
$query->filterByUser($user);
$query->filterByOwner($user);
return $query->find();
}


+ 21
- 0
Repository/SectionRepositoryQueryTrait.php Vedi File

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

namespace Lc\CaracoleBundle\Repository;

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

trait SectionRepositoryQueryTrait
{
protected bool $isJoinSection = false;

public function filterBySection(SectionInterface $section)
{
return $this->andWhereSection($this->id, $section);
}

public function filterByMerchantViaSection(MerchantInterface $merchant)
{
$this->joinSection();
return $this->andWhere('s.merchant = :merchant')
->setParameter('merchant', $merchant);
}

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

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

+ 27
- 0
Repository/SectionStoreTrait.php Vedi File

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

use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Repository\StoreInterface;

trait SectionStoreTrait
{
@@ -15,6 +17,31 @@ trait SectionStoreTrait
return $this;
}

public function isSectionDefined(): bool
{
return isset($this->section) && $this->section;
}

public function addFilterBySectionOptionnal(RepositoryQueryInterface $query): StoreInterface
{
if($this->isSectionDefined()) {
$query->filterBySection($this->section);
}

return $this;
}

public function addFilterBySectionRequired(RepositoryQueryInterface $query): StoreInterface
{
$this->addFilterBySectionOptionnal($query);

if(!$this->isSectionDefined()) {
throw new \ErrorException('La Section doit être définie dans '.get_class($this));
}

return $this;
}

public function getParents()
{
$query = $this->query->create();

+ 4
- 3
Resolver/MerchantResolver.php Vedi File

@@ -10,6 +10,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinitionInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
@@ -119,12 +120,12 @@ class MerchantResolver
);
}

public function getUrl($merchant)
public function getUrl(SectionInterface $section)
{
if ($this->urlResolver->isServerLocalhost()) {
return $this->router->generate('frontend_home', [], UrlGeneratorInterface::ABSOLUTE_URL);
return $this->router->generate('frontend_home', ['section' => $section->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
} else {
return $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL);
return $section->getMerchant()->getSettingValue(MerchantSettingDefinition::SETTING_URL);
}
}


+ 5
- 19
Resolver/SectionResolver.php Vedi File

@@ -61,29 +61,15 @@ class SectionResolver
return $currentAdminSection;
} // front
else {
$sectionStore = $this->sectionStore->setMerchant($this->merchantResolver->getCurrent());
$sectionCurrent = null;
$isCli = php_sapi_name() === 'cli';
$sectionDefault = $sectionStore->getOneDefault();

// local
if ($isCli || $this->urlResolver->isServerLocalhost()) {
$sectionArray = $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent())
->getOnline();

foreach ($sectionArray as $section) {
if ($section->getDevAlias() == $_ENV['CURRENT_SECTION_LOCAL']) {
$sectionCurrent = $section;
}
}
}
// distant
else {
$sectionCurrent = $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent())
->getOneDefault();
if(isset($requestAttributesArray['section'])) {
$sectionCurrent = $sectionStore->getOneBySlug($requestAttributesArray['section']);
}

return $sectionCurrent;
return $sectionCurrent ?: $sectionDefault;
}
}


+ 1
- 2
Solver/Order/OrderProductReductionCatalogSolver.php Vedi File

@@ -27,8 +27,7 @@ class OrderProductReductionCatalogSolver
OrderProductReductionCatalogInterface $orderProductReductionCatalog,
OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare
): bool {
return $orderProductReductionCatalogCompare
&& $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit()
return $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit()
&& (string)$orderProductReductionCatalog->getValue(
) == (string)$orderProductReductionCatalogCompare->getValue()
&& $orderProductReductionCatalog->getBehaviorTaxRate(

+ 1
- 1
Solver/Order/OrderShopSolver.php Vedi File

@@ -342,7 +342,7 @@ class OrderShopSolver
}

// getProductQuantityMaxAddCart
public function getProductQuantityMaxAddCart(ProductInterface $product, OrderShopInterface $orderShop)
public function getProductQuantityMaxAddCart(OrderShopInterface $orderShop, ProductInterface $product)
{
$productFamily = $product->getProductFamily();


+ 12
- 1
Solver/Product/ProductFamilySolver.php Vedi File

@@ -174,7 +174,7 @@ class ProductFamilySolver

foreach ($products as $product) {
if ($product->getStatus() == 1) {
$titleProduct = $product->getTitleInherited();
$titleProduct = $this->productSolver->getTitleInherited($product);
if (!isset($arrayProductsGroupByTitle[$titleProduct])) {
$arrayProductsGroupByTitle[$titleProduct] = [];
}
@@ -185,6 +185,17 @@ class ProductFamilySolver
return $arrayProductsGroupByTitle;
}

public function getQuantityTitle(ProductFamilyInterface $productFamily, ProductInterface $product)
{
$title = $this->productSolver->getQuantityLabelInherited($product);

if ($this->hasProductsWithVariousWeight($productFamily)) {
$title .= ', ' . $this->productSolver->getTitleInherited($product);
}

return $title;
}

public function getOriginProduct(ProductFamilyInterface $productFamily): ?ProductInterface
{
$products = $productFamily->getProducts();

+ 0
- 10
Solver/Product/ProductSolver.php Vedi File

@@ -142,16 +142,6 @@ class ProductSolver
return $quantity . $unit->getWordingShort();
}

// @TODO : si besoin, à remettre en place
/*public function getQuantityTitle(ProductInterface $product, ProductFamilyInterface $productFamily)
{
$title = $product->getQuantityLabelInherited();
if ($this->productFamilySolver->hasProductsWithVariousWeight($productFamily)) {
$title .= ', ' . $product->getTitleInherited();
}
return $title;
}*/

public function getAvailableQuantityInherited(ProductInterface $product)
{
switch ($product->getProductFamily()->getBehaviorCountStock()) {

+ 6
- 0
Twig/StoreTwigExtension.php Vedi File

@@ -85,6 +85,7 @@ class StoreTwigExtension extends AbstractExtension
new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']),
new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']),
new TwigFunction('section_current', [$this, 'getSectionCurrent']),
new TwigFunction('section_slug_current', [$this, 'getSectionSlugCurrent']),
new TwigFunction('merchant_setting', [$this, 'getMerchantSetting']),
new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']),
new TwigFunction('section_setting', [$this, 'getSectionSetting']),
@@ -109,6 +110,11 @@ class StoreTwigExtension extends AbstractExtension
return $this->sectionResolver->getCurrent();
}

public function getSectionSlugCurrent(): string
{
return $this->sectionResolver->getCurrent()->getSlug();
}

public function getCartCurrent(): OrderShopInterface
{
return $this->orderShopBuilder->createIfNotExist(

Loading…
Annulla
Salva