src/Entity/System/OrderCancellationRequest.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * @ORM\Table(name="order_cancellation_request")
  6. *
  7. * @ORM\Entity(repositoryClass="App\Repository\System\OrderCancellationRequestRepository")
  8. */
  9. class OrderCancellationRequest
  10. {
  11. public const WRONG_EAN_MARKETPLACE_CANCELLATION_REASON_ID = 8;
  12. public const MIP_BY_API_CANCELLATION_REASON_ID = 11;
  13. public const WORKHUMAN_CANCELLATION_REASON_ID = 12;
  14. public const CANCELLATION_REASONS = [
  15. 0 => 'controlpanel.orders.modal_delete.cancellation_reason.other_reason',
  16. 1 => 'controlpanel.orders.modal_delete.cancellation_reason.quantity_or_sku_modification',
  17. 2 => 'controlpanel.orders.modal_delete.cancellation_reason.duplicated_order',
  18. 3 => 'controlpanel.orders.modal_delete.cancellation_reason.wrong_order',
  19. 4 => 'controlpanel.orders.modal_delete.cancellation_reason.end_customer_cancellation',
  20. 5 => 'controlpanel.orders.modal_delete.cancellation_reason.change_delivery_address',
  21. 6 => 'controlpanel.orders.modal_delete.cancellation_reason.negative_margin',
  22. 7 => 'controlpanel.orders.modal_delete.cancellation_reason.carrier_high_cost',
  23. self::WRONG_EAN_MARKETPLACE_CANCELLATION_REASON_ID => 'controlpanel.orders.modal_delete.cancellation_reason.wrong_ean_marketplace',
  24. 9 => 'controlpanel.orders.modal_delete.cancellation_reason.end_customer_fraud',
  25. 10 => 'controlpanel.orders.modal_delete.cancellation_reason.test_order',
  26. self::MIP_BY_API_CANCELLATION_REASON_ID => 'controlpanel.orders.cancellation_reason.mip_by_api',
  27. self::WORKHUMAN_CANCELLATION_REASON_ID => 'controlpanel.orders.cancellation_reason.workhuman',
  28. ];
  29. /**
  30. * @var int
  31. *
  32. * @ORM\Id
  33. *
  34. * @ORM\GeneratedValue(strategy="AUTO")
  35. *
  36. * @ORM\Column(type="integer", name="id")
  37. */
  38. private $id;
  39. /**
  40. * @var Order
  41. *
  42. * @ORM\OneToOne(targetEntity="App\Entity\System\Order", inversedBy="cancellationRequest")
  43. *
  44. * @ORM\JoinColumn(name="order_id", referencedColumnName="id_order")
  45. */
  46. private $order;
  47. /**
  48. * @var int
  49. *
  50. * @ORM\Column(type="integer", length=10, name="order_previous_state")
  51. */
  52. private $orderPreviousState;
  53. /**
  54. * @var \DateTime|null
  55. *
  56. * @ORM\Column(type="datetime", nullable=true)
  57. */
  58. private $date;
  59. /**
  60. * @var int
  61. *
  62. * @ORM\Column(type="integer")
  63. */
  64. private int $reason;
  65. /**
  66. * @var string
  67. *
  68. * @ORM\Column(type="string")
  69. */
  70. private string $specificReason;
  71. public function __construct()
  72. {
  73. }
  74. public static function fromPrimitives(Order $order, int $orderPreviousState, int $reason, ?string $specificReason): self
  75. {
  76. $self = new self();
  77. $self->order = $order;
  78. $self->orderPreviousState = $orderPreviousState;
  79. $self->reason = $reason;
  80. $self->specificReason = $specificReason !== null ? $specificReason : '';
  81. $self->date = new \DateTime();
  82. return $self;
  83. }
  84. public function getId(): int
  85. {
  86. return $this->id;
  87. }
  88. public function getOrder(): Order
  89. {
  90. return $this->order;
  91. }
  92. public function setOrder(Order $order): void
  93. {
  94. $this->order = $order;
  95. }
  96. public function getOrderPreviousState(): int
  97. {
  98. return $this->orderPreviousState;
  99. }
  100. public function setOrderPreviousState(int $orderPreviousState): void
  101. {
  102. $this->orderPreviousState = $orderPreviousState;
  103. }
  104. public function getReason(): int
  105. {
  106. return $this->reason;
  107. }
  108. public function setReason(int $reason): void
  109. {
  110. $this->reason = $reason;
  111. }
  112. public function getSpecificReason(): string
  113. {
  114. return $this->specificReason;
  115. }
  116. public function setSpecificReason(string $specificReason): void
  117. {
  118. $this->specificReason = $specificReason;
  119. }
  120. public function getDate(): ?\DateTime
  121. {
  122. if (null === $this->date) {
  123. return null;
  124. }
  125. if ((int)$this->date->format('Y') <= 0) {
  126. // 0000-00-00 00:00:00 dates
  127. return null;
  128. }
  129. return $this->date;
  130. }
  131. }