You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReductionCartModel.php 6.3KB

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