Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

58 lines
1.6KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\Reduction;
  3. use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
  4. use Lc\CaracoleBundle\Model\Reduction\ReductionCartModel;
  5. use Lc\SovBundle\Model\User\UserInterface;
  6. class ReductionCartSolver
  7. {
  8. // isReductionCartMatchWithUser
  9. public function matchWithUser(ReductionCartInterface $reductionCart, UserInterface $user)
  10. {
  11. $conditionUser = false;
  12. if ($user) {
  13. if ($reductionCart->getUsers()->isEmpty() || $reductionCart->getUsers()->contains($user)) {
  14. $conditionUser = true;
  15. }
  16. }
  17. return $conditionUser;
  18. }
  19. // isReductionCartMatchWithGroupUser
  20. public function matchWithGroupUser(ReductionCartInterface $reductionCart, UserInterface $user)
  21. {
  22. $conditionGroupUser = false;
  23. if ($user) {
  24. if ($user->getGroupUsers() && count($user->getGroupUsers()) > 0) {
  25. foreach ($user->getGroupUsers() as $groupUser) {
  26. if ($reductionCart->getGroupUsers()->isEmpty() || $reductionCart->getGroupUsers()->contains($groupUser)) {
  27. $conditionGroupUser = true;
  28. }
  29. }
  30. } else {
  31. if ($reductionCart->getGroupUsers()->isEmpty()) {
  32. $conditionGroupUser = true;
  33. }
  34. }
  35. }
  36. return $conditionGroupUser;
  37. }
  38. public static function getAppliedToChoices()
  39. {
  40. return [
  41. // ReductionCartModel::APPLIED_TO_DELIVERY,
  42. ReductionCartModel::APPLIED_TO_ORDER_PRODUCTS,
  43. ];
  44. }
  45. }