ソースを参照

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Charly 3年前
コミット
01aabdbf15
7個のファイルの変更94行の追加11行の削除
  1. +1
    -1
      Controller/User/UserAdminController.php
  2. +32
    -6
      Generator/OrderReferenceGenerator.php
  3. +20
    -0
      Repository/Order/OrderProductRepositoryQuery.php
  4. +28
    -1
      Repository/Product/ProductRepositoryQuery.php
  5. +6
    -3
      Repository/Product/ProductStore.php
  6. +1
    -0
      Repository/Ticket/TicketStore.php
  7. +6
    -0
      Twig/StoreTwigExtension.php

+ 1
- 1
Controller/User/UserAdminController.php ファイルの表示

@@ -31,7 +31,7 @@ abstract class UserAdminController extends SovUserAdminController
foreach ($entity->getActions() as $action){
if($action->getName() == ActionDefinition::SWITCH_USER){
$sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault();
dump($sectionDefault);
$url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault->getSlug()));
$action->setLinkUrl($url);
}

+ 32
- 6
Generator/OrderReferenceGenerator.php ファイルの表示

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

namespace Lc\CaracoleBundle\Generator;

use App\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Definition\SectionSettingDefinition;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Section\SectionModel;
@@ -10,26 +11,51 @@ use Lc\SovBundle\Solver\Setting\SettingSolver;
class OrderReferenceGenerator
{
protected SettingSolver $settingSolver;
protected OrderShopSolver $orderShopSolver;

public function __construct(SettingSolver $settingSolver)
public function __construct(SettingSolver $settingSolver, OrderShopSolver $orderShopSolver)
{
$this->settingSolver = $settingSolver;
$this->orderShopSolver= $orderShopSolver;
}

public function buildReference(OrderShopInterface $orderShop): string
{
$complementaryIndex = null;

if ($orderShop->getMainOrderShop()) {
$complementaryIndex = 0;
foreach ($orderShop->getMainOrderShop()->getComplementaryOrderShops() as $complementaryOrder) {
if ($this->orderShopSolver->isValid($complementaryOrder)) $complementaryIndex++;
}
$orderShop = $complementaryOrder->getMainOrderShop();

}

switch ($orderShop->getSection()->getCycleType()) {
case SectionModel::CYCLE_TYPE_DAY:
return $this->buildReferenceCycleDay($orderShop);
$reference = $this->buildReferenceCycleDay($orderShop);
break;
case SectionModel::CYCLE_TYPE_WEEK:
return $this->buildReferenceCycleWeek($orderShop);
$reference = $this->buildReferenceCycleWeek($orderShop,);
break;
case SectionModel::CYCLE_TYPE_MONTH:
return $this->buildReferenceCycleMonth($orderShop);
$reference = $this->buildReferenceCycleMonth($orderShop);
break;
case SectionModel::CYCLE_TYPE_YEAR:
return $this->buildReferenceCycleYear($orderShop);
$reference = $this->buildReferenceCycleYear($orderShop);
break;
default:
$reference = 'C' . $orderShop->getId();
break;
}

return 'C' . $orderShop->getId();
if($complementaryIndex){
$reference = $reference.'C'.$this->numberPad($complementaryIndex, 1);
}

return $reference;

}

public function buildReferenceCycleDay(OrderShopInterface $orderShop): string

+ 20
- 0
Repository/Order/OrderProductRepositoryQuery.php ファイルの表示

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

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
@@ -14,6 +15,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
{

protected bool $isJoinProduct = false;
protected bool $isJoinSection = false;
protected bool $isJoinProductFamily = false;
protected bool $isJoinOrderShop = false;
protected bool $isJoinOrderStatus = false;
@@ -103,6 +105,17 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
return $this;
}

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

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

public function joinOrderStatus(): self
{
$this->joinOrderShop();
@@ -114,4 +127,11 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
}
return $this;
}

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

+ 28
- 1
Repository/Product/ProductRepositoryQuery.php ファイルの表示

