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.

242 rindas
6.1KB

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