|
|
@@ -3,9 +3,12 @@ |
|
|
|
namespace Lc\CaracoleBundle\Builder\Order; |
|
|
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
use Lc\CaracoleBundle\Factory\Order\OrderProductReductionCatalogFactory; |
|
|
|
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; |
|
|
|
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; |
|
|
|
use Lc\CaracoleBundle\Model\Section\SectionInterface; |
|
|
|
use Lc\CaracoleBundle\Repository\Order\OrderProductStore; |
|
|
|
use Lc\CaracoleBundle\Resolver\Price\PriceResolver; |
|
|
|
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; |
|
|
|
use Lc\CaracoleBundle\Solver\Order\OrderProductSolver; |
|
|
|
use Lc\CaracoleBundle\Solver\Price\PriceSolver; |
|
|
|
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver; |
|
|
@@ -19,6 +22,8 @@ class OrderProductBuilder |
|
|
|
protected ProductSolver $productSolver; |
|
|
|
protected ProductFamilySolver $productFamilySolver; |
|
|
|
protected OrderProductSolver $orderProductSolver; |
|
|
|
protected OrderProductReductionCatalogFactory $orderProductReductionCatalogFactory; |
|
|
|
protected ProductFamilyStore $productFamilyStore; |
|
|
|
|
|
|
|
public function __construct( |
|
|
|
EntityManagerInterface $entityManager, |
|
|
@@ -26,7 +31,9 @@ class OrderProductBuilder |
|
|
|
OrderProductStore $orderProductStore, |
|
|
|
ProductSolver $productSolver, |
|
|
|
OrderProductSolver $orderProductSolver, |
|
|
|
ProductFamilySolver $productFamilySolver |
|
|
|
ProductFamilySolver $productFamilySolver, |
|
|
|
OrderProductReductionCatalogFactory $orderProductReductionCatalogFactory, |
|
|
|
ProductFamilyStore $productFamilyStore |
|
|
|
) { |
|
|
|
$this->entityManager = $entityManager; |
|
|
|
$this->priceSolver = $priceSolver; |
|
|
@@ -34,6 +41,8 @@ class OrderProductBuilder |
|
|
|
$this->productSolver = $productSolver; |
|
|
|
$this->orderProductSolver = $orderProductSolver; |
|
|
|
$this->productFamilySolver = $productFamilySolver; |
|
|
|
$this->orderProductReductionCatalogFactory = $orderProductReductionCatalogFactory; |
|
|
|
$this->productFamilyStore = $productFamilyStore; |
|
|
|
} |
|
|
|
|
|
|
|
public function init(OrderProductInterface $orderProduct) :OrderProductInterface |
|
|
@@ -47,4 +56,27 @@ class OrderProductBuilder |
|
|
|
|
|
|
|
return $orderProduct; |
|
|
|
} |
|
|
|
|
|
|
|
public function initReductionCatalog(SectionInterface $section, OrderProductInterface $orderProduct, ProductFamilyInterface $productFamily = null): OrderProductInterface |
|
|
|
{ |
|
|
|
if(is_null($productFamily)) { |
|
|
|
$productFamily = $this->productFamilyStore->setSection($section)->getOneBySlug( |
|
|
|
$orderProduct->getProduct()->getProductFamily()->getSlug() |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
$reductionCatalog = $productFamily->getReductionCatalog(); |
|
|
|
if ($reductionCatalog && $reductionCatalog->getStatus()) { |
|
|
|
$orderProductReductionCatalog = $this->orderProductReductionCatalogFactory->create( |
|
|
|
$reductionCatalog->getTitle(), |
|
|
|
$reductionCatalog->getValue(), |
|
|
|
$reductionCatalog->getUnit(), |
|
|
|
$reductionCatalog->getBehaviorTaxRate() |
|
|
|
); |
|
|
|
|
|
|
|
$orderProduct->setOrderProductReductionCatalog($orderProductReductionCatalog); |
|
|
|
} |
|
|
|
|
|
|
|
return $orderProduct; |
|
|
|
} |
|
|
|
} |