|
|
@@ -6,6 +6,7 @@ use common\helpers\GlobalParam; |
|
|
|
use common\helpers\Price; |
|
|
|
use common\logic\AbstractService; |
|
|
|
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\ProductPrice\Service\ProductPriceSolver; |
|
|
|
use common\logic\SolverInterface; |
|
|
@@ -13,10 +14,12 @@ use common\logic\SolverInterface; |
|
|
|
class ProductSolver extends AbstractService implements SolverInterface |
|
|
|
{ |
|
|
|
protected ProductPriceSolver $productPriceSolver; |
|
|
|
protected PointSaleSolver $pointSaleSolver; |
|
|
|
|
|
|
|
public function loadDependencies(): void |
|
|
|
{ |
|
|
|
$this->productPriceSolver = $this->loadService(ProductPriceSolver::class); |
|
|
|
$this->pointSaleSolver = $this->loadService(PointSaleSolver::class); |
|
|
|
} |
|
|
|
|
|
|
|
public function getPrice(Product $product, array $params = []): ?float |
|
|
@@ -211,4 +214,20 @@ class ProductSolver extends AbstractService implements SolverInterface |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |