|
|
|
|
|
|
|
|
namespace Lc\CaracoleBundle\Builder\Order; |
|
|
namespace Lc\CaracoleBundle\Builder\Order; |
|
|
|
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
|
use Lc\CaracoleBundle\Factory\Order\OrderProductReductionCatalogFactory; |
|
|
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; |
|
|
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\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\Order\OrderProductSolver; |
|
|
use Lc\CaracoleBundle\Solver\Price\PriceSolver; |
|
|
use Lc\CaracoleBundle\Solver\Price\PriceSolver; |
|
|
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver; |
|
|
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver; |
|
|
|
|
|
|
|
|
protected ProductSolver $productSolver; |
|
|
protected ProductSolver $productSolver; |
|
|
protected ProductFamilySolver $productFamilySolver; |
|
|
protected ProductFamilySolver $productFamilySolver; |
|
|
protected OrderProductSolver $orderProductSolver; |
|
|
protected OrderProductSolver $orderProductSolver; |
|
|
|
|
|
protected OrderProductReductionCatalogFactory $orderProductReductionCatalogFactory; |
|
|
|
|
|
protected ProductFamilyStore $productFamilyStore; |
|
|
|
|
|
|
|
|
public function __construct( |
|
|
public function __construct( |
|
|
EntityManagerInterface $entityManager, |
|
|
EntityManagerInterface $entityManager, |
|
|
|
|
|
|
|
|
OrderProductStore $orderProductStore, |
|
|
OrderProductStore $orderProductStore, |
|
|
ProductSolver $productSolver, |
|
|
ProductSolver $productSolver, |
|
|
OrderProductSolver $orderProductSolver, |
|
|
OrderProductSolver $orderProductSolver, |
|
|
ProductFamilySolver $productFamilySolver |
|
|
|
|
|
|
|
|
ProductFamilySolver $productFamilySolver, |
|
|
|
|
|
OrderProductReductionCatalogFactory $orderProductReductionCatalogFactory, |
|
|
|
|
|
ProductFamilyStore $productFamilyStore |
|
|
) { |
|
|
) { |
|
|
$this->entityManager = $entityManager; |
|
|
$this->entityManager = $entityManager; |
|
|
$this->priceSolver = $priceSolver; |
|
|
$this->priceSolver = $priceSolver; |
|
|
|
|
|
|
|
|
$this->productSolver = $productSolver; |
|
|
$this->productSolver = $productSolver; |
|
|
$this->orderProductSolver = $orderProductSolver; |
|
|
$this->orderProductSolver = $orderProductSolver; |
|
|
$this->productFamilySolver = $productFamilySolver; |
|
|
$this->productFamilySolver = $productFamilySolver; |
|
|
|
|
|
$this->orderProductReductionCatalogFactory = $orderProductReductionCatalogFactory; |
|
|
|
|
|
$this->productFamilyStore = $productFamilyStore; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function init(OrderProductInterface $orderProduct) :OrderProductInterface |
|
|
public function init(OrderProductInterface $orderProduct) :OrderProductInterface |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $orderProduct; |
|
|
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; |
|
|
|
|
|
} |
|
|
} |
|
|
} |