Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

CreditHistory.php 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\OrderPayment;
  4. use App\Entity\OrderRefund;
  5. use App\Entity\UserMerchant;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Lc\ShopBundle\Context\OrderPaymentInterface;
  8. use Lc\ShopBundle\Context\OrderRefundInterface;
  9. use Lc\ShopBundle\Context\PayoffInterface;
  10. use Lc\ShopBundle\Context\UserMerchantInterface;
  11. /**
  12. * @ORM\MappedSuperclass()
  13. */
  14. abstract class CreditHistory extends AbstractEntity implements PayoffInterface
  15. {
  16. use PayoffTrait;
  17. const TYPE_CREDIT = 'credit';
  18. const TYPE_DEBIT = 'debit';
  19. /**
  20. * @ORM\Column(type="float", nullable=true)
  21. */
  22. protected $amount;
  23. /**
  24. * @ORM\Column(type="string", length=31)
  25. */
  26. protected $type;
  27. /**
  28. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserMerchantInterface", inversedBy="creditHistories")
  29. * @ORM\JoinColumn(nullable=false)
  30. */
  31. protected $userMerchant;
  32. /**
  33. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderPaymentInterface", cascade={"persist", "remove"})
  34. */
  35. protected $orderPayment;
  36. /**
  37. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", cascade={"persist", "remove"})
  38. */
  39. protected $orderRefund;
  40. public function getAmount(): ?float
  41. {
  42. return $this->amount;
  43. }
  44. public function setAmount(?float $amount): self
  45. {
  46. $this->amount = $amount;
  47. return $this;
  48. }
  49. public function getAmountInherited(): float
  50. {
  51. if ($this->getOrderPayment() !== null) {
  52. return $this->getOrderPayment()->getAmount();
  53. } else if ($this->getOrderRefund() !== null) {
  54. return $this->getOrderRefund()->getAmount();
  55. } else {
  56. return $this->getAmount();
  57. }
  58. }
  59. public function getMeanPaymentInherited(): string
  60. {
  61. if ($this->getOrderPayment() !== null) {
  62. return $this->getOrderPayment()->getMeanPayment();
  63. } else if ($this->getOrderRefund() !== null) {
  64. return $this->getOrderRefund()->getMeanPayment();
  65. } else {
  66. return $this->getMeanPayment();
  67. }
  68. }
  69. public function getPaidAtInherited (): ?\DateTimeInterface
  70. {
  71. if ($this->getOrderPayment() !== null) {
  72. return $this->getOrderPayment()->getPaidAt();
  73. } else if ($this->getOrderRefund() !== null) {
  74. return $this->getOrderRefund()->getPaidAt();
  75. } else {
  76. return $this->getPaidAt();
  77. }
  78. }
  79. public function getReferenceInherited (): ?string
  80. {
  81. if ($this->getOrderPayment() !== null) {
  82. return $this->getOrderPayment()->getReference();
  83. } else if ($this->getOrderRefund() !== null) {
  84. return $this->getOrderRefund()->getReference();
  85. } else {
  86. return $this->getReference();
  87. }
  88. }
  89. public function getCommentInherited (): ?string
  90. {
  91. if ($this->getOrderPayment() !== null) {
  92. return $this->getOrderPayment()->getComment();
  93. } else if ($this->getOrderRefund() !== null) {
  94. return $this->getOrderRefund()->getComment();
  95. } else {
  96. return $this->getComment();
  97. }
  98. }
  99. public function getMeanPaymentInheritedLabel(): string
  100. {
  101. return 'field.default.meanPaymentOptions.'.$this->getMeanPaymentInherited() ;
  102. }
  103. public function getType(): ?string
  104. {
  105. return $this->type;
  106. }
  107. public function setType(string $type): self
  108. {
  109. $this->type = $type;
  110. return $this;
  111. }
  112. public function getUserMerchant(): ?UserMerchantInterface
  113. {
  114. return $this->userMerchant;
  115. }
  116. public function setUserMerchant(?UserMerchantInterface $userMerchant): self
  117. {
  118. $this->userMerchant = $userMerchant;
  119. return $this;
  120. }
  121. public function getOrderPayment(): ?OrderPaymentInterface
  122. {
  123. return $this->orderPayment;
  124. }
  125. public function setOrderPayment(?OrderPaymentInterface $orderPayment): self
  126. {
  127. $this->orderPayment = $orderPayment;
  128. return $this;
  129. }
  130. public function getOrderRefund(): ?OrderRefundInterface
  131. {
  132. return $this->orderRefund;
  133. }
  134. public function setOrderRefund(?OrderRefundInterface $orderRefund): self
  135. {
  136. $this->orderRefund = $orderRefund;
  137. return $this;
  138. }
  139. }