Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

229 lines
5.9KB

  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. /**
  60. * @ORM\Column(type="integer")
  61. */
  62. protected $availableQuantityPerCode;
  63. public function __toString()
  64. {
  65. return $this->title;
  66. }
  67. public function __construct()
  68. {
  69. $this->__reductionPropertyConstruct();
  70. $this->pointSales = new ArrayCollection();
  71. $this->uncombinables = new ArrayCollection();
  72. }
  73. public function getTitle(): ?string
  74. {
  75. return $this->title;
  76. }
  77. public function setTitle(string $title): self
  78. {
  79. $this->title = $title;
  80. return $this;
  81. }
  82. public function getMerchant(): ?Merchant
  83. {
  84. return $this->merchant;
  85. }
  86. public function setMerchant(?Merchant $merchant): self
  87. {
  88. $this->merchant = $merchant;
  89. return $this;
  90. }
  91. public function getCodes(): ?array
  92. {
  93. return $this->codes;
  94. }
  95. public function setCodes(?array $codes): self
  96. {
  97. $this->codes = $codes;
  98. return $this;
  99. }
  100. /**
  101. * @return Collection|PointSale[]
  102. */
  103. public function getPointSales(): Collection
  104. {
  105. return $this->pointSales;
  106. }
  107. public function addPointSale(PointSale $pointSale): self
  108. {
  109. if (!$this->pointSales->contains($pointSale)) {
  110. $this->pointSales[] = $pointSale;
  111. }
  112. return $this;
  113. }
  114. public function removePointSale(PointSale $pointSale): self
  115. {
  116. if ($this->pointSales->contains($pointSale)) {
  117. $this->pointSales->removeElement($pointSale);
  118. }
  119. return $this;
  120. }
  121. public function getAvailableQuantity(): ?int
  122. {
  123. return $this->availableQuantity;
  124. }
  125. public function setAvailableQuantity(int $availableQuantity): self
  126. {
  127. $this->availableQuantity = $availableQuantity;
  128. return $this;
  129. }
  130. public function getAvailableQuantityPerUser(): ?int
  131. {
  132. return $this->availableQuantityPerUser;
  133. }
  134. public function setAvailableQuantityPerUser(int $availableQuantityPerUser): self
  135. {
  136. $this->availableQuantityPerUser = $availableQuantityPerUser;
  137. return $this;
  138. }
  139. /**
  140. * @return Collection|self[]
  141. */
  142. public function getUncombinables(): Collection
  143. {
  144. return $this->uncombinables;
  145. }
  146. public function addUncombinable(self $uncombinable): self
  147. {
  148. if (!$this->uncombinables->contains($uncombinable)) {
  149. $this->uncombinables[] = $uncombinable;
  150. }
  151. return $this;
  152. }
  153. public function removeUncombinables(self $uncombinable): self
  154. {
  155. if ($this->uncombinables->contains($uncombinable)) {
  156. $this->uncombinables->removeElement($uncombinable);
  157. }
  158. return $this;
  159. }
  160. public function getUncombinableTypes(): ?array
  161. {
  162. return $this->uncombinableTypes;
  163. }
  164. public function setUncombinableTypes(?array $uncombinableTypes): self
  165. {
  166. $this->uncombinableTypes = $uncombinableTypes;
  167. return $this;
  168. }
  169. public function getAvailableQuantityPerCode(): ?int
  170. {
  171. return $this->availableQuantityPerCode;
  172. }
  173. public function setAvailableQuantityPerCode(int $availableQuantityPerCode): self
  174. {
  175. $this->availableQuantityPerCode = $availableQuantityPerCode;
  176. return $this;
  177. }
  178. }