@@ -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\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
@@ -12,6 +13,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;
class ProductRepositoryQuery extends AbstractRepositoryQuery
{
protected bool $isJoinProductFamily =false;
protected bool $isJoinSections =false;
protected bool $isJoinProductFamilySectionProperties =false;

public function __construct(ProductRepository $repository, PaginatorInterface $paginator)
@@ -43,6 +45,29 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery

return $this;
}


public function filterByMerchantViaSection(MerchantInterface $merchant)
{
$this->joinProductFamilySectionProperties(false);
$this->joinSections(false);
$this->andWhereMerchant('section', $merchant);
$this->andWhere('productFamilySectionProperties.status = 1');
}

public function joinSections(bool $addSelect = true): self
{
if (!$this->isJoinSections) {
$this->isJoinSections = true;

$this->leftJoin('productFamilySectionProperties.section', 'section');
if ($addSelect) {
$this->addSelect('section');
}
}
return $this;
}

public function joinProductFamilySectionProperties(bool $addSelect = true): self
{
$this->joinProductFamily();
@@ -52,7 +77,9 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery

$this->leftJoin('productFamily.productFamilySectionProperties', 'productFamilySectionProperties');
if ($addSelect) {
$this->addSelect('productFamilySectionProperties');
//NB : Ici le select est en commentaire car si il est actif doctrine n'hydrate pas correectement ProductFamilySectionProperties (si filtre sur section les ProductFamilySectionProperties des autres sections ne sont pas chargé et ça peut être problématique pr la gestion des stocks)

//$this->addSelect('productFamilySectionProperties');
}
}
return $this;

+ 6
- 3
Repository/Product/ProductStore.php ファイルの表示

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

use App\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
@@ -10,6 +11,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;
class ProductStore extends AbstractStore
{
use SectionStoreTrait;
use MerchantStoreTrait;

protected ProductRepositoryQuery $query;
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;
@@ -28,6 +30,7 @@ class ProductStore extends AbstractStore
public function filtersDefault($query):RepositoryQueryInterface
{
$this->addFilterBySectionOptionnal($query);
$this->addFilterByMerchantViaSectionOptionnal($query);
$query->filterIsOnlineAndOffline();

return $query;
@@ -41,8 +44,8 @@ class ProductStore extends AbstractStore
//findProductByAvailabilitiesNegative
public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array
{
$query = $this->createQuery($query);
$query->joinProductFamily();
$query = $this->createDefaultQuery($query);
$query->filterIsOnline();
$query->filterAvailableQuantityNegative();
$query->groupBy('productFamily.id');
@@ -58,7 +61,7 @@ class ProductStore extends AbstractStore

public function getByAvailabilitiesSupplierNegative(ProductRepositoryQuery $query = null): array
{
$query = $this->createQuery($query);
$query = $this->createDefaultQuery($query);
$query->joinProductFamily();
$query->filterIsOnline();
$query->filterAvailableQuantitySupplierNegative();

+ 1
- 0
Repository/Ticket/TicketStore.php ファイルの表示

@@ -17,6 +17,7 @@ class TicketStore extends SovTicketStore
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$this->addFilterBySectionOptionnal($query);
$this->addFilterByMerchantOptionnal($query);
return $query;
}


+ 6
- 0
Twig/StoreTwigExtension.php ファイルの表示

@@ -86,6 +86,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_default', [$this, 'getSectionDefault']),
new TwigFunction('section_current_default', [$this, 'getSectionCurrentDefault']),
new TwigFunction('section_current_visited', [$this, 'getSectionCurrentVisited']),
new TwigFunction('is_out_of_sections', [$this, 'isOutOfSections']),
@@ -129,6 +130,11 @@ class StoreTwigExtension extends AbstractExtension
return $this->sectionResolver->getCurrent();
}

public function getSectionDefault(): ?SectionInterface
{
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOneDefault();
}

public function getSectionCurrentDefault(): ?SectionInterface
{
return $this->sectionResolver->getCurrent(true);

読み込み中…
キャンセル
保存