您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ReductionCreditModel.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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\ReductionInterface;
  8. use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait;
  9. use Lc\CaracoleBundle\Model\Config\UnitModel;
  10. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  11. use Lc\SovBundle\Doctrine\Extension\StatusInterface;
  12. use Lc\SovBundle\Doctrine\Extension\StatusTrait;
  13. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  14. use Lc\SovBundle\Model\User\UserInterface;
  15. /**
  16. * @ORM\MappedSuperclass()
  17. */
  18. abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface,
  19. FilterMerchantInterface,
  20. StatusInterface, ReductionCreditInterface
  21. {
  22. const TYPE_CREDIT = 'credit';
  23. const TYPE_GIFT = 'gift';
  24. use ReductionTrait;
  25. use StatusTrait;
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. */
  29. protected $title;
  30. /**
  31. * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="reductionCredits")
  32. */
  33. protected $users;
  34. /**
  35. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
  36. * @ORM\JoinColumn(nullable=false)
  37. */
  38. protected $merchant;
  39. /**
  40. * @ORM\Column(type="string", length=255)
  41. */
  42. protected $type;
  43. /**
  44. * @ORM\Column(type="boolean", nullable=true)
  45. */
  46. protected $sended;
  47. /**
  48. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  49. * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  50. */
  51. protected $owner;
  52. /**
  53. * @ORM\Column(type="datetime", nullable=true)
  54. */
  55. protected $activationDate;
  56. /**
  57. * @ORM\Column(type="string", length=255, nullable=true)
  58. */
  59. protected $ownerName;
  60. /**
  61. * @ORM\Column(type="text", nullable=true)
  62. */
  63. protected $ownerMessage;
  64. public function __construct()
  65. {
  66. $this->users = new ArrayCollection();
  67. $this->unit = UnitModel::UNIT_AMOUNT;
  68. }
  69. public function __toString()
  70. {
  71. return $this->title;
  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(): MerchantInterface
  83. {
  84. return $this->merchant;
  85. }
  86. public function setMerchant(MerchantInterface $merchant): self
  87. {
  88. $this->merchant = $merchant;
  89. return $this;
  90. }
  91. public function getType(): ?string
  92. {
  93. return $this->type;
  94. }
  95. public function setType(string $type): self
  96. {
  97. $this->type = $type;
  98. return $this;
  99. }
  100. /**
  101. * @return Collection|UserInterface[]
  102. */
  103. public function getUsers(): Collection
  104. {
  105. return $this->users;
  106. }
  107. public function addUser(UserInterface $user): self
  108. {
  109. if (!$this->users->contains($user)) {
  110. $this->users[] = $user;
  111. }
  112. return $this;
  113. }
  114. public function removeUser(UserInterface $user): self
  115. {
  116. if ($this->users->contains($user)) {
  117. $this->users->removeElement($user);
  118. }
  119. return $this;
  120. }
  121. public function getSended(): ?bool
  122. {
  123. return $this->sended;
  124. }
  125. public function setSended(?bool $sended): self
  126. {
  127. $this->sended = $sended;
  128. return $this;
  129. }
  130. public function getOwner(): ?UserInterface
  131. {
  132. return $this->owner;
  133. }
  134. public function setOwner(?UserInterface $owner): self
  135. {
  136. $this->owner = $owner;
  137. return $this;
  138. }
  139. public function getActivationDate(): ?\DateTimeInterface
  140. {
  141. return $this->activationDate;
  142. }
  143. public function setActivationDate(?\DateTimeInterface $activationDate): self
  144. {
  145. $this->activationDate = $activationDate;
  146. return $this;
  147. }
  148. public function getOwnerName(): ?string
  149. {
  150. return $this->ownerName;
  151. }
  152. public function setOwnerName(?string $ownerName): self
  153. {
  154. $this->ownerName = $ownerName;
  155. return $this;
  156. }
  157. public function getOwnerMessage(): ?string
  158. {
  159. return $this->ownerMessage;
  160. }
  161. public function setOwnerMessage(?string $ownerMessage): self
  162. {
  163. $this->ownerMessage = $ownerMessage;
  164. return $this;
  165. }
  166. }