<?php
namespace App\Entity;
use App\Entity\Traits;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Configuration;
/**
* @ORM\Entity(repositoryClass="App\Repository\ShopRepository")
* @ORM\Table(name="shop")
* @ORM\HasLifecycleCallbacks()
*/
class Shop
{
use Traits\Id;
use Traits\Dates;
/**
* @var int
* @ORM\Column(type="integer")
*/
protected $insalesId;
/**
* @var string
* @ORM\Column(type="string")
*/
protected $shop;
/**
* @var string
* @ORM\Column(type="string")
*/
protected $password;
/**
* @var string
* @ORM\Column(type="string")
*/
protected $passwordToken;
/**
* @var string
* @ORM\Column(type="string")
*/
protected $widgetPassword;
/**
* @var integer
* @ORM\Column (type="integer")
*/
protected $deliveryId;
/**
* @var integer
* @ORM\Column (type="integer")
*/
protected $rateResultPropertyId;
/**
* @var boolean
* @ORM\Column(type="boolean")
*/
protected $updateStatuses = false;
/**
* @var boolean
* @ORM\Column(type="boolean")
*/
protected $useCustomStatuses = false;
/**
* @var Configuration\Connection
* @ORM\OneToOne(targetEntity="App\Entity\Configuration\Connection", mappedBy="shop", cascade={"all"}, orphanRemoval=true)
*/
protected $connection;
/**
* @var Configuration\Calculation
* @ORM\OneToOne(targetEntity="App\Entity\Configuration\Calculation", mappedBy="shop", cascade={"all"}, orphanRemoval=true)
*/
protected $calculation;
/**
* @var Configuration\Status[]
* @ORM\OneToMany(targetEntity="App\Entity\Configuration\Status", mappedBy="shop", cascade={"all"}, orphanRemoval=true)
*/
protected $statuses;
/**
* @var Package[]
* @ORM\OneToMany(targetEntity="Package", mappedBy="shop", cascade={"all"}, orphanRemoval=true)
*/
protected $catapultoOrders;
/**
* @var Order[]
* @ORM\OneToMany (targetEntity="App\Entity\Order", mappedBy="shop", cascade={"all"}, orphanRemoval=true)
*/
protected $orders;
/** Флаг первичной синхронизации вариантов доставки после установки модуля
* @var bool
* @ORM\Column (type="boolean", options={"default": false})
*/
protected $firstSync = false;
/**
* @ORM\Column(type="boolean")
*/
private $markPayed = false;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $blockingStatus;
/**
* @return int
*/
public function getInsalesId(): int
{
return (int)$this->insalesId;
}
/**
* @param int $insalesId
* @return self
*/
public function setInsalesId(int $insalesId): self
{
$this->insalesId = $insalesId;
return $this;
}
/**
* @return string
*/
public function getShop(): string
{
return $this->shop;
}
/**
* @param string $shop
* @return self
*/
public function setShop(string $shop): self
{
$this->shop = $shop;
return $this;
}
/**
* @return string
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* @param string $password
* @return self
*/
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @return string
*/
public function getPasswordToken(): ?string
{
return $this->passwordToken;
}
/**
* @param string $passwordToken
*
* @return self
*/
public function setPasswordToken(string $passwordToken): self
{
$this->passwordToken = $passwordToken;
return $this;
}
/**
* @return string
*/
public function getWidgetPassword(): string
{
return $this->widgetPassword;
}
/**
* @param string $widgetPassword
* @return self
*/
public function setWidgetPassword(string $widgetPassword): self
{
$this->widgetPassword = $widgetPassword;
return $this;
}
/**
* @return int
*/
public function getDeliveryId(): int
{
return $this->deliveryId;
}
/**
* @param int $deliveryId
*
* @return Shop
*/
public function setDeliveryId(int $deliveryId): self
{
$this->deliveryId = $deliveryId;
return $this;
}
/**
* @return int
*/
public function getRateResultPropertyId(): int
{
return $this->rateResultPropertyId;
}
/**
* @param int $rateResultPropertyId
*
* @return Shop
*/
public function setRateResultPropertyId(int $rateResultPropertyId): Shop
{
$this->rateResultPropertyId = $rateResultPropertyId;
return $this;
}
/**
* @return bool
*/
public function isUpdateStatuses(): bool
{
return $this->updateStatuses;
}
/**
* @param bool $updateStatuses
* @return self
*/
public function setUpdateStatuses(bool $updateStatuses): self
{
$this->updateStatuses = $updateStatuses;
return $this;
}
/**
* @return bool
*/
public function isUseCustomStatuses(): bool
{
return $this->useCustomStatuses;
}
/**
* @param bool $useCustomStatuses
* @return self
*/
public function setUseCustomStatuses(bool $useCustomStatuses): self
{
$this->useCustomStatuses = $useCustomStatuses;
return $this;
}
/**
* Генерация пароля для виджета
* @return self
*/
public function createWidgetPassword(): self
{
$this->setWidgetPassword(
\md5(
\implode(
':',
[
$this->getPassword(),
$this->getPasswordToken(),
\time()
]
)
)
);
return $this;
}
/**
* @return self
* @throws \Exception
*/
public function updateLastUpdateStatusDates()
{
$this->lastUpdateStatuses = new \DateTime();
return $this;
}
/**
* @return self
* @throws \Exception
*/
public function updateLastUpdateTerminalsDates()
{
$this->lastUpdateTerminal = new \DateTime();
return $this;
}
/**
* @return \DateTime
*/
public function getLastUpdateTerminal(): \DateTime
{
return $this->lastUpdateTerminal;
}
/**
* @return Configuration\Connection
*/
public function getConnection(): ?Configuration\Connection
{
if (!$this->connection instanceof Configuration\Connection) {
$this->connection = new Configuration\Connection();
$this->connection->setShop($this);
}
return $this->connection;
}
/**
* @param Configuration\Connection $connection
*/
public function setConnection(?Configuration\Connection $connection): void
{
$this->connection = $connection;
}
/**
* @return Configuration\Calculation
*/
public function getCalculation(): Configuration\Calculation
{
if (!$this->calculation instanceof Configuration\Calculation) {
$this->calculation = new Configuration\Calculation();
$this->calculation->setShop($this);
}
return $this->calculation;
}
/**
* @param Configuration\Calculation $calculation
*/
public function setCalculation(Configuration\Calculation $calculation): void
{
$this->calculation = $calculation;
}
/**
* @return \DateTime
*/
public function getLastUpdateStatuses(): \DateTime
{
return $this->lastUpdateStatuses;
}
/**
* @param \DateTime $lastUpdateStatuses
*/
public function setLastUpdateStatuses(\DateTime $lastUpdateStatuses): void
{
$this->lastUpdateStatuses = $lastUpdateStatuses;
}
/**
* @return Configuration\Zone[]|null
*/
public function getZonePrices(): ?array
{
return $this->zonePrices;
}
/**
* @param Configuration\Zone[]|null $zonePrices
*/
public function setZonePrices(?array $zonePrices): void
{
$this->zonePrices = $zonePrices;
}
/**
* @return bool
*/
public function isUseZonePrice(): bool
{
return $this->useZonePrice;
}
/**
* @param bool $useZonePrice
*/
public function setUseZonePrice(bool $useZonePrice): void
{
$this->useZonePrice = $useZonePrice;
}
public function getZonePriceByZone($zone)
{
}
/**
* @return bool
*/
public function getFirstSync(): bool
{
return $this->firstSync;
}
/**
* @param bool $flag
* @return self
*/
public function setFirstSync($flag): self
{
$this->firstSync = $flag;
return $this;
}
public function getMarkPayed(): ?bool
{
return $this->markPayed;
}
public function setMarkPayed(bool $markPayed): self
{
$this->markPayed = $markPayed;
return $this;
}
public function getBlockingStatus(): ?string
{
return $this->blockingStatus;
}
public function setBlockingStatus(?string $blockingStatus): self
{
$this->blockingStatus = $blockingStatus;
return $this;
}
}