<?php | |||||
namespace Lc\CaracoleBundle\Builder\Address; | |||||
use App\Entity\Address\Address; | |||||
use App\Repository\Order\OrderShopStore; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Repository\File\DocumentStore; | |||||
class AddressBuilder | |||||
{ | |||||
protected EntityManagerInterface $entityManager; | |||||
protected OrderShopStore $orderShopStore; | |||||
protected DocumentStore $documentStore; | |||||
public function __construct( | |||||
EntityManagerInterface $entityManager, | |||||
OrderShopStore $orderShopStore, | |||||
DocumentStore $documentStore | |||||
) { | |||||
$this->entityManager = $entityManager; | |||||
$this->orderShopStore = $orderShopStore; | |||||
$this->documentStore = $documentStore; | |||||
} | |||||
// unlinkAddress | |||||
public function unlink(Address $address): void | |||||
{ | |||||
$orderShops = $this->orderShopStore->getBy( | |||||
[ | |||||
'address' => $address | |||||
] | |||||
); | |||||
if ($orderShops) { | |||||
foreach ($orderShops as $orderShop) { | |||||
$update = false; | |||||
if ($orderShop->getInvoiceAddress() == $address) { | |||||
$orderShop->setInvoiceAddress(null); | |||||
$update = true; | |||||
} | |||||
if ($orderShop->getDeliveryAddress() == $address) { | |||||
$orderShop->setDeliveryAddress(null); | |||||
$update = true; | |||||
} | |||||
if ($update) { | |||||
$this->entityManager->update($orderShop); | |||||
} | |||||
} | |||||
} | |||||
$documents = $this->documentStore->getByBuyerAddress($address); | |||||
if ($documents) { | |||||
foreach ($documents as $document) { | |||||
$update = false; | |||||
if ($document->getBuyerAddress() == $address) { | |||||
$document->setBuyerAddress(null); | |||||
$update = true; | |||||
} | |||||
if ($update) { | |||||
$this->entityManager->update($document); | |||||
} | |||||
} | |||||
} | |||||
$this->entityManager->flush(); | |||||
} | |||||
} |
use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent; | use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent; | ||||
use Lc\CaracoleBundle\Factory\File\DocumentFactory; | use Lc\CaracoleBundle\Factory\File\DocumentFactory; | ||||
use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory; | use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory; | ||||
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory; | |||||
use Lc\CaracoleBundle\Factory\Order\OrderProductReductionCatalogFactory; | use Lc\CaracoleBundle\Factory\Order\OrderProductReductionCatalogFactory; | ||||
use Lc\CaracoleBundle\Factory\Order\OrderReductionCartFactory; | use Lc\CaracoleBundle\Factory\Order\OrderReductionCartFactory; | ||||
use Lc\CaracoleBundle\Factory\Order\OrderReductionCreditFactory; | use Lc\CaracoleBundle\Factory\Order\OrderReductionCreditFactory; | ||||
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory; | use Lc\CaracoleBundle\Factory\Order\OrderShopFactory; | ||||
use Lc\CaracoleBundle\Factory\Order\OrderStatusHistoryFactory; | use Lc\CaracoleBundle\Factory\Order\OrderStatusHistoryFactory; | ||||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | |||||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | use Lc\CaracoleBundle\Model\File\DocumentInterface; | ||||
use Lc\CaracoleBundle\Model\File\DocumentModel; | use Lc\CaracoleBundle\Model\File\DocumentModel; | ||||
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; | use Lc\CaracoleBundle\Model\Order\OrderProductInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | ||||
use Lc\CaracoleBundle\Model\Section\OpeningModel; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionModel; | |||||
use Lc\CaracoleBundle\Model\User\VisitorInterface; | use Lc\CaracoleBundle\Model\User\VisitorInterface; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderProductStore; | use Lc\CaracoleBundle\Repository\Order\OrderProductStore; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore; | use Lc\CaracoleBundle\Repository\Order\OrderStatusStore; | ||||
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; | use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; | ||||
use Lc\CaracoleBundle\Resolver\OpeningResolver; | |||||
use Lc\CaracoleBundle\Resolver\Price\PriceResolver; | use Lc\CaracoleBundle\Resolver\Price\PriceResolver; | ||||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\CaracoleBundle\Statistic\Product\ProductsSalesStatistic; | |||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | ||||
protected OrderStatusStore $orderStatusStore; | protected OrderStatusStore $orderStatusStore; | ||||
protected OrderProductStore $orderProductStore; | protected OrderProductStore $orderProductStore; | ||||
protected OrderShopStore $orderShopStore; | protected OrderShopStore $orderShopStore; | ||||
protected OrderShopSolver $orderShopSolver; | |||||
protected ProductFamilyStore $productFamilyStore; | protected ProductFamilyStore $productFamilyStore; | ||||
protected PriceSolver $priceSolver; | protected PriceSolver $priceSolver; | ||||
protected OrderProductBuilder $orderProductBuilder; | protected OrderProductBuilder $orderProductBuilder; | ||||
protected DocumentBuilder $documentBuilder; | protected DocumentBuilder $documentBuilder; | ||||
protected EventDispatcherInterface $eventDispatcher; | protected EventDispatcherInterface $eventDispatcher; | ||||
protected FlashBagInterface $flashBag; | protected FlashBagInterface $flashBag; | ||||
protected OpeningResolver $openingResolver; | |||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $entityManager, | EntityManagerInterface $entityManager, | ||||
OrderShopStore $orderShopStore, | OrderShopStore $orderShopStore, | ||||
OrderShopSolver $orderShopSolver, | |||||
OrderStatusStore $orderStatusStore, | OrderStatusStore $orderStatusStore, | ||||
OrderProductStore $orderProductStore, | OrderProductStore $orderProductStore, | ||||
ProductFamilyStore $productFamilyStore, | ProductFamilyStore $productFamilyStore, | ||||
DocumentBuilder $documentBuilder, | DocumentBuilder $documentBuilder, | ||||
PriceSolver $priceSolver, | PriceSolver $priceSolver, | ||||
EventDispatcherInterface $eventDispatcher, | EventDispatcherInterface $eventDispatcher, | ||||
FlashBagInterface $flashBag | |||||
FlashBagInterface $flashBag, | |||||
OpeningResolver $openingResolver | |||||
) { | ) { | ||||
$this->entityManager = $entityManager; | $this->entityManager = $entityManager; | ||||
$this->orderShopStore = $orderShopStore; | $this->orderShopStore = $orderShopStore; | ||||
$this->orderShopSolver = $orderShopSolver; | |||||
$this->orderStatusStore = $orderStatusStore; | $this->orderStatusStore = $orderStatusStore; | ||||
$this->orderProductStore = $orderProductStore; | $this->orderProductStore = $orderProductStore; | ||||
$this->productFamilyStore = $productFamilyStore; | $this->productFamilyStore = $productFamilyStore; | ||||
$this->priceSolver = $priceSolver; | $this->priceSolver = $priceSolver; | ||||
$this->eventDispatcher = $eventDispatcher; | $this->eventDispatcher = $eventDispatcher; | ||||
$this->flashBag = $flashBag; | $this->flashBag = $flashBag; | ||||
$this->openingResolver = $openingResolver; | |||||
} | } | ||||
public function create( | public function create( | ||||
UserInterface $user = null, | UserInterface $user = null, | ||||
VisitorInterface $visitor = null | VisitorInterface $visitor = null | ||||
): OrderShopInterface { | ): OrderShopInterface { | ||||
$orderShopFactory = new OrderShopFactory(); | $orderShopFactory = new OrderShopFactory(); | ||||
$orderShop = $orderShopFactory->create($section, $user, $visitor); | $orderShop = $orderShopFactory->create($section, $user, $visitor); | ||||
$orderShop->addOrderPayment($orderPayment); | $orderShop->addOrderPayment($orderPayment); | ||||
if ($this->isOrderPaid($orderShop)) { | |||||
if ($this->orderSh->isPaid($orderShop)) { | |||||
$nextStatus = OrderStatusModel::ALIAS_PAID; | $nextStatus = OrderStatusModel::ALIAS_PAID; | ||||
} else { | } else { | ||||
$nextStatus = OrderStatusModel::ALIAS_PARTIAL_PAYMENT; | $nextStatus = OrderStatusModel::ALIAS_PARTIAL_PAYMENT; | ||||
return $orderShop; | return $orderShop; | ||||
} | } | ||||
public function initStatsInfo(OrderShopInterface $orderShop, $flush = true) | |||||
{ | |||||
$orderShop->setStatTotal($this->priceSolver->getTotal($orderShop)); | |||||
$orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop)); | |||||
$orderShop->setStatTotalOrderProductsWithReductions( | |||||
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop) | |||||
); | |||||
$orderShop->setStatTotalOrderProductsWithTaxAndReductions( | |||||
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop) | |||||
); | |||||
$orderShop->setStatMarginOrderProductsWithReductions( | |||||
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop) | |||||
); | |||||
$orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop)); | |||||
$orderShop->setStatDeliveryPriceWithTaxAndReduction( | |||||
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop) | |||||
); | |||||
$this->entityManager->persist($orderShop); | |||||
if ($flush) { | |||||
$this->entityManager->flush(); | |||||
} | |||||
} | |||||
public function initCycleNumber(OrderShopInterface $orderShop): void | |||||
{ | |||||
$cycleNumber = null; | |||||
$deliveryDate = $orderShop->getDeliveryDate(); | |||||
switch ($orderShop->getSection()->getCycle()) { | |||||
case SectionModel::CYCLE_DAY: | |||||
$cycleNumber = $deliveryDate->format('z'); | |||||
break; | |||||
case SectionModel::CYCLE_WEEK: | |||||
$cycleNumber = $deliveryDate->format('W'); | |||||
break; | |||||
} | |||||
$orderShop->setCycleNumber($cycleNumber); | |||||
} | |||||
public function createDocumentInvoice(OrderShopInterface $orderShop): DocumentInterface | public function createDocumentInvoice(OrderShopInterface $orderShop): DocumentInterface | ||||
{ | { | ||||
$documentFactory = new DocumentFactory(); | $documentFactory = new DocumentFactory(); | ||||
$this->entityManager->flush(); | $this->entityManager->flush(); | ||||
} | } | ||||
public function updatePriceByProductFamily(ProductFamilyInterface $productFamily) | |||||
{ | |||||
// @TODO : faire la vérification isOpenSale depuis la méthode appelante | |||||
if (!$this->openingResolver->isOpenSale($productFamily->getSection(), null,null, OpeningResolver::OPENING_CONTEXT_BACKEND)) { | |||||
$countOrderProductUpdated = 0; | |||||
foreach ($productFamily->getProducts() as $product) { | |||||
$orderProducts = $this->orderProductStore->getInCartsByProduct($product); | |||||
foreach ($orderProducts as $orderProduct) { | |||||
$quantityOrder = $orderProduct->getQuantityOrder(); | |||||
$orderShop = $orderProduct->getOrderShop(); | |||||
$orderShop->removeOrderProduct($orderProduct); | |||||
$this->entityManager->delete($orderProduct); | |||||
$this->entityManager->flush(); | |||||
$this->entityManager->refresh($orderShop); | |||||
$orderProductFactory = new OrderProductFactory(); | |||||
$addOrderProduct = $orderProductFactory->create($product, $quantityOrder); | |||||
$this->addOrderProduct($orderShop, $addOrderProduct); | |||||
$countOrderProductUpdated++; | |||||
} | |||||
} | |||||
if ($countOrderProductUpdated) { | |||||
// @TODO : faire le add flash dans le controller | |||||
/*$this->utils->addFlash( | |||||
'success', | |||||
'success.OrderShop.orderProductUpdated', | |||||
array(), | |||||
array('%count%' => $countOrderProductUpdated) | |||||
);*/ | |||||
$this->entityManager->flush(); | |||||
} | |||||
return $countOrderProductUpdated; | |||||
} | |||||
} | |||||
public function setStatsInfo(OrderShopInterface $orderShop, $flush = true) | |||||
{ | |||||
$orderShop->setStatTotal($this->priceSolver->getTotal($orderShop)); | |||||
$orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop)); | |||||
$orderShop->setStatTotalOrderProductsWithReductions( | |||||
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop) | |||||
); | |||||
$orderShop->setStatTotalOrderProductsWithTaxAndReductions( | |||||
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop) | |||||
); | |||||
$orderShop->setStatMarginOrderProductsWithReductions( | |||||
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop) | |||||
); | |||||
$orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop)); | |||||
$orderShop->setStatDeliveryPriceWithTaxAndReduction( | |||||
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop) | |||||
); | |||||
$this->entityManager->update($orderShop); | |||||
if ($flush) { | |||||
$this->entityManager->flush(); | |||||
} | |||||
} | |||||
public function setHasReach(int $reachStep, OrderShopInterface $orderShop) | |||||
{ | |||||
if ($orderShop->getHasReach() === null || $orderShop->getHasReach() < $reachStep) { | |||||
$orderShop->setHasReach($reachStep); | |||||
$this->entityManager->persist($orderShop); | |||||
$this->entityManager->flush($orderShop); | |||||
} | |||||
} | |||||
public function initComplementaryOrderShop(OrderShopInterface $orderShop, OrderShopInterface $mainOrderShop): void | |||||
{ | |||||
$orderShop->setMainOrderShop($mainOrderShop); | |||||
$orderShop->setDeliveryPrice(0); | |||||
if ($mainOrderShop->getDeliveryAddress()) { | |||||
$this->initDeliveryAddress($orderShop, $mainOrderShop->getDeliveryAddress()); | |||||
} | |||||
$orderShop->setInvoiceAddress($mainOrderShop->getInvoiceAddress()); | |||||
} | |||||
// setDeliveryAddress | |||||
public function initDeliveryAddress(OrderShopInterface $orderShop, AddressInterface $address):void | |||||
{ | |||||
$orderShop->setDeliveryAddress($address); | |||||
$orderShop->setDeliveryInfos($address ? $address->getDeliveryInfos() : null); | |||||
} | |||||
// resetOrderShopInfos | |||||
public function reset(OrderShopInterface $orderShop) | |||||
{ | |||||
$this->initDeliveryAddress($orderShop, null); | |||||
$orderShop->setMainOrderShop(null); | |||||
$orderShop->setDeliveryPrice(null); | |||||
$orderShop->setInvoiceAddress(null); | |||||
$orderShop->setDeclineComplementaryOrderShop(false); | |||||
} | |||||
public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2) | |||||
{ | |||||
$productsSalesStatistic = new ProductsSalesStatistic($this->entityManager, $entity, $nbWeek); | |||||
$productsSalesStatistic->init($section, $this->orderShopSolver, $this->openingResolver); | |||||
$productsSalesStatistic->populateProperties($this->orderShopStore); | |||||
return $productsSalesStatistic->getAsArray(); | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Checker; | |||||
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||||
class OrderChecker | |||||
{ | |||||
protected PriceSolver $priceSolver; | |||||
protected OrderShopSolver $orderShopSolver; | |||||
public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver) | |||||
{ | |||||
$this->priceSolver = $priceSolver; | |||||
$this->orderShopSolver = $orderShopSolver; | |||||
} | |||||
public function hasOrderProductAlreadyInCart( | |||||
OrderShopInterface $orderShop, | |||||
OrderProductInterface $orderProductTest | |||||
): ?OrderProductInterface { | |||||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||||
if ($orderProduct->getProduct() == $orderProductTest->getProduct()) { | |||||
return $orderProduct; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public function isValid(OrderShopInterface $orderShop): bool | |||||
{ | |||||
if ($orderShop->getOrderStatus() && in_array( | |||||
$orderShop->getOrderStatus()->getAlias(), | |||||
OrderStatusModel::$statusAliasAsValid | |||||
) > 0) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
public function isCart(OrderShopInterface $orderShop): bool | |||||
{ | |||||
if ($orderShop->getOrderStatus() && in_array( | |||||
$orderShop->getOrderStatus()->getAlias(), | |||||
OrderStatusModel::$statusAliasAsCart | |||||
) > 0) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
// isOrderShopPositiveAmount | |||||
public function isPositiveAmount(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return $this->priceSolver->getTotalWithTax($orderShop) >= 0; | |||||
} | |||||
public function isPaid(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): bool | |||||
{ | |||||
$totalOrderPayments = $this->orderShopSolver->getTotalOrderPayments($orderShop, $mergeComplementaryOrderShop); | |||||
$totalOrder = $this->priceSolver->getTotalWithTax($orderShop); | |||||
if ((abs($totalOrderPayments - $totalOrder) < 0.00001 | |||||
|| $totalOrderPayments >= $totalOrder) | |||||
&& $totalOrder > 0) { | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | |||||
// isOrderShopPositiveAmountRemainingToBePaid | |||||
public function isPositiveAmountRemainingToBePaid(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return $this->orderShopSolver->getTotalRemainingToBePaid($orderShop) > 0; | |||||
} | |||||
public function isCartAllowToBeOrder(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return true; | |||||
} | |||||
} |
namespace Lc\CaracoleBundle\Container\Order; | namespace Lc\CaracoleBundle\Container\Order; | ||||
use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder; | use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder; | ||||
use Lc\CaracoleBundle\Checker\OrderChecker; | |||||
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory; | use Lc\CaracoleBundle\Factory\Order\OrderShopFactory; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderShopRepositoryQuery; | use Lc\CaracoleBundle\Repository\Order\OrderShopRepositoryQuery; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | ||||
{ | { | ||||
protected OrderShopFactory $orderShopFactory; | protected OrderShopFactory $orderShopFactory; | ||||
protected OrderShopSolver $orderShopSolver; | protected OrderShopSolver $orderShopSolver; | ||||
protected OrderChecker $orderChecker; | |||||
protected OrderShopRepositoryQuery $orderShopRepositoryQuery; | protected OrderShopRepositoryQuery $orderShopRepositoryQuery; | ||||
protected OrderShopStore $orderShopStore; | protected OrderShopStore $orderShopStore; | ||||
protected OrderShopBuilder $orderShopBuilder; | protected OrderShopBuilder $orderShopBuilder; | ||||
public function __construct( | public function __construct( | ||||
OrderShopFactory $orderShopFactory, | OrderShopFactory $orderShopFactory, | ||||
OrderShopSolver $orderShopSolver, | OrderShopSolver $orderShopSolver, | ||||
OrderChecker $orderChecker, | |||||
OrderShopRepositoryQuery $orderShopRepositoryQuery, | OrderShopRepositoryQuery $orderShopRepositoryQuery, | ||||
OrderShopStore $orderShopStore, | OrderShopStore $orderShopStore, | ||||
OrderShopBuilder $orderShopBuilder | OrderShopBuilder $orderShopBuilder | ||||
) { | ) { | ||||
$this->orderShopFactory = $orderShopFactory; | $this->orderShopFactory = $orderShopFactory; | ||||
$this->orderShopSolver = $orderShopSolver; | $this->orderShopSolver = $orderShopSolver; | ||||
$this->orderChecker = $orderChecker; | |||||
$this->orderShopRepositoryQuery = $orderShopRepositoryQuery; | $this->orderShopRepositoryQuery = $orderShopRepositoryQuery; | ||||
$this->orderShopStore = $orderShopStore; | $this->orderShopStore = $orderShopStore; | ||||
$this->orderShopBuilder = $orderShopBuilder; | $this->orderShopBuilder = $orderShopBuilder; | ||||
return $this->orderShopSolver; | return $this->orderShopSolver; | ||||
} | } | ||||
public function getChecker(): OrderChecker | |||||
{ | |||||
return $this->orderChecker; | |||||
} | |||||
public function getRepositoryQuery(): OrderShopRepositoryQuery | public function getRepositoryQuery(): OrderShopRepositoryQuery | ||||
{ | { | ||||
return $this->orderShopRepositoryQuery; | return $this->orderShopRepositoryQuery; |
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface; | use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface; | ||||
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository; | use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository; | ||||
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; | |||||
use Lc\CaracoleBundle\Repository\Section\SectionRepository; | use Lc\CaracoleBundle\Repository\Section\SectionRepository; | ||||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||||
use Lc\SovBundle\Solver\Setting\SettingSolver; | |||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||||
use Symfony\Component\HttpKernel\KernelEvents; | use Symfony\Component\HttpKernel\KernelEvents; | ||||
class SettingEventSubscriber implements EventSubscriberInterface | class SettingEventSubscriber implements EventSubscriberInterface | ||||
{ | { | ||||
protected $em; | |||||
protected $merchantRepository; | |||||
protected $sectionRepository; | |||||
protected $merchantSettingDefinition; | |||||
protected $sectionSettingDefinition; | |||||
protected $merchantSettingFactory; | |||||
protected $sectionSettingFactory; | |||||
protected EntityManagerInterface $entityManager; | |||||
protected MerchantSettingDefinitionInterface $merchantSettingDefinition; | |||||
protected SectionSettingDefinitionInterface $sectionSettingDefinition; | |||||
protected MerchantStore $merchantStore; | |||||
protected SectionStore $sectionStore; | |||||
protected MerchantSettingFactory $merchantSettingFactory; | |||||
protected SectionSettingFactory $sectionSettingFactory; | |||||
protected SettingSolver $settingSolver; | |||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $em, | |||||
EntityManagerInterface $entityManager, | |||||
MerchantSettingDefinitionInterface $merchantSettingDefinition, | MerchantSettingDefinitionInterface $merchantSettingDefinition, | ||||
SectionSettingDefinitionInterface $sectionSettingDefinition, | SectionSettingDefinitionInterface $sectionSettingDefinition, | ||||
MerchantRepository $merchantRepository, | |||||
SectionRepository $sectionRepository, | |||||
MerchantStore $merchantStore, | |||||
SectionStore $sectionStore, | |||||
MerchantSettingFactory $merchantSettingFactory, | MerchantSettingFactory $merchantSettingFactory, | ||||
SectionSettingFactory $sectionSettingFactory | |||||
SectionSettingFactory $sectionSettingFactory, | |||||
SettingSolver $settingSolver | |||||
) { | ) { | ||||
$this->em = $em; | |||||
$this->merchantRepository = $merchantRepository; | |||||
$this->sectionRepository = $sectionRepository; | |||||
$this->entityManager = $entityManager; | |||||
$this->merchantStore = $merchantStore; | |||||
$this->sectionStore = $sectionStore; | |||||
$this->merchantSettingDefinition = $merchantSettingDefinition; | $this->merchantSettingDefinition = $merchantSettingDefinition; | ||||
$this->sectionSettingDefinition = $sectionSettingDefinition; | $this->sectionSettingDefinition = $sectionSettingDefinition; | ||||
$this->merchantSettingFactory = $merchantSettingFactory; | $this->merchantSettingFactory = $merchantSettingFactory; | ||||
$this->sectionSettingFactory = $sectionSettingFactory; | $this->sectionSettingFactory = $sectionSettingFactory; | ||||
$this->settingSolver = $settingSolver; | |||||
} | } | ||||
public static function getSubscribedEvents() | public static function getSubscribedEvents() | ||||
$this->initSettingsGeneric( | $this->initSettingsGeneric( | ||||
'merchant', | 'merchant', | ||||
$this->merchantSettingDefinition->getSettings(), | $this->merchantSettingDefinition->getSettings(), | ||||
$this->merchantRepository->findAll(), | |||||
//TODO vérifier que ce soit bien les online que l'on souhaite | |||||
$this->merchantStore->getOnline(), | |||||
$this->merchantSettingFactory | $this->merchantSettingFactory | ||||
); | ); | ||||
$this->initSettingsGeneric( | $this->initSettingsGeneric( | ||||
'section', | 'section', | ||||
$this->sectionSettingDefinition->getSettings(), | $this->sectionSettingDefinition->getSettings(), | ||||
$this->sectionRepository->findAll(), | |||||
//TODOJ'en suis là !!! Et je sais pas ce que je dois mettre, tout les sections ? et les sections d'un merchant ? | |||||
$this->sectionStore->getOnline(), | |||||
$this->sectionSettingFactory | $this->sectionSettingFactory | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
if ($createEntitySetting) { | if ($createEntitySetting) { | ||||
$text = null; | $text = null; | ||||
$date = null; | $date = null; | ||||
$file = null; | $file = null; | ||||
$entitySetting = $factory->create($entity, $setting['name'], $text, $date, $file); | $entitySetting = $factory->create($entity, $setting['name'], $text, $date, $file); | ||||
$this->em->persist($entitySetting); | |||||
$this->entityManager->persist($entitySetting); | |||||
} | } | ||||
} else { | } else { | ||||
if ($entitySetting->getValue() === null | |||||
if ($this->settingSolver->getValue($entitySetting) === null | |||||
&& isset($setting['default']) | && isset($setting['default']) | ||||
&& $setting['default'] !== null) { | && $setting['default'] !== null) { | ||||
$methodSetValue = 'set' . ucfirst($setting['field']); | $methodSetValue = 'set' . ucfirst($setting['field']); | ||||
$entitySetting->$methodSetValue($setting['default']); | $entitySetting->$methodSetValue($setting['default']); | ||||
$this->em->update($entitySetting); | |||||
$this->entityManager->update($entitySetting); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$this->em->flush(); | |||||
$this->entityManager->flush(); | |||||
} | } | ||||
} | } |
public function getUnit(): ?string; | public function getUnit(): ?string; | ||||
public function setUnit(string $unit): \Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
public function setUnit(string $unit); | |||||
public function getWording(): ?string; | public function getWording(): ?string; | ||||
public function setWording(string $wording): \Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
public function setWording(string $wording); | |||||
public function getWordingUnit(): ?string; | public function getWordingUnit(): ?string; | ||||
public function setWordingUnit(string $wordingUnit): \Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
public function setWordingUnit(string $wordingUnit); | |||||
public function getWordingShort(): ?string; | public function getWordingShort(): ?string; | ||||
public function setWordingShort(string $wordingShort): \Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
public function setWordingShort(string $wordingShort); | |||||
public function getCoefficient(): ?int; | public function getCoefficient(): ?int; | ||||
public function setCoefficient(int $coefficient): \Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
public function setCoefficient(int $coefficient); | |||||
public function getUnitReference(): ?self; | public function getUnitReference(): ?self; | ||||
public function setUnitReference(?self $unitReference): \Lc\CaracoleBundle\Model\Config\UnitModel; | |||||
public function setUnitReference(?UnitModel $unitReference): self; | |||||
} | } |
const MEAN_PAYMENT_TRANSFER = 'transfer'; | const MEAN_PAYMENT_TRANSFER = 'transfer'; | ||||
const MEAN_PAYMENT_CASH = 'cash'; | const MEAN_PAYMENT_CASH = 'cash'; | ||||
/**$merchant | |||||
/** | |||||
* @ORM\Column(type="float", nullable=true) | * @ORM\Column(type="float", nullable=true) | ||||
*/ | */ | ||||
protected $amount; | protected $amount; |
public function getValidationDate(): ?\DateTimeInterface; | public function getValidationDate(): ?\DateTimeInterface; | ||||
public function setValidationDate(\DateTimeInterface $validationDate | public function setValidationDate(\DateTimeInterface $validationDate | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getUser(): ?UserInterface; | public function getUser(): ?UserInterface; | ||||
public function setUser(?UserInterface $user): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setUser(?UserInterface $user): OrderShopModel; | |||||
public function getInvoiceAddress(): ?AddressInterface; | public function getInvoiceAddress(): ?AddressInterface; | ||||
public function setInvoiceAddress(?AddressInterface $invoiceAddress): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setInvoiceAddress(?AddressInterface $invoiceAddress): OrderShopModel; | |||||
public function getInvoiceAddressText(): ?string; | public function getInvoiceAddressText(): ?string; | ||||
public function setInvoiceAddressText(string $invoiceAddressText): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setInvoiceAddressText(string $invoiceAddressText): OrderShopModel; | |||||
public function getComment(): ?string; | public function getComment(): ?string; | ||||
public function setComment(?string $comment): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setComment(?string $comment): OrderShopModel; | |||||
public function getMeanPayment(): ?string; | public function getMeanPayment(): ?string; | ||||
public function setMeanPayment(string $meanPayment): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setMeanPayment(string $meanPayment): OrderShopModel; | |||||
/** | /** | ||||
* @return Collection|OrderStatusHistoryInterface[] | * @return Collection|OrderStatusHistoryInterface[] | ||||
public function getOrderStatusHistories(): Collection; | public function getOrderStatusHistories(): Collection; | ||||
public function addOrderStatusHistory(OrderStatusHistoryInterface $orderStatusHistory | public function addOrderStatusHistory(OrderStatusHistoryInterface $orderStatusHistory | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function removeOrderStatusHistory(OrderStatusHistoryInterface $orderStatusHistory | public function removeOrderStatusHistory(OrderStatusHistoryInterface $orderStatusHistory | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
/** | /** | ||||
* @return Collection|OrderPaymentInterface[] | * @return Collection|OrderPaymentInterface[] | ||||
*/ | */ | ||||
public function getOrderPayments($meanPayment = null): Collection; | public function getOrderPayments($meanPayment = null): Collection; | ||||
public function addOrderPayment(OrderPaymentInterface $orderPayment): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function addOrderPayment(OrderPaymentInterface $orderPayment): OrderShopModel; | |||||
public function removeOrderPayment(OrderPaymentInterface $orderPayment | public function removeOrderPayment(OrderPaymentInterface $orderPayment | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
/** | /** | ||||
* @return Collection|OrderProductInterface[] | * @return Collection|OrderProductInterface[] | ||||
*/ | */ | ||||
public function getOrderProducts(): Collection; | public function getOrderProducts(): Collection; | ||||
public function addOrderProduct(OrderProductInterface $orderProduct): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function addOrderProduct(OrderProductInterface $orderProduct): OrderShopModel; | |||||
public function removeOrderProduct(OrderProductInterface $orderProduct | public function removeOrderProduct(OrderProductInterface $orderProduct | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getVisitor(): ?VisitorInterface; | public function getVisitor(): ?VisitorInterface; | ||||
public function setVisitor(?VisitorInterface $visitor): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setVisitor(?VisitorInterface $visitor): OrderShopModel; | |||||
public function getDeliveryInfos(): ?string; | public function getDeliveryInfos(): ?string; | ||||
public function setDeliveryInfos(?string $deliveryInfos): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setDeliveryInfos(?string $deliveryInfos): OrderShopModel; | |||||
public function getOrderStatus(): ?OrderStatusInterface; | public function getOrderStatus(): ?OrderStatusInterface; | ||||
public function setOrderStatusProtected(?OrderStatusInterface $orderStatus | public function setOrderStatusProtected(?OrderStatusInterface $orderStatus | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
/** | /** | ||||
* @return Collection|OrderReductionCartInterface[] | * @return Collection|OrderReductionCartInterface[] | ||||
public function getOrderReductionCarts(): Collection; | public function getOrderReductionCarts(): Collection; | ||||
public function addOrderReductionCart(OrderReductionCartInterface $orderReductionCart | public function addOrderReductionCart(OrderReductionCartInterface $orderReductionCart | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function removeOrderReductionCart(OrderReductionCartInterface $orderReductionCart | public function removeOrderReductionCart(OrderReductionCartInterface $orderReductionCart | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
/** | /** | ||||
* @return Collection|OrderReductionCreditInterface[] | * @return Collection|OrderReductionCreditInterface[] | ||||
public function getOrderReductionCredits(): Collection; | public function getOrderReductionCredits(): Collection; | ||||
public function addOrderReductionCredit(OrderReductionCreditInterface $orderReductionCredit | public function addOrderReductionCredit(OrderReductionCreditInterface $orderReductionCredit | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function removeOrderReductionCredit(OrderReductionCreditInterface $orderReductionCredit | public function removeOrderReductionCredit(OrderReductionCreditInterface $orderReductionCredit | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
/** | /** | ||||
* @return Collection|DocumentInterface[] | * @return Collection|DocumentInterface[] | ||||
*/ | */ | ||||
public function getDocuments(): Collection; | public function getDocuments(): Collection; | ||||
public function addDocument(DocumentInterface $document): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function addDocument(DocumentInterface $document): OrderShopModel; | |||||
public function removeDocument(DocumentInterface $document): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function removeDocument(DocumentInterface $document): OrderShopModel; | |||||
/** | /** | ||||
* @return Collection|TicketInterface[] | * @return Collection|TicketInterface[] | ||||
*/ | */ | ||||
public function getTickets(): Collection; | public function getTickets(): Collection; | ||||
public function addTicket(TicketInterface $ticket): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function addTicket(TicketInterface $ticket): OrderShopModel; | |||||
public function removeTicket(TicketInterface $ticket): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function removeTicket(TicketInterface $ticket): OrderShopModel; | |||||
public function getSection(): ?SectionInterface; | public function getSection(): ?SectionInterface; | ||||
public function setSection(?SectionInterface $section): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setSection(?SectionInterface $section): OrderShopModel; | |||||
public function getCycleId(): ?int; | public function getCycleId(): ?int; | ||||
public function setCycleId(?int $cycleId): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setCycleId(?int $cycleId): OrderShopModel; | |||||
public function getCycleNumber(): ?int; | public function getCycleNumber(): ?int; | ||||
public function setCycleNumber(?int $cycleNumber): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setCycleNumber(?int $cycleNumber): OrderShopModel; | |||||
public function getOrderShopCreatedAt(): ?\DateTimeInterface; | public function getOrderShopCreatedAt(): ?\DateTimeInterface; | ||||
public function setOrderShopCreatedAt(?\DateTimeInterface $orderShopCreatedAt | public function setOrderShopCreatedAt(?\DateTimeInterface $orderShopCreatedAt | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getIdValidOrder(): ?int; | public function getIdValidOrder(): ?int; | ||||
public function setIdValidOrder(?int $idValidOrder): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setIdValidOrder(?int $idValidOrder): OrderShopModel; | |||||
public function getDeliveryAddress(): ?AddressInterface; | public function getDeliveryAddress(): ?AddressInterface; | ||||
public function setDeliveryAddress(?AddressInterface $deliveryAddress | public function setDeliveryAddress(?AddressInterface $deliveryAddress | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getDeliveryAddressText(): ?string; | public function getDeliveryAddressText(): ?string; | ||||
public function setDeliveryAddressText(string $deliveryAddressText): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setDeliveryAddressText(string $deliveryAddressText): OrderShopModel; | |||||
public function getDeliveryPointSale(): ?PointSaleInterface; | public function getDeliveryPointSale(): ?PointSaleInterface; | ||||
public function setDeliveryPointSale(?PointSaleInterface $deliveryPointSale | public function setDeliveryPointSale(?PointSaleInterface $deliveryPointSale | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getDeliveryType(): ?string; | public function getDeliveryType(): ?string; | ||||
public function setDeliveryType(?string $deliveryType): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setDeliveryType(?string $deliveryType): OrderShopModel; | |||||
public function getDeliveryPrice(): ?float; | public function getDeliveryPrice(): ?float; | ||||
public function setDeliveryPrice(?float $deliveryPrice): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setDeliveryPrice(?float $deliveryPrice): OrderShopModel; | |||||
public function getDeliveryTaxRate(): ?TaxRateInterface; | public function getDeliveryTaxRate(): ?TaxRateInterface; | ||||
public function setDeliveryTaxRate(?TaxRateInterface $deliveryTaxRate | public function setDeliveryTaxRate(?TaxRateInterface $deliveryTaxRate | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getReference(): ?string; | public function getReference(): ?string; | ||||
public function setReference(?string $reference): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setReference(?string $reference): OrderShopModel; | |||||
public function getMainOrderShop(): ?self; | public function getMainOrderShop(): ?self; | ||||
public function setMainOrderShop(?self $mainOrderShop): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setMainOrderShop(?OrderShopModel $mainOrderShop): OrderShopModel; | |||||
/** | /** | ||||
* @return Collection|OrderShopInterface[] | * @return Collection|OrderShopInterface[] | ||||
*/ | */ | ||||
public function getComplementaryOrderShops(): Collection; | public function getComplementaryOrderShops(): Collection; | ||||
public function addComplementaryOrderShop(self $complementaryOrderShop | |||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function addComplementaryOrderShop(OrderShopModel $complementaryOrderShop | |||||
): OrderShopModel; | |||||
public function removeComplementaryOrderShop(self $complementaryOrderShop | |||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function removeComplementaryOrderShop(OrderShopModel $complementaryOrderShop | |||||
): OrderShopModel; | |||||
public function getDeclineComplementaryOrderShop(): ?bool; | public function getDeclineComplementaryOrderShop(): ?bool; | ||||
public function setDeclineComplementaryOrderShop(?bool $declineComplementaryOrderShop | public function setDeclineComplementaryOrderShop(?bool $declineComplementaryOrderShop | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getOrderAllowByAdmin(): ?bool; | public function getOrderAllowByAdmin(): ?bool; | ||||
public function setOrderAllowByAdmin(?bool $orderAllowByAdmin): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setOrderAllowByAdmin(?bool $orderAllowByAdmin): OrderShopModel; | |||||
public function getHasReach(): ?int; | public function getHasReach(): ?int; | ||||
public function setHasReach(?int $hasReach): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setHasReach(?int $hasReach): OrderShopModel; | |||||
public function getStatTotal(): ?float; | public function getStatTotal(): ?float; | ||||
public function setStatTotal(?float $statTotal): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setStatTotal(?float $statTotal): OrderShopModel; | |||||
public function getStatTotalWithTax(): ?float; | public function getStatTotalWithTax(): ?float; | ||||
public function setStatTotalWithTax(?float $statTotalWithTax): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
public function setStatTotalWithTax(?float $statTotalWithTax): OrderShopModel; | |||||
public function getStatTotalOrderProductsWithReductions(): ?float; | public function getStatTotalOrderProductsWithReductions(): ?float; | ||||
public function setStatTotalOrderProductsWithReductions(?float $statTotalOrderProductsWithReductions | public function setStatTotalOrderProductsWithReductions(?float $statTotalOrderProductsWithReductions | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getStatTotalOrderProductsWithTaxAndReductions(): ?float; | public function getStatTotalOrderProductsWithTaxAndReductions(): ?float; | ||||
public function setStatTotalOrderProductsWithTaxAndReductions(?float $statTotalOrderProductsWithTaxAndReductions | public function setStatTotalOrderProductsWithTaxAndReductions(?float $statTotalOrderProductsWithTaxAndReductions | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getStatMarginOrderProductsWithReductions(): ?float; | public function getStatMarginOrderProductsWithReductions(): ?float; | ||||
public function setStatMarginOrderProductsWithReductions(?float $statMarginOrderProductsWithReductions | public function setStatMarginOrderProductsWithReductions(?float $statMarginOrderProductsWithReductions | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getStatDeliveryPriceWithReduction(): ?float; | public function getStatDeliveryPriceWithReduction(): ?float; | ||||
public function setStatDeliveryPriceWithReduction(?float $statDeliveryPriceWithReduction | public function setStatDeliveryPriceWithReduction(?float $statDeliveryPriceWithReduction | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
public function getStatDeliveryPriceWithTaxAndReduction(): ?float; | public function getStatDeliveryPriceWithTaxAndReduction(): ?float; | ||||
public function setStatDeliveryPriceWithTaxAndReduction(?float $statDeliveryPriceWithTaxAndReduction | public function setStatDeliveryPriceWithTaxAndReduction(?float $statDeliveryPriceWithTaxAndReduction | ||||
): \Lc\CaracoleBundle\Model\Order\OrderShopModel; | |||||
): OrderShopModel; | |||||
} | } |
{ | { | ||||
public function getSection(): SectionInterface; | public function getSection(): SectionInterface; | ||||
public function setSection(SectionInterface $section): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel; | |||||
public function setSection(SectionInterface $section): ProductCategoryModel; | |||||
public function getParent(): ?self; | public function getParent(): ?self; | ||||
public function setParent(?self $productCategory): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel; | |||||
public function setParent(?ProductCategoryModel $productCategory): ProductCategoryModel; | |||||
public function getParentCategory(); | public function getParentCategory(); | ||||
*/ | */ | ||||
public function getChildrens(): Collection; | public function getChildrens(): Collection; | ||||
public function addChildren(self $productCategory): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel; | |||||
public function addChildren(ProductCategoryModel $productCategory): ProductCategoryModel; | |||||
public function removeChildren(self $productCategory): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel; | |||||
public function removeChildren(ProductCategoryModel $productCategory): ProductCategoryModel; | |||||
/** | /** | ||||
* @return Collection|ProductFamilyInterface[] | * @return Collection|ProductFamilyInterface[] | ||||
public function getProductFamilies(): Collection; | public function getProductFamilies(): Collection; | ||||
public function addProductFamily(ProductFamilyInterface $productFamily | public function addProductFamily(ProductFamilyInterface $productFamily | ||||
): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel; | |||||
): ProductCategoryModel; | |||||
public function removeProductFamily(ProductFamilyInterface $productFamily | public function removeProductFamily(ProductFamilyInterface $productFamily | ||||
): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel; | |||||
): ProductCategoryModel; | |||||
public function countProductFamilies($status = null); | public function countProductFamilies($status = null); | ||||
public function getSaleStatus(): ?bool; | public function getSaleStatus(): ?bool; | ||||
public function setSaleStatus(bool $saleStatus): \Lc\CaracoleBundle\Model\Product\ProductCategoryModel; | |||||
public function setSaleStatus(bool $saleStatus): ProductCategoryModel; | |||||
} | } |
public function getSection(): SectionInterface; | public function getSection(): SectionInterface; | ||||
public function setSection(SectionInterface $section): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setSection(SectionInterface $section): ProductFamilyModel; | |||||
public function getAvailableQuantityInherited(); | public function getAvailableQuantityInherited(); | ||||
public function getActiveProducts(): ?bool; | public function getActiveProducts(): ?bool; | ||||
public function setActiveProducts(bool $activeProducts): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setActiveProducts(bool $activeProducts): ProductFamilyModel; | |||||
public function getProductsQuantityAsTitle(): ?bool; | public function getProductsQuantityAsTitle(): ?bool; | ||||
public function setProductsQuantityAsTitle(bool $productsQuantityAsTitle | public function setProductsQuantityAsTitle(bool $productsQuantityAsTitle | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getProductsType(): ?string; | public function getProductsType(): ?string; | ||||
public function setProductsType(?string $productsType): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setProductsType(?string $productsType): ProductFamilyModel; | |||||
public function getQuantityLabel(): ?string; | public function getQuantityLabel(): ?string; | ||||
public function setQuantityLabel(?string $quantityLabel): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setQuantityLabel(?string $quantityLabel): ProductFamilyModel; | |||||
/** | /** | ||||
* @return Collection|ProductInterface[] | * @return Collection|ProductInterface[] | ||||
public function getProductsOnline(): Collection; | public function getProductsOnline(): Collection; | ||||
public function addProduct(ProductInterface $product): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function addProduct(ProductInterface $product): ProductFamilyModel; | |||||
public function removeProduct(ProductInterface $product): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function removeProduct(ProductInterface $product): ProductFamilyModel; | |||||
public function getReductionCatalog(): ?ReductionCatalogInterface; | public function getReductionCatalog(): ?ReductionCatalogInterface; | ||||
public function getReductionCatalogInherited(): ?ReductionCatalogInterface; | public function getReductionCatalogInherited(): ?ReductionCatalogInterface; | ||||
public function setReductionCatalog(?ReductionCatalogInterface $reductionCatalog | public function setReductionCatalog(?ReductionCatalogInterface $reductionCatalog | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
/** | /** | ||||
* @return Collection|ProductCategoryInterface[] | * @return Collection|ProductCategoryInterface[] | ||||
public function initProductCategories(); | public function initProductCategories(); | ||||
public function addProductCategory(ProductCategoryInterface $productCategory | public function addProductCategory(ProductCategoryInterface $productCategory | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function removeProductCategory(ProductCategoryInterface $productCategory | public function removeProductCategory(ProductCategoryInterface $productCategory | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getProductCategoryParent(); | public function getProductCategoryParent(); | ||||
public function getSubtitle(): ?string; | public function getSubtitle(): ?string; | ||||
public function setSubtitle(?string $subtitle): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setSubtitle(?string $subtitle): ProductFamilyModel; | |||||
public function getWarningMessage(): ?string; | public function getWarningMessage(): ?string; | ||||
public function setWarningMessage(?string $warningMessage): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setWarningMessage(?string $warningMessage): ProductFamilyModel; | |||||
public function getWarningMessageType(): ?string; | public function getWarningMessageType(): ?string; | ||||
public function setWarningMessageType(?string $warningMessageType | public function setWarningMessageType(?string $warningMessageType | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getNote(): ?string; | public function getNote(): ?string; | ||||
public function setNote(?string $note): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setNote(?string $note): ProductFamilyModel; | |||||
public function getBehaviorOutOfStock(): ?string; | public function getBehaviorOutOfStock(): ?string; | ||||
public function setBehaviorOutOfStock(?string $behaviorOutOfStock | public function setBehaviorOutOfStock(?string $behaviorOutOfStock | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getBehaviorCountStock(): ?string; | public function getBehaviorCountStock(): ?string; | ||||
public function setBehaviorCountStock(string $behaviorCountStock | public function setBehaviorCountStock(string $behaviorCountStock | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getExportTitle(): ?string; | public function getExportTitle(): ?string; | ||||
public function setExportTitle(?string $exportTitle): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setExportTitle(?string $exportTitle): ProductFamilyModel; | |||||
public function getExportNote(): ?string; | public function getExportNote(): ?string; | ||||
public function setExportNote(?string $exportNote): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setExportNote(?string $exportNote): ProductFamilyModel; | |||||
public function getBehaviorStockWeek(): ?string; | |||||
public function getBehaviorStockCycle(): ?string; | |||||
public function setBehaviorStockWeek(string $behaviorStockWeek | |||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setBehaviorStockCycle(string $behaviorStockWeek | |||||
): ProductFamilyModel; | |||||
public function getAvailabilityRenewedThisWeek(): ?bool; | public function getAvailabilityRenewedThisWeek(): ?bool; | ||||
public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek | public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getBehaviorDisplaySale(): ?string; | public function getBehaviorDisplaySale(): ?string; | ||||
public function setBehaviorDisplaySale(string $behaviorDisplaySale | public function setBehaviorDisplaySale(string $behaviorDisplaySale | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function isPropertyNoveltyOnline(): ?bool; | public function isPropertyNoveltyOnline(): ?bool; | ||||
public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface; | public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface; | ||||
public function setPropertyNoveltyExpirationDate(?\DateTimeInterface $propertyNoveltyExpirationDate | public function setPropertyNoveltyExpirationDate(?\DateTimeInterface $propertyNoveltyExpirationDate | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getPropertyOrganicLabel(): ?string; | public function getPropertyOrganicLabel(): ?string; | ||||
public function setPropertyOrganicLabel(?string $propertyOrganicLabel | public function setPropertyOrganicLabel(?string $propertyOrganicLabel | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getPropertyAllergens(): ?string; | public function getPropertyAllergens(): ?string; | ||||
public function setPropertyAllergens(?string $propertyAllergens | public function setPropertyAllergens(?string $propertyAllergens | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getPropertyComposition(): ?string; | public function getPropertyComposition(): ?string; | ||||
public function setPropertyComposition(?string $propertyComposition | public function setPropertyComposition(?string $propertyComposition | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getPropertyFragrances(): ?string; | public function getPropertyFragrances(): ?string; | ||||
public function setPropertyFragrances(?string $propertyFragrances | public function setPropertyFragrances(?string $propertyFragrances | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function countProperties(): bool; | public function countProperties(): bool; | ||||
public function getBehaviorExpirationDate(): ?string; | public function getBehaviorExpirationDate(): ?string; | ||||
public function setBehaviorExpirationDate(?string $behaviorExpirationDate | public function setBehaviorExpirationDate(?string $behaviorExpirationDate | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getTypeExpirationDate(): ?string; | public function getTypeExpirationDate(): ?string; | ||||
public function setTypeExpirationDate(?string $typeExpirationDate | public function setTypeExpirationDate(?string $typeExpirationDate | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getPropertyWeight(): ?string; | public function getPropertyWeight(): ?string; | ||||
public function setPropertyWeight(?string $propertyWeight): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setPropertyWeight(?string $propertyWeight): ProductFamilyModel; | |||||
public function getPropertyQuantity(): ?string; | public function getPropertyQuantity(): ?string; | ||||
public function setPropertyQuantity(?string $propertyQuantity): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setPropertyQuantity(?string $propertyQuantity): ProductFamilyModel; | |||||
public function getPropertyVariety(): ?string; | public function getPropertyVariety(): ?string; | ||||
public function setPropertyVariety(?string $propertyVariety): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setPropertyVariety(?string $propertyVariety): ProductFamilyModel; | |||||
public function getPropertyFeature(): ?string; | public function getPropertyFeature(): ?string; | ||||
public function setPropertyFeature(?string $propertyFeature): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setPropertyFeature(?string $propertyFeature): ProductFamilyModel; | |||||
public function getPropertyAlcoholLevel(): ?string; | public function getPropertyAlcoholLevel(): ?string; | ||||
public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel | public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getPropertyPackaging(): ?string; | public function getPropertyPackaging(): ?string; | ||||
public function setPropertyPackaging(?string $propertyPackaging | public function setPropertyPackaging(?string $propertyPackaging | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getPropertyCharacteristics(): ?string; | public function getPropertyCharacteristics(): ?string; | ||||
public function setPropertyCharacteristics(?string $propertyCharacteristics | public function setPropertyCharacteristics(?string $propertyCharacteristics | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getBehaviorAddToCart(): ?string; | public function getBehaviorAddToCart(): ?string; | ||||
public function setBehaviorAddToCart(?string $behaviorAddToCart | public function setBehaviorAddToCart(?string $behaviorAddToCart | ||||
): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
): ProductFamilyModel; | |||||
public function getBehaviorPrice(): ?string; | public function getBehaviorPrice(): ?string; | ||||
public function getBehaviorPriceInherited(); | public function getBehaviorPriceInherited(); | ||||
public function setBehaviorPrice(?string $behaviorPrice): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setBehaviorPrice(?string $behaviorPrice): ProductFamilyModel; | |||||
public function hasProductsWithVariousWeight(); | public function hasProductsWithVariousWeight(); | ||||
public function getSaleStatus(): ?bool; | public function getSaleStatus(): ?bool; | ||||
public function setSaleStatus(bool $saleStatus): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setSaleStatus(bool $saleStatus): ProductFamilyModel; | |||||
public function getFieldBuyingPrice(); | public function getFieldBuyingPrice(); | ||||
public function getImage(): ?FileInterface; | public function getImage(): ?FileInterface; | ||||
public function setImage(?FileInterface $image): \Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
public function setImage(?FileInterface $image): ProductFamilyModel; | |||||
} | } |
/** | /** | ||||
* @ORM\Column(type="string", length=255) | * @ORM\Column(type="string", length=255) | ||||
*/ | */ | ||||
protected $behaviorStockWeek; | |||||
protected $behaviorStockCycle; | |||||
/** | /** | ||||
* @ORM\Column(type="boolean", nullable=true) | * @ORM\Column(type="boolean", nullable=true) | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getBehaviorStockWeek(): ?string | |||||
public function getBehaviorStockCycle(): ?string | |||||
{ | { | ||||
return $this->behaviorStockWeek; | |||||
return $this->behaviorStockCycle; | |||||
} | } | ||||
public function setBehaviorStockWeek(string $behaviorStockWeek): self | |||||
public function setBehaviorStockCycle(string $behaviorStockCycle): self | |||||
{ | { | ||||
$this->behaviorStockWeek = $behaviorStockWeek; | |||||
$this->behaviorStockCycle = $behaviorStockCycle; | |||||
return $this; | return $this; | ||||
} | } |
namespace Lc\CaracoleBundle\Repository\Order; | namespace Lc\CaracoleBundle\Repository\Order; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class OrderProductRepositoryQuery extends AbstractRepositoryQuery | class OrderProductRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
protected bool $isJoinProduct = false; | |||||
protected bool $isJoinProductFamily = false; | |||||
protected bool $isJoinOrderShop = false; | |||||
protected bool $isJoinOrderStatus = false; | |||||
public function __construct(OrderProductRepository $repository, PaginatorInterface $paginator) | public function __construct(OrderProductRepository $repository, PaginatorInterface $paginator) | ||||
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function filterByOrderShop(OrderShopInterface $orderShop): self | |||||
{ | |||||
return $this | |||||
->andWhere('.orderShop = :orderShop') | |||||
->setParameter('orderShop', $orderShop); | |||||
} | |||||
public function filterByProduct(ProductInterface $product): self | |||||
{ | |||||
return $this | |||||
->andWhere('.product = :product') | |||||
->setParameter('product', $product); | |||||
} | |||||
public function filterByUser(UserInterface $user): self | |||||
{ | |||||
$this->joinOrderShop(); | |||||
return $this | |||||
->andWhere('orderShop.user = :user') | |||||
->setParameter('user', $user); | |||||
} | |||||
public function filterBySection(SectionInterface $section): self | |||||
{ | |||||
$this->joinOrderShop(); | |||||
return $this->andWhereSection('orderShop', $section); | |||||
} | |||||
public function filterByOrderStatus(array $status): self | |||||
{ | |||||
$this->joinOrderStatus(); | |||||
return $this | |||||
->andWhere('os.alias IN (:alias)') | |||||
->setParameter('alias', $status); | |||||
} | |||||
public function selectCount(): self | |||||
{ | |||||
return $this | |||||
->select('count(r.id) as total'); | |||||
} | |||||
public function joinProduct(): self | |||||
{ | |||||
if (!$this->isJoinProduct) { | |||||
$this->isJoinProduct = true; | |||||
return $this | |||||
->leftJoin('.product', 'product'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinProductFamily(): self | |||||
{ | |||||
$this->joinProduct(); | |||||
if (!$this->isJoinProductFamily) { | |||||
$this->isJoinProductFamily = true; | |||||
return $this | |||||
->leftJoin('product.productFamily', 'productFamily'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinOrderShop(): self | |||||
{ | |||||
if (!$this->isJoinOrderShop) { | |||||
$this->isJoinOrderShop = true; | |||||
return $this | |||||
->leftJoin('.orderShop', 'orderShop'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinOrderStatus(): self | |||||
{ | |||||
$this->joinOrderShop(); | |||||
if (!$this->isJoinOrderStatus) { | |||||
$this->isJoinOrderStatus = true; | |||||
return $this | |||||
->leftJoin('orderShop.orderStatus', 'os'); | |||||
} | |||||
return $this; | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Repository\Order; | namespace Lc\CaracoleBundle\Repository\Order; | ||||
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
class OrderProductStore extends AbstractStore | class OrderProductStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | |||||
protected OrderProductRepositoryQuery $query; | protected OrderProductRepositoryQuery $query; | ||||
public function __construct(OrderProductRepositoryQuery $query) | public function __construct(OrderProductRepositoryQuery $query) | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterBySection($this->section); | |||||
return $query; | return $query; | ||||
} | } | ||||
{ | { | ||||
return $query; | return $query; | ||||
} | } | ||||
//findOrderProductsInCartsByProduct | |||||
public function getInCartsByProduct(ProductInterface $product, $query = null): array | |||||
{ | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->filterByProduct($product); | |||||
$query->filterByOrderStatus(OrderStatusModel::$statusAliasAsValid); | |||||
} | |||||
} | } |
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | ||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver; | use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver; | ||||
use Lc\CaracoleBundle\Statistic\Product\ProductsSalesStatistic; | |||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
OrderProductStore $orderProductStore, | OrderProductStore $orderProductStore, | ||||
MerchantStore $merchantStore, | MerchantStore $merchantStore, | ||||
FlashBagInterface $flashBag, | FlashBagInterface $flashBag, | ||||
OpeningResolver $openingResolver, | |||||
ParameterBagInterface $parameterBag, | ParameterBagInterface $parameterBag, | ||||
UrlGeneratorInterface $router, | UrlGeneratorInterface $router, | ||||
OrderShopSolver $orderShopSolver | OrderShopSolver $orderShopSolver | ||||
$this->orderProductStore = $orderProductStore; | $this->orderProductStore = $orderProductStore; | ||||
$this->merchantStore = $merchantStore; | $this->merchantStore = $merchantStore; | ||||
$this->flashBag = $flashBag; | $this->flashBag = $flashBag; | ||||
$this->openingResolver = $openingResolver; | |||||
$this->parameterBag = $parameterBag; | $this->parameterBag = $parameterBag; | ||||
$this->router = $router; | $this->router = $router; | ||||
$this->orderShopSolver = $orderShopSolver; | $this->orderShopSolver = $orderShopSolver; | ||||
return $reductionCartsArray; | return $reductionCartsArray; | ||||
} | } | ||||
public function countValidOrderProductsOfCyclesByProducts(array $cycleNumbers, array $products, $query =null): array | |||||
{ | |||||
$query = $this->createDefaultQuery($query); | |||||
$query | |||||
->filterByAlias(OrderStatusModel::$statusAliasAsValid) | |||||
->filterByCycleNumbers($cycleNumbers) | |||||
->filterByProducts($products) | |||||
->selectSum() | |||||
->groupBy('.cycleNumber, product.id'); | |||||
return $query->find(); | |||||
} | |||||
public function countValidOrderProductsOfCycleByProduct(int $cycleNumber, int $productId, $query =null): ?string | |||||
{ | |||||
$query = $this->createDefaultQuery($query); | |||||
$query | |||||
->filterByAlias(OrderStatusModel::$statusAliasAsValid) | |||||
->filterByCycleNumber($cycleNumber) | |||||
->filterByProduct($productId) | |||||
->selectSumQuantityOrder() | |||||
->groupBy('.cycleNumber, product.id'); | |||||
$result = $query->findOne(); | |||||
if ($result) { | |||||
return $result['quantity']; | |||||
} | |||||
return null; | |||||
} | |||||
} | } |
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | ||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; | ||||
class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery implements RepositoryQuery | |||||
class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | |||||
{ | { | ||||
protected bool $isJoinProductCategories; | protected bool $isJoinProductCategories; | ||||
protected bool $isJoinProducts; | protected bool $isJoinProducts; | ||||
->setParameter('now', $dateTime); | ->setParameter('now', $dateTime); | ||||
} | } | ||||
public function filterPropertyLargeVolume(): self | |||||
{ | |||||
return $this->andWhere('.propertyLargeVolume = 1'); | |||||
} | |||||
public function filterPropertyOrganicLabel(): self | |||||
public function filterIsOrganicLabel(): self | |||||
{ | { | ||||
return $this->andWhere('.propertyOrganicLabel IS NOT NULL'); | return $this->andWhere('.propertyOrganicLabel IS NOT NULL'); | ||||
} | } |
return $query->find(); | return $query->find(); | ||||
} | } | ||||
//getProductFamiliesLargeVolumes | |||||
public function getLargeVolumes($query = null) | |||||
{ | |||||
$query = $this->createDefaultQuery($query); | |||||
$query | |||||
->filterPropertyLargeVolume() | |||||
->filterIsOnline(); | |||||
return $query->find(); | |||||
} | |||||
//getProductFamiliesOrganics | //getProductFamiliesOrganics | ||||
public function getOrganics($query = null) | public function getOrganics($query = null) | ||||
{ | { |
protected ReductionCartRepositoryQuery $query; | protected ReductionCartRepositoryQuery $query; | ||||
protected ReductionCartSolver $reductionCartSolver; | protected ReductionCartSolver $reductionCartSolver; | ||||
protected PriceSolver $priceSolver; | protected PriceSolver $priceSolver; | ||||
protected FlashBagInterface $flashBag; | |||||
public function __construct( | public function __construct( | ||||
ReductionCartRepositoryQuery $query, | ReductionCartRepositoryQuery $query, | ||||
ReductionCartSolver $reductionCartSolver, | ReductionCartSolver $reductionCartSolver, | ||||
PriceSolver $priceSolver, | |||||
FlashBagInterface $flashBag, | |||||
PriceSolver $priceSolver | |||||
) { | ) { | ||||
$this->query = $query; | $this->query = $query; | ||||
$this->reductionCartSolver = $reductionCartSolver; | $this->reductionCartSolver = $reductionCartSolver; | ||||
$this->priceSolver = $priceSolver; | $this->priceSolver = $priceSolver; | ||||
$this->flashBag = $flashBag; | |||||
} | } | ||||
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface |
class OpeningResolver | class OpeningResolver | ||||
{ | { | ||||
const OPENING_CONTEXT_FRONTEND = 'frontend' ; | |||||
const OPENING_CONTEXT_BACKEND = 'backend' ; | |||||
protected array $messages = []; | protected array $messages = []; | ||||
protected SectionResolver $sectionResolver; | protected SectionResolver $sectionResolver; | ||||
protected Security $security; | protected Security $security; | ||||
{ | { | ||||
$this->messages[] = $message; | $this->messages[] = $message; | ||||
} | } | ||||
public function isOpenSaleOnlyComplementaryOrders(Section $section, UserInterface $user) | |||||
{ | |||||
// @TODO : ajouter une option dans les sections (permettre les commandes complémentaires ou non) | |||||
$orderShopsUser = $this->orderShopStore->setSection($section)->getByCurrentCycleAndUser($user); | |||||
return $this->isOpenSale($section, $user) | |||||
&& $this->isMaximumOrderCycleAchieved($section) | |||||
&& count($orderShopsUser) > 0; | |||||
} | |||||
} | } |
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | use Lc\CaracoleBundle\Model\File\DocumentInterface; | ||||
use Lc\CaracoleBundle\Model\File\DocumentModel; | use Lc\CaracoleBundle\Model\File\DocumentModel; | ||||
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopModel; | use Lc\CaracoleBundle\Model\Order\OrderShopModel; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | ||||
return false; | return false; | ||||
} | } | ||||
public function hasOrderProductAlreadyInCart( | |||||
OrderShopInterface $orderShop, | |||||
OrderProductInterface $orderProductTest | |||||
): ?OrderProductInterface { | |||||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||||
if ($orderProduct->getProduct() == $orderProductTest->getProduct()) { | |||||
return $orderProduct; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
public function isValid(OrderShopInterface $orderShop): bool | |||||
{ | |||||
if ($orderShop->getOrderStatus() && in_array( | |||||
$orderShop->getOrderStatus()->getAlias(), | |||||
OrderStatusModel::$statusAliasAsValid | |||||
) > 0) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
public function isCart(OrderShopInterface $orderShop): bool | |||||
{ | |||||
if ($orderShop->getOrderStatus() && in_array( | |||||
$orderShop->getOrderStatus()->getAlias(), | |||||
OrderStatusModel::$statusAliasAsCart | |||||
) > 0) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
// isOrderShopPositiveAmount | |||||
public function isPositiveAmount(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return $this->priceSolver->getTotalWithTax($orderShop) >= 0; | |||||
} | |||||
public function isPaid(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): bool | |||||
{ | |||||
$totalOrderPayments = $this->getTotalOrderPayments($orderShop, $mergeComplementaryOrderShop); | |||||
$totalOrder = $this->priceSolver->getTotalWithTax($orderShop); | |||||
if ((abs($totalOrderPayments - $totalOrder) < 0.00001 | |||||
|| $totalOrderPayments >= $totalOrder) | |||||
&& $totalOrder > 0) { | |||||
return true; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | |||||
// isOrderShopPositiveAmountRemainingToBePaid | |||||
public function isPositiveAmountRemainingToBePaid(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return $this->getTotalRemainingToBePaid($orderShop) > 0; | |||||
} | |||||
public function isCartAllowToBeOrder(OrderShopInterface $orderShop): bool | |||||
{ | |||||
return true; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Statistic\Product; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\CaracoleBundle\Repository\Order\OrderProductStore; | |||||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||||
use Lc\CaracoleBundle\Resolver\OpeningResolver; | |||||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||||
use Lc\CaracoleBundle\Statistic\Statistic; | |||||
class ProductsSalesStatistic extends Statistic | |||||
{ | |||||
protected int $nbCycle; | |||||
protected $productFamily; | |||||
protected $cycleNumbers = array(); | |||||
protected $productIds = array(); | |||||
public function __construct(EntityManagerInterface $entityManager, $productFamily, $nbCycle) | |||||
{ | |||||
parent::__construct($entityManager); | |||||
$this->nbCycle = $nbCycle; | |||||
$this->productFamily = $productFamily; | |||||
$this->createProperties(); | |||||
} | |||||
public function createProperties() | |||||
{ | |||||
$this->addProperty( | |||||
'total_sales', | |||||
[ | |||||
'label' => 'Total ventes' | |||||
] | |||||
); | |||||
foreach ($this->productFamily->getProducts() as $product) { | |||||
$this->productIds[$product->getId()] = $product; | |||||
$this->addProperty( | |||||
$product->getId(), | |||||
[ | |||||
'label' => $product->getTitle() | |||||
] | |||||
); | |||||
} | |||||
} | |||||
// Initialise les valeurs des données pour chaque Interval de date | |||||
public function init(SectionInterface $section, OrderShopSolver $orderShopSolver, OpeningResolver $openingResolver) | |||||
{ | |||||
$currentCycleNumber = $orderShopSolver->getCycleNumberCurrentOrder(); | |||||
if ($openingResolver->isOpenSale($section, null, null,OpeningResolver::OPENING_CONTEXT_BACKEND) == false && date('w') > 2) { | |||||
$currentCycleNumber = $currentCycleNumber - 1; | |||||
} | |||||
$this->cycleNumbers = array(); | |||||
for ($w = $currentCycleNumber - $this->nbCycle + 1; $w <= $currentCycleNumber; $w++) { | |||||
$this->cycleNumbers[] = $w; | |||||
$this->labels[$w] = 'S ' . $w; | |||||
foreach ($this->getProperties() as $propertyName => $property) { | |||||
$this->properties[$propertyName]['data'][$w] = 0; | |||||
} | |||||
foreach ($this->getAverageProperties() as $propertyName => $property) { | |||||
$this->averageProperties[$propertyName]['data'][$w] = 0; | |||||
} | |||||
} | |||||
} | |||||
public function populateProperties(OrderShopStore $orderShopStore) | |||||
{ | |||||
$countsOrderedByCyclesAndProducts = $orderShopStore->countValidOrderProductsOfCyclesByProducts( | |||||
$this->cycleNumbers, | |||||
$this->productIds | |||||
); | |||||
foreach ($countsOrderedByCyclesAndProducts as $result) { | |||||
$this->setData($result['productId'], $result['cycleNumber'], $result['quantity']); | |||||
$product = $this->productIds[$result['productId']]; | |||||
if ($this->productFamily->getBehaviorDisplaySale() == ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE) { | |||||
$ratioByMeasure = $product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient(); | |||||
$this->setData('total_sales', $result['cycleNumber'], intval($result['quantity']) * $ratioByMeasure); | |||||
} else { | |||||
$this->setData('total_sales', $result['cycleNumber'], intval($result['quantity'])); | |||||
} | |||||
} | |||||
$this->setAveragePropertiesData(); | |||||
} | |||||
} |