|
|
@@ -39,7 +39,6 @@ use Lc\CaracoleBundle\Repository\Order\OrderShopStore; |
|
|
|
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore; |
|
|
|
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; |
|
|
|
use Lc\CaracoleBundle\Resolver\MerchantResolver; |
|
|
|
use Lc\CaracoleBundle\Resolver\OpeningResolver; |
|
|
|
use Lc\CaracoleBundle\Resolver\OrderShopResolver; |
|
|
|
use Lc\CaracoleBundle\Solver\Order\OrderProductReductionCatalogSolver; |
|
|
|
use Lc\CaracoleBundle\Solver\Order\OrderProductSolver; |
|
|
@@ -48,7 +47,7 @@ use Lc\CaracoleBundle\Solver\Price\PriceSolver; |
|
|
|
use Lc\CaracoleBundle\Solver\Product\ProductSolver; |
|
|
|
use Lc\CaracoleBundle\Statistic\Product\ProductsSalesStatistic; |
|
|
|
use Lc\SovBundle\Model\User\UserInterface; |
|
|
|
use Lc\SovBundle\Translation\FlashBagTranslator; |
|
|
|
|
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
|
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; |
|
|
|
|
|
|
@@ -65,14 +64,12 @@ class OrderShopBuilder |
|
|
|
protected DocumentBuilder $documentBuilder; |
|
|
|
protected EventDispatcherInterface $eventDispatcher; |
|
|
|
protected FlashBagInterface $flashBag; |
|
|
|
protected OpeningResolver $openingResolver; |
|
|
|
protected ProductSolver $productSolver; |
|
|
|
protected OrderShopResolver $orderShopResolver; |
|
|
|
protected OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver; |
|
|
|
protected DistributionBuilder $distributionBuilder; |
|
|
|
protected MerchantResolver $merchantResolver; |
|
|
|
protected CreditHistoryBuilder $creditHistoryBuilder; |
|
|
|
protected FlashBagTranslator $flashBagTranslator; |
|
|
|
protected OrderShopFactory $orderShopFactory; |
|
|
|
protected OrderProductSolver $orderProductSolver; |
|
|
|
|
|
|
@@ -88,14 +85,12 @@ class OrderShopBuilder |
|
|
|
PriceSolver $priceSolver, |
|
|
|
EventDispatcherInterface $eventDispatcher, |
|
|
|
FlashBagInterface $flashBag, |
|
|
|
OpeningResolver $openingResolver, |
|
|
|
ProductSolver $productSolver, |
|
|
|
OrderShopResolver $orderShopResolver, |
|
|
|
OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver, |
|
|
|
DistributionBuilder $distributionBuilder, |
|
|
|
MerchantResolver $merchantResolver, |
|
|
|
CreditHistoryBuilder $creditHistoryBuilder, |
|
|
|
FlashBagTranslator $flashBagTranslator, |
|
|
|
OrderShopFactory $orderShopFactory, |
|
|
|
OrderProductSolver $orderProductSolver |
|
|
|
) { |
|
|
@@ -110,14 +105,12 @@ class OrderShopBuilder |
|
|
|
$this->priceSolver = $priceSolver; |
|
|
|
$this->eventDispatcher = $eventDispatcher; |
|
|
|
$this->flashBag = $flashBag; |
|
|
|
$this->openingResolver = $openingResolver; |
|
|
|
$this->productSolver = $productSolver; |
|
|
|
$this->orderShopResolver = $orderShopResolver; |
|
|
|
$this->orderProductReductionCatalogSolver = $orderProductReductionCatalogSolver; |
|
|
|
$this->distributionBuilder = $distributionBuilder; |
|
|
|
$this->merchantResolver = $merchantResolver; |
|
|
|
$this->creditHistoryBuilder = $creditHistoryBuilder; |
|
|
|
$this->flashBagTranslator = $flashBagTranslator; |
|
|
|
$this->orderShopFactory = $orderShopFactory; |
|
|
|
$this->orderProductSolver = $orderProductSolver; |
|
|
|
} |
|
|
@@ -541,50 +534,35 @@ class OrderShopBuilder |
|
|
|
$this->entityManager->flush(); |
|
|
|
} |
|
|
|
|
|
|
|
public function updatePriceByProductFamily(ProductFamilyInterface $productFamily) |
|
|
|
public function updatePriceByProductFamily(ProductFamilyInterface $productFamily, SectionInterface $section) |
|
|
|
{ |
|
|
|
$debug = ''; |
|
|
|
|
|
|
|
foreach ($this->merchantResolver->getCurrent()->getSections() as $section) { |
|
|
|
// @TODO : faire la vérification isOpenSale depuis la méthode appelante |
|
|
|
if (!$this->openingResolver->isOpenSale($section)) { |
|
|
|
$countOrderProductUpdated = 0; |
|
|
|
$countOrderProductUpdated = 0; |
|
|
|
|
|
|
|
foreach ($productFamily->getProducts() as $product) { |
|
|
|
$orderProducts = $this->orderProductStore->resetContext()->setSection( |
|
|
|
$section |
|
|
|
)->getInCartsByProduct($product); |
|
|
|
foreach ($productFamily->getProducts() as $product) { |
|
|
|
$orderProducts = $this->orderProductStore->resetContext()->setSection( |
|
|
|
$section |
|
|
|
)->getInCartsByProduct($product); |
|
|
|
|
|
|
|
foreach ($orderProducts as $orderProduct) { |
|
|
|
$quantityOrder = $orderProduct->getQuantityOrder(); |
|
|
|
$orderShop = $orderProduct->getOrderShop(); |
|
|
|
foreach ($orderProducts as $orderProduct) { |
|
|
|
$quantityOrder = $orderProduct->getQuantityOrder(); |
|
|
|
$orderShop = $orderProduct->getOrderShop(); |
|
|
|
|
|
|
|
$orderShop->removeOrderProduct($orderProduct); |
|
|
|
$this->entityManager->delete($orderProduct); |
|
|
|
$this->entityManager->flush(); |
|
|
|
$this->entityManager->refresh($orderShop); |
|
|
|
$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); |
|
|
|
$orderProductFactory = new OrderProductFactory(); |
|
|
|
$addOrderProduct = $orderProductFactory->create($product, $quantityOrder); |
|
|
|
$this->addOrderProduct($orderShop, $addOrderProduct); |
|
|
|
|
|
|
|
$countOrderProductUpdated++; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($countOrderProductUpdated) { |
|
|
|
$this->flashBagTranslator->add( |
|
|
|
'success', |
|
|
|
'orderProductUpdated', |
|
|
|
'OrderShop', |
|
|
|
//array('%count%' => $countOrderProductUpdated) |
|
|
|
['%count' => $debug] |
|
|
|
); |
|
|
|
|
|
|
|
$this->entityManager->flush(); |
|
|
|
} |
|
|
|
return $countOrderProductUpdated; |
|
|
|
$countOrderProductUpdated++; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($countOrderProductUpdated) { |
|
|
|
$this->entityManager->flush(); |
|
|
|
} |
|
|
|
return $countOrderProductUpdated; |
|
|
|
} |
|
|
|
|
|
|
|
|