<?php
namespace App\Entity;
use App\Constants\ActiveConstants;
use App\Repository\OrderRepository;
use App\Traits\TimeTrackTrait;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: OrderRepository::class)]
#[ORM\Table(name: '`order`')]
#[ORM\HasLifecycleCallbacks]
class Order
{
use TimeTrackTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column]
private ?int $status = null;
#[ORM\Column(length: 191)]
private ?string $reference = null;
#[ORM\Column(type: 'boolean', options: ['default' => 0])]
private bool $lifecellActivationError = false;
#[ORM\Column(type: 'boolean', options: ['default' => 0])]
private bool $newNumberIssued = false;
#[ORM\Column]
private ?float $price = null;
#[ORM\Column(type: "text", nullable: true)]
private ?string $apiError = null;
#[ORM\Column(type: "text", nullable: true)]
private ?string $paymentData = null;
#[ORM\Column(length: 191, nullable: true)]
private ?string $idReceipt = null;
#[ORM\Column(length: 191, nullable: true)]
private ?string $signature = null;
#[ORM\Column(length: 191, nullable: true)]
private ?string $paymentUrl = null;
#[ORM\Column(length: 191, nullable: true)]
private ?string $repayUrl = null;
#[ORM\Column(length: 191, nullable: true)]
private ?string $userLifecellPosId = null;
#[ORM\ManyToOne(inversedBy: 'orders')]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
#[ORM\ManyToOne(inversedBy: 'orders')]
#[ORM\JoinColumn(nullable: false)]
private ?PhoneNumber $phoneNumber = null;
#[ORM\ManyToOne(inversedBy: 'orders')]
#[ORM\JoinColumn(nullable: false)]
private ?Company $company = null;
#[ORM\Column(length: 191, nullable: true)]
private ?string $orderToken = null;
private $payment;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'payment_accepted_at', type: 'datetime', nullable: true)]
private $paymentAcceptedAt;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'esim_mail_resend_at', type: 'datetime', nullable: true)]
private $esimMailResendAt;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $unfreezeNumberAt = null;
#[ORM\ManyToOne(inversedBy: 'orders')]
#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private ?Voucher $voucher = null;
#[ORM\ManyToOne(inversedBy: 'orders')]
#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]
private ?VoucherCode $voucherCode = null;
#[ORM\Column(nullable: true)]
private ?float $discount = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $discountName = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $metaTags = null;
public function getVoucher(): ?Voucher
{
return $this->voucher;
}
public function setVoucher(?Voucher $voucher): static
{
$this->voucher = $voucher;
return $this;
}
public function getVoucherCode(): ?VoucherCode
{
return $this->voucherCode;
}
public function setVoucherCode(?VoucherCode $voucherCode): static
{
$this->voucherCode = $voucherCode;
return $this;
}
public function getSeries(): string
{
return 'AAAA';
}
public function getId(): ?int
{
return $this->id;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): static
{
$this->status = $status;
return $this;
}
public function getStatusLabel(): string
{
$statuses = [
1 => "Відправлене на оплату",
2 => "Успіх",
3 => "Прострочене замовлення",
4 => "Помилка оплати",
5 => "Очікує підтвердження від вашого банку",
];
return $statuses[$this->status] ?? (string)$this->status;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(string $reference): static
{
$this->reference = $reference;
return $this;
}
public function getSignature(): ?string
{
return $this->signature;
}
public function setSignature(?string $signature): static
{
$this->signature = $signature;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
public function getPhoneNumber(): ?PhoneNumber
{
return $this->phoneNumber;
}
public function setPhoneNumber(?PhoneNumber $phoneNumber): static
{
$this->phoneNumber = $phoneNumber;
return $this;
}
/**
* Set createdAt.
*
* @param \DateTime|null $createdAt
*
* @return Order
*/
public function setCreatedAt($createdAt = null)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt.
*
* @return \DateTime|null
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt.
*
* @param \DateTime|null $updatedAt
*
* @return Order
*/
public function setUpdatedAt($updatedAt = null)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt.
*
* @return \DateTime|null
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function __toString()
{
return $this->getReference();
}
public function getRepayUrl(): ?string
{
return $this->repayUrl;
}
public function setRepayUrl(?string $repayUrl): static
{
$this->repayUrl = $repayUrl;
return $this;
}
public function getPaymentAcceptedAt(): ?\DateTimeInterface
{
return $this->paymentAcceptedAt;
}
public function setPaymentAcceptedAt(?\DateTimeInterface $paymentAcceptedAt): static
{
$this->paymentAcceptedAt = $paymentAcceptedAt;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): static
{
$this->company = $company;
return $this;
}
public function getPaymentUrl(): ?string
{
return $this->paymentUrl;
}
public function setPaymentUrl(?string $paymentUrl): static
{
$this->paymentUrl = $paymentUrl;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): static
{
$this->price = $price;
return $this;
}
public function getEsimMailResendAt(): ?\DateTimeInterface
{
return $this->esimMailResendAt;
}
public function setEsimMailResendAt(?\DateTimeInterface $esimMailResendAt): static
{
$this->esimMailResendAt = $esimMailResendAt;
return $this;
}
public function getApiError(): ?string
{
return $this->apiError;
}
public function hasApiError(): bool
{
return !empty($this->getApiError());
}
public function setApiError(?string $apiError): static
{
$this->apiError = $apiError;
return $this;
}
public function isLifecellActivationError(): ?bool
{
return $this->lifecellActivationError;
}
public function setLifecellActivationError(bool $lifecellActivationError): static
{
$this->lifecellActivationError = $lifecellActivationError;
return $this;
}
public function getUserLifecellPosId(): ?string
{
return $this->userLifecellPosId;
}
public function setUserLifecellPosId(?string $userLifecellPosId): static
{
$this->userLifecellPosId = $userLifecellPosId;
return $this;
}
public function isNewNumberIssued(): ?bool
{
return $this->newNumberIssued;
}
public function setNewNumberIssued(bool $newNumberIssued): static
{
$this->newNumberIssued = $newNumberIssued;
return $this;
}
public function getNewNumberIssuedLabel(): string
{
return $this->newNumberIssued ? ActiveConstants::LABEL_YES : ActiveConstants::LABEL_NO;
}
public function getLifecellActivationErrorLabel(): string
{
return $this->lifecellActivationError ? ActiveConstants::LABEL_YES : ActiveConstants::LABEL_NO;
}
public function getHasApiErrorLabel(): string
{
return $this->hasApiError() ? ActiveConstants::LABEL_YES : ActiveConstants::LABEL_NO;
}
public function getUnfreezeNumberAt(): ?\DateTimeInterface
{
return $this->unfreezeNumberAt;
}
public function setUnfreezeNumberAt(?\DateTimeInterface $unfreezeNumberAt): static
{
$this->unfreezeNumberAt = $unfreezeNumberAt;
return $this;
}
public function getTariff(): ?Tariff
{
return $this->getPhoneNumber()?->getTariff();
}
public function getStatusName()
{
$statuses = [
1 => "Відправлене на оплату",
2 => "Успіх",
3 => "Прострочене замовлення",
4 => "Помилка оплати",
5 => "Очікує підтвердження від вашого банку",
];
return $statuses[$this->getStatus()];
}
public function getPaymentData(): ?string
{
return $this->paymentData;
}
public function setPaymentData(?string $paymentData): static
{
$this->paymentData = $paymentData;
return $this;
}
public function getIdReceipt(): ?string
{
return $this->idReceipt;
}
public function setIdReceipt(?string $idReceipt): static
{
$this->idReceipt = $idReceipt;
return $this;
}
public function getOrderToken(): ?string
{
return $this->orderToken;
}
public function setOrderToken(?string $orderToken): static
{
$this->orderToken = $orderToken;
return $this;
}
public function getDiscount()
{
return $this->discount;
}
public function setDiscount($discount): static
{
$this->discount = $discount;
return $this;
}
public function getDiscountName(): ?string
{
return $this->discountName;
}
public function setDiscountName($discountName): static
{
$this->discountName = $discountName;
return $this;
}
public function getMetaTags(): ?string
{
return $this->metaTags;
}
public function setMetaTags(?string $metaTags): static
{
$this->metaTags = $metaTags;
return $this;
}
}