|
|
|
|
|
|
|
|
use common\helpers\Price; |
|
|
use common\helpers\Price; |
|
|
use common\logic\AbstractService; |
|
|
use common\logic\AbstractService; |
|
|
use common\logic\PointSale\PointSale\Model\PointSale; |
|
|
use common\logic\PointSale\PointSale\Model\PointSale; |
|
|
|
|
|
use common\logic\PointSale\PointSale\Service\PointSaleSolver; |
|
|
use common\logic\Product\Product\Model\Product; |
|
|
use common\logic\Product\Product\Model\Product; |
|
|
use common\logic\Product\ProductPrice\Service\ProductPriceSolver; |
|
|
use common\logic\Product\ProductPrice\Service\ProductPriceSolver; |
|
|
use common\logic\SolverInterface; |
|
|
use common\logic\SolverInterface; |
|
|
|
|
|
|
|
|
class ProductSolver extends AbstractService implements SolverInterface |
|
|
class ProductSolver extends AbstractService implements SolverInterface |
|
|
{ |
|
|
{ |
|
|
protected ProductPriceSolver $productPriceSolver; |
|
|
protected ProductPriceSolver $productPriceSolver; |
|
|
|
|
|
protected PointSaleSolver $pointSaleSolver; |
|
|
|
|
|
|
|
|
public function loadDependencies(): void |
|
|
public function loadDependencies(): void |
|
|
{ |
|
|
{ |
|
|
$this->productPriceSolver = $this->loadService(ProductPriceSolver::class); |
|
|
$this->productPriceSolver = $this->loadService(ProductPriceSolver::class); |
|
|
|
|
|
$this->pointSaleSolver = $this->loadService(PointSaleSolver::class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getPrice(Product $product, array $params = []): ?float |
|
|
public function getPrice(Product $product, array $params = []): ?float |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $quantityMax; |
|
|
return $quantityMax; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function isPublic(Product $product): bool |
|
|
|
|
|
{ |
|
|
|
|
|
if($product->available_on_points_sale) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
foreach($product->productPointSale as $productPointSale) { |
|
|
|
|
|
if($productPointSale->pointSale && $this->pointSaleSolver->isPublic($productPointSale->pointSale)) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |