<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiSubresource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass="App\Repository\OzonClientRepository")
*/
class OzonClient implements \JsonSerializable
{
const CURRENCY_RUB = 1;
const CURRENCY_KZT = 2;
const CURRENCY_KZT_TEXT = 'KZT';
/**
* @Groups({"ozonClient"})
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @var int
*/
private $id;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="string", length=255)
*
* @var string
*/
private $name;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="string", length=255)
*
* @var string
*/
private $url;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @var string
*/
private $storeUrl;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="string", length=64)
*
* @var string
*/
private $apiClientId;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="string", length=255)
*
* @var string
*/
private $apiKey;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="string", length=100)
*
* @var string
*/
private $storeFbs;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="string", length=100)
*
* @var string
*/
private $storeFbo;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="string", length=128)
*
* @var string
*/
private $orderType;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $isEnabled;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $isEnabledOrders;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $isEnabledStatuses;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTimeInterface|null
*/
private $startOrdersTm;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $orderPriceDeflection;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $minStock;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $stockFree;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $stockReserv;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $stockSher;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $stockFim;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $stockFimspb;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $stockFimInter;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $stockMp;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $isEnabledPrice;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean", nullable=true, options={"default" : true})
*
* @var bool
*/
private $isEnabledStocks;
/**
* @Groups({"ozonClient"})
*
* @ORM\Column(type="boolean")
*
* @var bool
*/
private $useNightPrice;
/**
* @Groups({"ozonClient"})
*
* @ORM\OneToMany(targetEntity="App\Entity\OzonClientTarget", mappedBy="client", cascade={"persist"}, fetch="EAGER")
*
* @ApiSubresource
*
* @var OzonClientTarget[]
*/
private $targets;
/**
* @Groups({"ozonClient"})
*
* @ORM\OneToMany(targetEntity="App\Entity\OzonWarehouse", mappedBy="client", cascade={"persist"}, fetch="EAGER")
*
* @ApiSubresource
*
* @var OzonClientTarget[]
*/
private $warehouses;
/**
* @ORM\Column(type="string", nullable=true)
*
* @var string
*/
private $orderComment;
/**
* @Groups({"ozonClient"})
* @ORM\Column(type="smallint", length=3, options={"default": 1})
*/
private $currencyCode;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $legalName;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $thankyouMessage;
/**
* Отправлять ли сообщение после доставки
* @ORM\Column(type="boolean")
*/
private $isThankyouMsgSend;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $retailCrmId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $retailCrmSite;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $omsStoreId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $omsApiKey;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $omsPassword;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $omsApiKeyCreatedAt;
/**
* OzonClient constructor.
*/
public function __construct()
{
$this->isEnabled = false;
$this->isEnabledOrders = false;
$this->isEnabledStatuses = false;
$this->isEnabledPrice = false;
$this->isEnabledStocks = false;
$this->useNightPrice = false;
$this->targets = new ArrayCollection();
$this->warehouses = new ArrayCollection();
$this->stockFree = true;
$this->stockReserv = false;
$this->stockSher = false;
$this->stockFim = false;
$this->stockFimInter = false;
$this->stockFimspb = false;
$this->currencyCode = self::CURRENCY_RUB;
$this->legalName = 'ООО “Гипер”';
$this->isThankyouMsgSend = false;
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
*
* @return self
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getUrl(): ?string
{
return $this->url;
}
/**
* @param string $url
*
* @return self
*/
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
/**
* @return string|null
*/
public function getStoreUrl(): ?string
{
return $this->storeUrl;
}
/**
* @param string $storeUrl
*
* @return self
*/
public function setStoreUrl(string $storeUrl): self
{
$this->storeUrl = $storeUrl;
return $this;
}
/**
* @return string|null
*/
public function getApiClientId(): ?string
{
return $this->apiClientId;
}
/**
* @param string $apiClientId
*
* @return self
*/
public function setApiClientId(string $apiClientId): self
{
$this->apiClientId = $apiClientId;
return $this;
}
/**
* @return string|null
*/
public function getApiKey(): ?string
{
return $this->apiKey;
}
/**
* @param string $apiKey
*
* @return self
*/
public function setApiKey(string $apiKey): self
{
$this->apiKey = $apiKey;
return $this;
}
/**
* @return string|null
*/
public function getStoreFbs(): ?string
{
return $this->storeFbs;
}
/**
* @param string $storeFbs
*
* @return self
*/
public function setStoreFbs(string $storeFbs): self
{
$this->storeFbs = $storeFbs;
return $this;
}
/**
* @return array|null
*/
public function getStoreFbsObject(): ?array
{
return ['store' => $this->storeFbs];
}
/**
* @param array $storeFbs
*
* @return self
*/
public function setStoreFbsObject(array $storeFbs): self
{
$this->storeFbs = $storeFbs['store'];
return $this;
}
/**
* @return string|null
*/
public function getStoreFbo(): ?string
{
return $this->storeFbo;
}
/**
* @param string $storeFbo
*
* @return self
*/
public function setStoreFbo(string $storeFbo): self
{
$this->storeFbo = $storeFbo;
return $this;
}
/**
* @return array|null
*/
public function getStoreFboObject(): ?array
{
return ['store' => $this->storeFbo];
}
/**
* @param array $storeFbo
*
* @return self
*/
public function setStoreFboObject(array $storeFbo): self
{
$this->storeFbo = $storeFbo['store'];
return $this;
}
/**
* @return string|null
*/
public function getOrderType(): ?string
{
return $this->orderType;
}
/**
* @param string $orderType
*
* @return self
*/
public function setOrderType(string $orderType): self
{
$this->orderType = $orderType;
return $this;
}
/**
* @return array|null
*/
public function getOrderTypeObject(): ?array
{
return ['orderType' => $this->orderType];
}
/**
* @param array $orderType
*
* @return self
*/
public function setOrderTypeObject(array $orderType): self
{
$this->orderType = $orderType['orderType'];
return $this;
}
/**
* @return bool
*/
public function isEnabled(): bool
{
return $this->isEnabled ?? false;
}
/**
* @param bool $isEnabled
*
* @return self
*/
public function setIsEnabled(bool $isEnabled): self
{
$this->isEnabled = $isEnabled;
return $this;
}
/**
* @return bool
*/
public function isEnabledOrders(): bool
{
return $this->isEnabledOrders ?? false;
}
/**
* @param bool $isEnabledOrders
*
* @return self
*/
public function setIsEnabledOrders(bool $isEnabledOrders): self
{
$this->isEnabledOrders = $isEnabledOrders;
return $this;
}
/**
* @return bool
*/
public function isEnabledStatuses(): bool
{
return $this->isEnabledStatuses ?? false;
}
/**
* @param bool $isEnabledStatuses
*
* @return self
*/
public function setIsEnabledStatuses(bool $isEnabledStatuses): self
{
$this->isEnabledStatuses = $isEnabledStatuses;
return $this;
}
/**
* @return \DateTimeInterface|null
*/
public function getStartOrdersTm(): ?\DateTimeInterface
{
return $this->startOrdersTm;
}
/**
* @param \DateTimeInterface|null $startOrdersTm
*
* @return self
*/
public function setStartOrdersTm(?\DateTimeInterface $startOrdersTm): self
{
$this->startOrdersTm = $startOrdersTm;
return $this;
}
/**
* @return int|null
*/
public function getOrderPriceDeflection(): ?int
{
return $this->orderPriceDeflection;
}
/**
* @param int|null $orderPriceDeflection
*/
public function setOrderPriceDeflection(?int $orderPriceDeflection): void
{
$this->orderPriceDeflection = $orderPriceDeflection;
}
/**
* @return int|null
*/
public function getMinStock(): ?int
{
return $this->minStock;
}
/**
* @param int|null $minStock
*
* @return self
*/
public function setMinStock(?int $minStock): self
{
$this->minStock = $minStock;
return $this;
}
/**
* @return bool|null
*/
public function isStockFree(): ?bool
{
return $this->stockFree;
}
/**
* @param bool $stockFree
*
* @return self
*/
public function setStockFree(bool $stockFree): self
{
$this->stockFree = $stockFree;
return $this;
}
/**
* @return bool|null
*/
public function isStockReserv(): ?bool
{
return $this->stockReserv;
}
/**
* @param bool $stockReserv
*
* @return self
*/
public function setStockReserv(bool $stockReserv): self
{
$this->stockReserv = $stockReserv;
return $this;
}
/**
* @return bool|null
*/
public function isStockSher(): ?bool
{
return $this->stockSher;
}
/**
* @param bool $stockSher
*
* @return self
*/
public function setStockSher(bool $stockSher): self
{
$this->stockSher = $stockSher;
return $this;
}
/**
* @return bool|null
*/
public function isStockFim(): ?bool
{
return $this->stockFim;
}
/**
* @param bool $stockFim
*
* @return self
*/
public function setStockFim(bool $stockFim): self
{
$this->stockFim = $stockFim;
return $this;
}
/**
* @return bool|null
*/
public function isStockFimspb(): ?bool
{
return $this->stockFimspb;
}
/**
* @param bool $stockFimspb
*
* @return self
*/
public function setStockFimspb(bool $stockFimspb): self
{
$this->stockFimspb = $stockFimspb;
return $this;
}
/**
* @return bool|null
*/
public function isStockFimInter(): ?bool
{
return $this->stockFimInter;
}
/**
* @param bool $stockFimInter
*
* @return self
*/
public function setStockFimInter(bool $stockFimInter): self
{
$this->stockFimInter = $stockFimInter;
return $this;
}
/**
* @return bool|null
*/
public function isStockMp(): ?bool
{
return $this->stockMp;
}
/**
* @param bool $stockMp
*/
public function setStockMp(bool $stockMp): void
{
$this->stockMp = $stockMp;
}
/**
* @return bool
*/
public function isEnabledPrice(): bool
{
return $this->isEnabledPrice;
}
/**
* @param bool $isEnabledPrice
*
* @return self
*/
public function setIsEnabledPrice(bool $isEnabledPrice): self
{
$this->isEnabledPrice = $isEnabledPrice;
return $this;
}
/**
* @return bool|null
*/
public function isEnabledStocks(): ?bool
{
return $this->isEnabledStocks;
}
/**
* @param bool|null $isEnabledStocks
*
* @return self
*/
public function setIsEnabledStocks(?bool $isEnabledStocks): self
{
$this->isEnabledStocks = $isEnabledStocks;
return $this;
}
/**
* @return bool
*/
public function getUseNightPrice(): bool
{
return $this->useNightPrice;
}
/**
* @param bool $useNightPrice
*
* @return self
*/
public function setUseNightPrice(bool $useNightPrice): self
{
$this->useNightPrice = $useNightPrice;
return $this;
}
/**
* @return Collection|OzonClientTarget[]
*/
public function getTargets(): Collection
{
return $this->targets;
}
/**
* @param OzonClientTarget $target
*
* @return self
*/
public function addTarget(OzonClientTarget $target): self
{
if (!$this->targets->contains($target)) {
$this->targets->add($target);
$target->setClient($this);
}
return $this;
}
/**
* @param OzonClientTarget $target
*
* @return self
*/
public function removeTarget(OzonClientTarget $target): self
{
if ($this->targets->contains($target)) {
$this->targets->removeElement($target);
}
return $this;
}
/**
* @return Collection|OzonWarehouse[]
*/
public function getWarehouses(): Collection
{
return $this->warehouses;
}
/**
* @param OzonWarehouse $warehouse
*
* @return self
*/
public function addWarehouse(OzonWarehouse $warehouse): self
{
if (!$this->warehouses->contains($warehouse)) {
$this->warehouses->add($warehouse);
$warehouse->setClient($this);
}
return $this;
}
/**
* @param OzonWarehouse $warehouse
*
* @return self
*/
public function removeWarehouse(OzonWarehouse $warehouse): self
{
if ($this->warehouses->contains($warehouse)) {
$this->warehouses->removeElement($warehouse);
}
return $this;
}
/**
* @return string|null
*/
public function getOrderComment(): ?string
{
return $this->orderComment;
}
/**
* @param string|null $orderComment
* @return OzonClient
*/
public function setOrderComment(?string $orderComment): OzonClient
{
$this->orderComment = $orderComment;
return $this;
}
/**
* @return string
*/
public function __toString(): string
{
return ($this->getName() ?? '').' ('.$this->getApiClientId().')';
}
/**
* @return array
*/
public function jsonSerialize(): array
{
$data = [
'id' => $this->getId(),
'name' => $this->getName(),
'url' => $this->getUrl(),
'storeUrl' => $this->getStoreUrl(),
'apiClientId' => $this->getApiClientId(),
'apiKey' => $this->getApiKey(),
'storeFbs' => $this->getStoreFbs(),
'storeFbo' => $this->getStoreFbo(),
'orderType' => $this->getOrderType(),
'isEnabled' => $this->isEnabled(),
'isEnabledOrders' => $this->isEnabledOrders(),
'isEnabledStatuses' => $this->isEnabledStatuses(),
'isEnabledPrice' => $this->isEnabledPrice(),
'useNightPrice' => $this->getUseNightPrice(),
'startOrdersTm' => $this->getStartOrdersTm(),
'minStock' => $this->getMinStock(),
'isStockFree' => $this->isStockFree(),
'isStockReserv' => $this->isStockReserv(),
'isStockSher' => $this->isStockSher(),
'isStockFim' => $this->isStockFim(),
'isStockFimspb' => $this->isStockFimspb(),
'isStockFimInter' => $this->isStockFimInter(),
];
return $data;
}
public function getCurrencyCode(): ?int
{
return $this->currencyCode;
}
public function setCurrencyCode(int $currencyCode): self
{
$this->currencyCode = $currencyCode;
return $this;
}
public function getCurrency(): string
{
$currencies = [
self::CURRENCY_RUB => 'RUB',
self::CURRENCY_KZT => 'KZT'
];
return $currencies[$this->currencyCode];
}
public function getLegalName(): ?string
{
return $this->legalName;
}
public function setLegalName(?string $legalName): self
{
$this->legalName = $legalName;
return $this;
}
public function getThankyouMessage(): ?string
{
return $this->thankyouMessage;
}
public function setThankyouMessage(?string $thankyouMessage): self
{
$this->thankyouMessage = $thankyouMessage;
return $this;
}
public function getIsThankyouMsgSend(): ?bool
{
return $this->isThankyouMsgSend;
}
public function setIsThankyouMsgSend(bool $isThankyouMsgSend): self
{
$this->isThankyouMsgSend = $isThankyouMsgSend;
return $this;
}
public function getRetailCrmId(): ?string
{
return $this->retailCrmId;
}
public function setRetailCrmId(?string $retailCrmId): self
{
$this->retailCrmId = $retailCrmId;
return $this;
}
public function getRetailCrmSite(): ?string
{
return $this->retailCrmSite;
}
public function setRetailCrmSite(?string $retailCrmSite): self
{
$this->retailCrmSite = $retailCrmSite;
return $this;
}
public function getOmsStoreId(): ?string
{
return $this->omsStoreId;
}
public function setOmsStoreId(?string $omsStoreId): self
{
$this->omsStoreId = $omsStoreId;
return $this;
}
public function getOmsApiKey(): ?string
{
return $this->omsApiKey;
}
public function setOmsApiKey(?string $omsApiKey): self
{
$this->omsApiKey = $omsApiKey;
return $this;
}
public function getOmsPassword(): ?string
{
return $this->omsPassword;
}
public function setOmsPassword(?string $omsPassword): self
{
$this->omsPassword = $omsPassword;
return $this;
}
public function getOmsApiKeyCreatedAt(): ?\DateTimeInterface
{
return $this->omsApiKeyCreatedAt;
}
public function setOmsApiKeyCreatedAt(?\DateTimeInterface $omsApiKeyCreatedAt): self
{
$this->omsApiKeyCreatedAt = $omsApiKeyCreatedAt;
return $this;
}
}