ReductionCart.php 5.4KB

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