ReductionCart.php 5.5KB

4 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\ShopBundle\Context\FilterMerchantInterface;
  7. use Lc\ShopBundle\Context\OrderAmountMinInterface;
  8. use Lc\ShopBundle\Context\ReductionCartPropertyInterface;
  9. use Lc\ShopBundle\Context\ReductionInterface;
  10. use Lc\ShopBundle\Context\ReductionPropertyInterface;
  11. use Lc\ShopBundle\Context\StatusInterface;
  12. /**
  13. * @ORM\MappedSuperclass()
  14. */
  15. abstract class ReductionCart extends AbstractEntity implements ReductionPropertyInterface, ReductionInterface, ReductionCartPropertyInterface, FilterMerchantInterface, OrderAmountMinInterface, StatusInterface
  16. {
  17. const APPLIED_TO_DELIVERY = 'delivery';
  18. const APPLIED_TO_ORDER_PRODUCTS = 'order-products';
  19. use StatusTrait;
  20. use OrderAmountMin;
  21. use ReductionTrait;
  22. use ReductionCartPropertyTrait;
  23. use ReductionPropertyTrait {
  24. ReductionPropertyTrait::__construct as private __reductionPropertyConstruct;
  25. }
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. */
  29. protected $title;
  30. /**
  31. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  32. * @ORM\JoinColumn(nullable=false)
  33. */
  34. protected $merchant;
  35. /**
  36. * @ORM\Column(type="array", nullable=true)
  37. */
  38. protected $codes = [];
  39. /**
  40. * @ORM\Column(type="integer")
  41. */
  42. protected $availableQuantity;
  43. /**
  44. * @ORM\Column(type="integer")
  45. */
  46. protected $availableQuantityPerUser;
  47. /**
  48. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\PointSaleInterface")
  49. */
  50. protected $pointSales;
  51. /**
  52. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ReductionCartInterface")
  53. */
  54. protected $uncombinables;
  55. /**
  56. * @ORM\Column(type="array", nullable=true)
  57. */
  58. protected $uncombinableTypes = [];
  59. public function __toString()
  60. {
  61. return $this->title;
  62. }
  63. public function __construct()
  64. {
  65. $this->__reductionPropertyConstruct();
  66. $this->pointSales = new ArrayCollection();
  67. $this->uncombinables = new ArrayCollection();
  68. }
  69. public function getTitle(): ?string
  70. {
  71. return $this->title;
  72. }
  73. public function setTitle(string $title): self
  74. {
  75. $this->title = $title;
  76. return $this;
  77. }
  78. public function getMerchant(): ?Merchant
  79. {
  80. return $this->merchant;
  81. }
  82. public function setMerchant(?Merchant $merchant): self
  83. {
  84. $this->merchant = $merchant;
  85. return $this;
  86. }
  87. public function getCodes(): ?array
  88. {
  89. return $this->codes;
  90. }
  91. public function setCodes(?array $codes): self
  92. {
  93. $this->codes = $codes;
  94. return $this;
  95. }
  96. /**
  97. * @return Collection|PointSale[]
  98. */
  99. public function getPointSales(): Collection
  100. {
  101. return $this->pointSales;
  102. }
  103. public function addPointSale(PointSale $pointSale): self
  104. {
  105. if (!$this->pointSales->contains($pointSale)) {
  106. $this->pointSales[] = $pointSale;
  107. }
  108. return $this;
  109. }
  110. public function removePointSale(PointSale $pointSale): self
  111. {
  112. if ($this->pointSales->contains($pointSale)) {
  113. $this->pointSales->removeElement($pointSale);
  114. }
  115. return $this;
  116. }
  117. public function getAvailableQuantity(): ?int
  118. {
  119. return $this->availableQuantity;
  120. }
  121. public function setAvailableQuantity(int $availableQuantity): self
  122. {
  123. $this->availableQuantity = $availableQuantity;
  124. return $this;
  125. }
  126. public function getAvailableQuantityPerUser(): ?int
  127. {
  128. return $this->availableQuantityPerUser;
  129. }
  130. public function setAvailableQuantityPerUser(int $availableQuantityPerUser): self
  131. {
  132. $this->availableQuantityPerUser = $availableQuantityPerUser;
  133. return $this;
  134. }
  135. /**
  136. * @return Collection|self[]
  137. */
  138. public function getUncombinables(): Collection
  139. {
  140. return $this->uncombinables;
  141. }
  142. public function addUncombinable(self $uncombinable): self
  143. {
  144. if (!$this->uncombinables->contains($uncombinable)) {
  145. $this->uncombinables[] = $uncombinable;
  146. }
  147. return $this;
  148. }
  149. public function removeUncombinables(self $uncombinable): self
  150. {
  151. if ($this->uncombinables->contains($uncombinable)) {
  152. $this->uncombinables->removeElement($uncombinable);
  153. }
  154. return $this;
  155. }
  156. public function getUncombinableTypes(): ?array
  157. {
  158. return $this->uncombinableTypes;
  159. }
  160. public function setUncombinableTypes(?array $uncombinableTypes): self
  161. {
  162. $this->uncombinableTypes = $uncombinableTypes;
  163. return $this;
  164. }
  165. }