src/Entity/UserBusinessResult.php line 25

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