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

58 行
1.6KB

  1. <?php
  2. namespace domain\PointSale\UserPointSale;
  3. use domain\Distribution\Distribution\Distribution;
  4. use domain\PointSale\PointSale\PointSale;
  5. use domain\PointSale\PointSale\PointSaleSolver;
  6. use domain\User\User\User;
  7. use domain\_\AbstractRepository;
  8. class UserPointSaleRepository extends AbstractRepository
  9. {
  10. protected UserPointSaleRepositoryQuery $query;
  11. protected PointSaleSolver $pointSaleSolver;
  12. public function loadDependencies(): void
  13. {
  14. $this->loadQuery(UserPointSaleRepositoryQuery::class);
  15. $this->pointSaleSolver = $this->loadService(PointSaleSolver::class);
  16. }
  17. public function getDefaultOptionsSearch(): array
  18. {
  19. return [
  20. self::WITH => [],
  21. self::JOIN_WITH => [],
  22. self::ORDER_BY => '',
  23. self::ATTRIBUTE_ID_PRODUCER => 'point_sale.id_producer'
  24. ] ;
  25. }
  26. public function findUserPointSalesByUser(User $user, Distribution $distribution = null): array
  27. {
  28. $userPointSalesArray = $this->createDefaultQuery()
  29. ->joinPointSale()
  30. ->filterByUser($user)
  31. ->find();
  32. if($distribution) {
  33. $userPointSalesArray = $this->pointSaleSolver->filterUserPointSalesByDistribution($userPointSalesArray, $distribution);
  34. }
  35. return $userPointSalesArray;
  36. }
  37. public function findOneUserPointSale(User $user = null, PointSale $pointSale = null)
  38. {
  39. if(!$user || !$pointSale) {
  40. return null;
  41. }
  42. return $this->createDefaultQuery()
  43. ->joinPointSale()
  44. ->filterByUser($user)
  45. ->filterByPointSale($pointSale)
  46. ->findOne();
  47. }
  48. }