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.

CreditHistory.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 getMeanPaymentInheritedLabel(): string
  70. {
  71. return 'field.default.meanPaymentOptions.'.$this->getMeanPaymentInherited() ;
  72. }
  73. public function getType(): ?string
  74. {
  75. return $this->type;
  76. }
  77. public function setType(string $type): self
  78. {
  79. $this->type = $type;
  80. return $this;
  81. }
  82. public function getUserMerchant(): ?UserMerchantInterface
  83. {
  84. return $this->userMerchant;
  85. }
  86. public function setUserMerchant(?UserMerchantInterface $userMerchant): self
  87. {
  88. $this->userMerchant = $userMerchant;
  89. return $this;
  90. }
  91. public function getOrderPayment(): ?OrderPaymentInterface
  92. {
  93. return $this->orderPayment;
  94. }
  95. public function setOrderPayment(?OrderPaymentInterface $orderPayment): self
  96. {
  97. $this->orderPayment = $orderPayment;
  98. return $this;
  99. }
  100. public function getOrderRefund(): ?OrderRefundInterface
  101. {
  102. return $this->orderRefund;
  103. }
  104. public function setOrderRefund(?OrderRefundInterface $orderRefund): self
  105. {
  106. $this->orderRefund = $orderRefund;
  107. return $this;
  108. }
  109. }