src/Entity/UserBusinessResult.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserBusinessResultRepository;
  4. use App\Traits\DateTrait;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation as Serializer;
  7. use JMS\Serializer\Annotation\Expose;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. /**
  10. * @ORM\Table(uniqueConstraints={
  11. * @ORM\UniqueConstraint(columns={"rrdi_code", "seller_code", "highlight"})
  12. * })
  13. *
  14. * @ORM\Entity(repositoryClass=UserBusinessResultRepository::class)
  15. * @ORM\HasLifecycleCallbacks()
  16. *
  17. * @UniqueEntity(fields={"rrdiCode", "sellerCode", "highlight"})
  18. *
  19. * @Serializer\ExclusionPolicy("ALL")
  20. */
  21. class UserBusinessResult
  22. {
  23. use DateTrait;
  24. /**
  25. * @ORM\Id
  26. * @ORM\GeneratedValue
  27. * @ORM\Column(type="integer")
  28. *
  29. * @Expose
  30. * @Serializer\Groups({
  31. * "user_bussiness_result:id"
  32. * })
  33. */
  34. private ?int $id = NULL;
  35. /**
  36. * @ORM\Column(type="integer")
  37. *
  38. * @Expose
  39. * @Serializer\Groups({
  40. * "user_bussiness_result",
  41. * "user_bussiness_result:sale",
  42. * "userBusinessResult:sale",
  43. * "export_user_datatable"
  44. * })
  45. */
  46. private ?int $sale = NULL;
  47. /**
  48. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="userBusinessResults" , fetch="EAGER")
  49. * @ORM\JoinColumn(nullable=true)
  50. *
  51. * @Expose
  52. * @Serializer\Groups({
  53. * "user_bussiness_result",
  54. * "user_bussiness_result:user"
  55. * })
  56. */
  57. private ?User $user;
  58. /**
  59. * @ORM\Column(type="string", length=64, nullable=true)
  60. *
  61. * @Expose
  62. * @Serializer\Groups({
  63. * "user_bussiness_result",
  64. * "user_bussiness_result:rrdi_code"
  65. * })
  66. */
  67. private ?string $rrdiCode = NULL;
  68. /**
  69. * @ORM\Column(type="string", length=64, nullable=true)
  70. *
  71. * @Expose
  72. * @Serializer\Groups({
  73. * "user_bussiness_result",
  74. * "user_bussiness_result:seller_code"
  75. * })
  76. */
  77. private ?string $sellerCode = NULL;
  78. /**
  79. * @ORM\Column(type="integer", nullable=true)
  80. *
  81. * @Expose
  82. * @Serializer\Groups({"user_bussiness_result"})
  83. */
  84. private ?int $highlight = NULL;
  85. /**
  86. * @ORM\OneToOne(targetEntity=PointTransaction::class, mappedBy="businessResult", cascade={"persist", "remove"})
  87. */
  88. private ?PointTransaction $pointTransaction;
  89. /**
  90. * @ORM\Column(type="string", length=255, nullable=true)
  91. *
  92. * @Expose
  93. * @Serializer\Groups({
  94. * "user_bussiness_result",
  95. * "user_bussiness_result:accountId",
  96. * "userBusinessResult:accountId",
  97. * "export_user_datatable"
  98. * })
  99. *
  100. */
  101. private ?string $accountId = NULL;
  102. /**
  103. * @ORM\Column(type="float", nullable=true)
  104. *
  105. * @Expose
  106. * @Serializer\Groups({
  107. * "user_bussiness_result",
  108. * "user_bussiness_result:bonusPoint"
  109. * })
  110. *
  111. */
  112. private ?float $bonusPoint = NULL;
  113. public function getId(): ?int
  114. {
  115. return $this->id;
  116. }
  117. public function getSale(): ?int
  118. {
  119. return $this->sale;
  120. }
  121. public function setSale(int $sale): self
  122. {
  123. $this->sale = $sale;
  124. return $this;
  125. }
  126. public function getRrdiCode(): ?string
  127. {
  128. return $this->rrdiCode;
  129. }
  130. public function setRrdiCode(?string $rrdiCode): self
  131. {
  132. $this->rrdiCode = $rrdiCode;
  133. return $this;
  134. }
  135. public function getSellerCode(): ?string
  136. {
  137. return $this->sellerCode;
  138. }
  139. public function setSellerCode(?string $sellerCode): self
  140. {
  141. $this->sellerCode = $sellerCode;
  142. if(strlen($sellerCode) > 7 && empty($this->rrdiCode)) $this->rrdiCode = substr($sellerCode, 0, 7);
  143. return $this;
  144. }
  145. public function getHighlight(): ?int
  146. {
  147. return $this->highlight;
  148. }
  149. public function setHighlight(?int $highlight): self
  150. {
  151. $this->highlight = $highlight;
  152. return $this;
  153. }
  154. public function getUser(): ?User
  155. {
  156. return $this->user;
  157. }
  158. public function setUser(?User $user): self
  159. {
  160. $this->user = $user;
  161. return $this;
  162. }
  163. public function getPointTransaction(): ?PointTransaction
  164. {
  165. return $this->pointTransaction;
  166. }
  167. public function setPointTransaction(?PointTransaction $pointTransaction): self
  168. {
  169. // unset the owning side of the relation if necessary
  170. if ($pointTransaction === NULL && $this->pointTransaction !== NULL) {
  171. $this->pointTransaction->setBusinessResult(NULL);
  172. }
  173. // set the owning side of the relation if necessary
  174. if ($pointTransaction !== NULL && $pointTransaction->getBusinessResult() !== $this) {
  175. $pointTransaction->setBusinessResult($this);
  176. }
  177. $this->pointTransaction = $pointTransaction;
  178. return $this;
  179. }
  180. public function getAccountId(): ?string
  181. {
  182. return $this->accountId;
  183. }
  184. public function setAccountId(?string $accountId): self
  185. {
  186. $this->accountId = $accountId;
  187. return $this;
  188. }
  189. /**
  190. * @return float|null
  191. */
  192. public function getBonusPoint(): ?float
  193. {
  194. return $this->bonusPoint;
  195. }
  196. /**
  197. * @param float|null $bonusPoint
  198. * @return UserBusinessResult
  199. */
  200. public function setBonusPoint(?float $bonusPoint): UserBusinessResult
  201. {
  202. $this->bonusPoint = $bonusPoint;
  203. return $this;
  204. }
  205. }