Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ReductionCartModel.php 6.1KB

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