Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ReductionCartModel.php 7.1KB

pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Reduction;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
  7. use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinInterface;
  8. use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinTrait;
  9. use Lc\CaracoleBundle\Doctrine\Extension\ReductionCartPropertyInterface;
  10. use Lc\CaracoleBundle\Doctrine\Extension\ReductionCartPropertyTrait;
  11. use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface;
  12. use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyTrait;
  13. use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
  14. use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface;
  15. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  16. use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
  17. use Lc\SovBundle\Doctrine\Extension\StatusInterface;
  18. use Lc\SovBundle\Doctrine\Extension\StatusTrait;
  19. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  20. use Lc\SovBundle\Model\User\UserInterface;
  21. /**
  22. * @ORM\MappedSuperclass()
  23. */
  24. abstract class ReductionCartModel extends AbstractLightEntity implements ReductionPropertyInterface, ReductionInterface,
  25. ReductionCartPropertyInterface,
  26. FilterMerchantInterface,
  27. OrderAmountMinInterface, StatusInterface
  28. {
  29. const APPLIED_TO_DELIVERY = 'delivery';
  30. const APPLIED_TO_ORDER_PRODUCTS = 'order-products';
  31. use StatusTrait;
  32. use OrderAmountMinTrait;
  33. use ReductionTrait;
  34. use ReductionCartPropertyTrait;
  35. use ReductionPropertyTrait {
  36. ReductionPropertyTrait::__construct as private __reductionPropertyConstruct;
  37. }
  38. /**
  39. * @ORM\Column(type="string", length=255)
  40. */
  41. protected $title;
  42. /**
  43. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
  44. * @ORM\JoinColumn(nullable=false)
  45. */
  46. protected $merchant;
  47. /**
  48. * @ORM\Column(type="array", nullable=true)
  49. */
  50. protected $codes = [];
  51. /**
  52. * @ORM\Column(type="integer")
  53. */
  54. protected $availableQuantity;
  55. /**
  56. * @ORM\Column(type="integer")
  57. */
  58. protected $availableQuantityPerUser;
  59. /**
  60. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleInterface")
  61. */
  62. protected $pointSales;
  63. /**
  64. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface")
  65. */
  66. protected $uncombinables;
  67. /**
  68. * @ORM\Column(type="array", nullable=true)
  69. */
  70. protected $uncombinableTypes = [];
  71. /**
  72. * @ORM\Column(type="integer", nullable=true)
  73. */
  74. protected $availableQuantityPerCode;
  75. public function __toString()
  76. {
  77. return $this->title;
  78. }
  79. public function __construct()
  80. {
  81. $this->__reductionPropertyConstruct();
  82. $this->pointSales = new ArrayCollection();
  83. $this->uncombinables = new ArrayCollection();
  84. }
  85. // isReductionCartMatchWithUser
  86. public function matchWithUser(UserInterface $user)
  87. {
  88. $conditionUser = false;
  89. if ($user) {
  90. if ($this->getUsers()->isEmpty() || $this->getUsers()->contains($user)) {
  91. $conditionUser = true;
  92. }
  93. }
  94. return $conditionUser;
  95. }
  96. // isReductionCartMatchWithGroupUser
  97. public function matchWithGroupUser(UserInterface $user)
  98. {
  99. $conditionGroupUser = false;
  100. if ($user) {
  101. if ($user->getGroupUsers() && count($user->getGroupUsers()) > 0) {
  102. foreach ($user->getGroupUsers() as $groupUser) {
  103. if ($this->getGroupUsers()->isEmpty() || $this->getGroupUsers()->contains($groupUser)) {
  104. $conditionGroupUser = true;
  105. }
  106. }
  107. } else {
  108. if ($reductionCart->getGroupUsers()->isEmpty()) {
  109. $conditionGroupUser = true;
  110. }
  111. }
  112. }
  113. return $conditionGroupUser;
  114. }
  115. public function getTitle(): ?string
  116. {
  117. return $this->title;
  118. }
  119. public function setTitle(string $title): self
  120. {
  121. $this->title = $title;
  122. return $this;
  123. }
  124. public function getMerchant(): ?MerchantInterface
  125. {
  126. return $this->merchant;
  127. }
  128. public function setMerchant(?MerchantInterface $merchant): self
  129. {
  130. $this->merchant = $merchant;
  131. return $this;
  132. }
  133. public function getCodes(): ?array
  134. {
  135. return $this->codes;
  136. }
  137. public function setCodes(?array $codes): self
  138. {
  139. $this->codes = $codes;
  140. return $this;
  141. }
  142. /**
  143. * @return Collection|PointSaleInterface[]
  144. */
  145. public function getPointSales(): Collection
  146. {
  147. return $this->pointSales;
  148. }
  149. public function addPointSale(PointSaleInterface $pointSale): self
  150. {
  151. if (!$this->pointSales->contains($pointSale)) {
  152. $this->pointSales[] = $pointSale;
  153. }
  154. return $this;
  155. }
  156. public function removePointSale(PointSaleInterface $pointSale): self
  157. {
  158. if ($this->pointSales->contains($pointSale)) {
  159. $this->pointSales->removeElement($pointSale);
  160. }
  161. return $this;
  162. }
  163. public function getAvailableQuantity(): ?int
  164. {
  165. return $this->availableQuantity;
  166. }
  167. public function setAvailableQuantity(int $availableQuantity): self
  168. {
  169. $this->availableQuantity = $availableQuantity;
  170. return $this;
  171. }
  172. public function getAvailableQuantityPerUser(): ?int
  173. {
  174. return $this->availableQuantityPerUser;
  175. }
  176. public function setAvailableQuantityPerUser(int $availableQuantityPerUser): self
  177. {
  178. $this->availableQuantityPerUser = $availableQuantityPerUser;
  179. return $this;
  180. }
  181. /**
  182. * @return Collection|self[]
  183. */
  184. public function getUncombinables(): Collection
  185. {
  186. return $this->uncombinables;
  187. }
  188. public function addUncombinable(self $uncombinable): self
  189. {
  190. if (!$this->uncombinables->contains($uncombinable)) {
  191. $this->uncombinables[] = $uncombinable;
  192. }
  193. return $this;
  194. }
  195. public function removeUncombinables(self $uncombinable): self
  196. {
  197. if ($this->uncombinables->contains($uncombinable)) {
  198. $this->uncombinables->removeElement($uncombinable);
  199. }
  200. return $this;
  201. }
  202. public function getUncombinableTypes(): ?array
  203. {
  204. return $this->uncombinableTypes;
  205. }
  206. public function setUncombinableTypes(?array $uncombinableTypes): self
  207. {
  208. $this->uncombinableTypes = $uncombinableTypes;
  209. return $this;
  210. }
  211. public function getAvailableQuantityPerCode(): ?int
  212. {
  213. return $this->availableQuantityPerCode;
  214. }
  215. public function setAvailableQuantityPerCode(int $availableQuantityPerCode): self
  216. {
  217. $this->availableQuantityPerCode = $availableQuantityPerCode;
  218. return $this;
  219. }
  220. }