您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

78 行
2.7KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Product;
  3. use App\Solver\Product\ProductFamilySectionPropertySolver;
  4. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  5. use Lc\CaracoleBundle\Repository\AbstractStore;
  6. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  7. class ProductStore extends AbstractStore
  8. {
  9. use SectionStoreTrait;
  10. protected ProductRepositoryQuery $query;
  11. protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;
  12. public function __construct(ProductRepositoryQuery $query, ProductFamilySectionPropertySolver $productFamilySectionPropertySolver)
  13. {
  14. $this->query = $query;
  15. $this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
  16. }
  17. public function orderByDefault(RepositoryQueryInterface $query) :RepositoryQueryInterface
  18. {
  19. return $query;
  20. }
  21. public function filtersDefault($query):RepositoryQueryInterface
  22. {
  23. $this->addFilterBySectionOptionnal($query);
  24. $query->filterIsOnlineAndOffline();
  25. return $query;
  26. }
  27. public function relationsDefault($query):RepositoryQueryInterface
  28. {
  29. return $query->joinProductFamily();
  30. }
  31. //findProductByAvailabilitiesNegative
  32. public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array
  33. {
  34. $query = $this->createQuery($query);
  35. $query->joinProductFamily();
  36. $query->filterIsOnline();
  37. $query->filterAvailableQuantityNegative();
  38. $query->groupBy('productFamily.id');
  39. $productListAvailableQuantityNegative = $query->find();
  40. foreach ($productListAvailableQuantityNegative as $i=>$product) {
  41. if(!$this->productFamilySectionPropertySolver->useBehaviorStockAvailableQuantity($product->getProductfamily())){
  42. unset($productListAvailableQuantityNegative[$i]);
  43. }
  44. }
  45. return $productListAvailableQuantityNegative;
  46. }
  47. public function getByAvailabilitiesSupplierNegative(ProductRepositoryQuery $query = null): array
  48. {
  49. $query = $this->createQuery($query);
  50. $query->joinProductFamily();
  51. $query->filterIsOnline();
  52. $query->filterAvailableQuantitySupplierNegative();
  53. $query->groupBy('productFamily.id');
  54. $productListAvailableQuantityNegative = $query->find();
  55. foreach ($productListAvailableQuantityNegative as $i=>$product) {
  56. if(!$this->productFamilySectionPropertySolver->useBehaviorStockAvailableQuantitySupplier($product->getProductfamily())){
  57. unset($productListAvailableQuantityNegative[$i]);
  58. }
  59. }
  60. return $productListAvailableQuantityNegative;
  61. }
  62. }