Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

242 lines
6.0KB

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