<?php
namespace Slivki\Entity;
use Slivki\Enum\Order\PaymentType;
class OnlineOrderSettings extends Entity
{
protected $offer;
protected $minDeliverySum;
protected $minSumForFreeDelivery;
protected $deliveryPrice;
protected $pickupEnabled;
protected $deliveryEnabled;
protected $allowedPaymentMethods;
protected $orderPeriodInDays;
protected $pickupDiscountPercent;
protected $email;
protected $splitPayment;
protected $domain;
protected $merchantID;
protected $secretKey;
protected $schedule;
protected $deliveryTimeFrom;
protected $deliveryTimeTill;
protected $deliverySchedule;
protected $deliveryLeadType;
protected $deliveryLeadTime;
protected $deliveryIntervalBetweenOrdersType;
protected $deliveryIntervalBetweenOrdersTime;
protected $deliveryDisableType;
protected $deliveryDisableTime;
protected $deliveryNearlyEnabled;
protected ?string $deliveryPriceInfo = null;
protected ?string $deliveryWorkingTime = null;
protected ?string $pickupCookingTime = null;
protected ?array $receivingOrdersSchedule = null;
protected bool $pendingOrderAllowed = false;
protected ?int $pickupLeadTime = null;
protected ?string $priceCodeDependsOnOrder = null;
public function getOffer(): Offer
{
return $this->offer;
}
public function setOffer(Offer $offer): void
{
$this->offer = $offer;
}
public function getMinDeliverySum() {
return $this->minDeliverySum;
}
public function setMinDeliverySum($minDeliverySum) {
$this->minDeliverySum = $minDeliverySum;
}
public function getMinSumForFreeDelivery() {
return $this->minSumForFreeDelivery;
}
public function setMinSumForFreeDelivery($minSumForFreeDelivery) {
$this->minSumForFreeDelivery = $minSumForFreeDelivery;
}
public function getDeliveryPrice(): ?float
{
return $this->deliveryPrice;
}
public function setDeliveryPrice($deliveryPrice) {
$this->deliveryPrice = $deliveryPrice;
}
public function isPickupEnabled() {
return $this->pickupEnabled;
}
public function setPickupEnabled($pickupEnabled) {
$this->pickupEnabled = $pickupEnabled;
}
public function isDeliveryEnabled() {
return $this->deliveryEnabled;
}
public function setDeliveryEnabled($deliveryEnabled) {
$this->deliveryEnabled = $deliveryEnabled;
}
public function getAllowedPaymentMethods() {
if (!$this->allowedPaymentMethods) {
return [];
}
return json_decode($this->allowedPaymentMethods, true);
}
public function getAllowedPaymentMethodsString(): string
{
$allowedPaymentMethods = $this->getAllowedPaymentMethods();
if (0 === \count($allowedPaymentMethods)) {
return '';
}
$allowedPaymentMethodsStrings = [];
if ($allowedPaymentMethods['delivery'][PaymentType::ONLINE]) {
$allowedPaymentMethodsStrings[] = 'онлайн';
}
if ($allowedPaymentMethods['delivery'][PaymentType::CASH] && $allowedPaymentMethods['pickup'][PaymentType::CASH]) {
$allowedPaymentMethodsStrings[] = 'наличными на месте или курьеру';
} elseif ($allowedPaymentMethods['delivery'][PaymentType::CASH]) {
$allowedPaymentMethodsStrings[] = 'наличными курьеру';
} elseif ($allowedPaymentMethods['pickup'][PaymentType::CASH]) {
$allowedPaymentMethodsStrings[] = 'наличными на месте';
}
if ($allowedPaymentMethods['pickup'][PaymentType::TERMINAL]) {
$allowedPaymentMethodsStrings[] = 'картой на месте';
}
if ($allowedPaymentMethods['delivery'][PaymentType::TERMINAL]) {
$allowedPaymentMethodsStrings[] = 'через терминал курьеру';
}
return \implode(', ', $allowedPaymentMethodsStrings);
}
public function setAllowedPaymentMethods($allowedPaymentMethods) {
$this->allowedPaymentMethods = $allowedPaymentMethods;
}
public function getOrderPeriodInDays() {
return $this->orderPeriodInDays;
}
public function setOrderPeriodInDays($orderPeriodInDays) {
$this->orderPeriodInDays = $orderPeriodInDays;
}
public function getPickupDiscountPercent() {
return $this->pickupDiscountPercent;
}
public function setPickupDiscountPercent($pickupDiscountPercent) {
$this->pickupDiscountPercent = $pickupDiscountPercent;
}
public function getEmail() {
return $this->email;
}
public function setEmail($email) {
$this->email = $email;
}
public function isSplitPayment() {
return $this->splitPayment;
}
public function setSplitPayment($splitPayment) {
$this->splitPayment = $splitPayment;
}
public function getDomain() {
return $this->domain;
}
public function setDomain($domain) {
$this->domain = $domain;
}
public function getMerchantID() {
return $this->merchantID;
}
public function setMerchantID($merchantID) {
$this->merchantID = $merchantID;
return $this;
}
public function getSecretKey() {
return $this->secretKey;
}
public function setSecretKey($secretKey) {
$this->secretKey = $secretKey;
}
public function getDeliveryTimeFrom(): ?string
{
return $this->deliveryTimeFrom;
}
public function setDeliveryTimeFrom($deliveryTimeFrom): void
{
$this->deliveryTimeFrom = $deliveryTimeFrom;
}
public function getDeliveryTimeTill(): ?string
{
return $this->deliveryTimeTill;
}
public function setDeliveryTimeTill($deliveryTimeTill): void
{
$this->deliveryTimeTill = $deliveryTimeTill;
}
public function getSchedule()
{
return $this->schedule;
}
public function setSchedule($schedule)
{
$this->schedule = $schedule;
}
public function getDeliverySchedule()
{
return $this->deliverySchedule;
}
public function setDeliverySchedule($deliverySchedule)
{
$this->deliverySchedule = $deliverySchedule;
}
public function getDeliveryLeadType()
{
return $this->deliveryLeadType;
}
public function setDeliveryLeadType($deliveryLeadType)
{
$this->deliveryLeadType = $deliveryLeadType;
}
public function getDeliveryLeadTime()
{
return $this->deliveryLeadTime;
}
public function setDeliveryLeadTime($deliveryLeadTime)
{
$this->deliveryLeadTime = $deliveryLeadTime;
}
public function getDeliveryIntervalBetweenOrdersType()
{
return $this->deliveryIntervalBetweenOrdersType;
}
public function setDeliveryIntervalBetweenOrdersType($deliveryIntervalBetweenOrdersType)
{
$this->deliveryIntervalBetweenOrdersType = $deliveryIntervalBetweenOrdersType;
}
public function getDeliveryIntervalBetweenOrdersTime()
{
return $this->deliveryIntervalBetweenOrdersTime;
}
public function setDeliveryIntervalBetweenOrdersTime($deliveryIntervalBetweenOrdersTime)
{
$this->deliveryIntervalBetweenOrdersTime = $deliveryIntervalBetweenOrdersTime;
}
public function getDeliveryDisableType()
{
return $this->deliveryDisableType;
}
public function setDeliveryDisableType($deliveryDisableType)
{
$this->deliveryDisableType = $deliveryDisableType;
}
public function getDeliveryDisableTime()
{
return $this->deliveryDisableTime;
}
public function setDeliveryDisableTime($deliveryDisableTime)
{
$this->deliveryDisableTime = $deliveryDisableTime;
}
public function isDeliveryNearlyEnabled() {
return $this->deliveryNearlyEnabled;
}
public function setDeliveryNearlyEnabled($deliveryNearlyEnabled) {
$this->deliveryNearlyEnabled = $deliveryNearlyEnabled;
}
public function getDeliveryPriceInfo(): ?string
{
return $this->deliveryPriceInfo;
}
public function setDeliveryPriceInfo(?string $deliveryPriceInfo): void
{
$this->deliveryPriceInfo = $deliveryPriceInfo;
}
public function getDeliveryWorkingTime(): ?string
{
return $this->deliveryWorkingTime;
}
public function setDeliveryWorkingTime(?string $deliveryWorkingTime): void
{
$this->deliveryWorkingTime = $deliveryWorkingTime;
}
public function getPickupCookingTime(): ?string
{
return $this->pickupCookingTime;
}
public function setPickupCookingTime(?string $pickupCookingTime): void
{
$this->pickupCookingTime = $pickupCookingTime;
}
public function getReceivingOrdersSchedule(): ?array
{
return $this->receivingOrdersSchedule;
}
public function setReceivingOrdersSchedule(?array $receivingOrdersSchedule): void
{
$this->receivingOrdersSchedule = $receivingOrdersSchedule;
}
public function isPendingOrderAllowed(): bool
{
return $this->pendingOrderAllowed;
}
public function setPendingOrderAllowed(bool $pendingOrderAllowed): void
{
$this->pendingOrderAllowed = $pendingOrderAllowed;
}
public function getPickupLeadTime(): ?int
{
return $this->pickupLeadTime;
}
public function setPickupLeadTime(?int $pickupLeadTime): void
{
$this->pickupLeadTime = $pickupLeadTime;
}
public function getPriceCodeDependsOnOrder(): ?string
{
return $this->priceCodeDependsOnOrder;
}
public function setPriceCodeDependsOnOrder(?string $priceCodeDependsOnOrder): void
{
$this->priceCodeDependsOnOrder = $priceCodeDependsOnOrder;
}
public function jsonSerialize(): array
{
return [
'ID' => $this->ID,
'minDeliverySum' => $this->minDeliverySum,
'minSumForFreeDelivery' => $this->minSumForFreeDelivery,
'deliveryPrice' => $this->deliveryPrice,
'deliveryPriceInfo' => $this->deliveryPriceInfo,
'pickupEnabled' => $this->pickupEnabled,
'deliveryEnabled' => $this->deliveryEnabled,
'allowedPaymentMethods' => $this->allowedPaymentMethods,
'orderPeriodInDays' => $this->orderPeriodInDays,
'pickupDiscountPercent' => $this->pickupDiscountPercent,
'email' => $this->email,
'splitPayment' => $this->splitPayment,
'domain' => $this->domain,
'merchantID' => $this->merchantID,
'secretKey' => $this->secretKey,
'schedule' => $this->schedule,
'deliveryTimeFrom' => $this->deliveryTimeFrom,
'deliveryTimeTill' => $this->deliveryTimeTill,
'deliverySchedule' => $this->deliverySchedule,
'deliveryLeadType' => $this->deliveryLeadType,
'deliveryLeadTime' => $this->deliveryLeadTime,
'deliveryIntervalBetweenOrdersType' => $this->deliveryIntervalBetweenOrdersType,
'deliveryIntervalBetweenOrdersTime' => $this->deliveryIntervalBetweenOrdersTime,
'deliveryDisableType' => $this->deliveryDisableType,
'deliveryDisableTime' => $this->deliveryDisableTime,
'deliveryNearlyEnabled' => $this->deliveryNearlyEnabled,
'deliveryWorkingTime' => $this->deliveryWorkingTime,
'pickupCookingTime' => $this->pickupCookingTime,
'receivingOrdersSchedule' => $this->receivingOrdersSchedule,
'pendingOrderAllowed' => $this->pendingOrderAllowed,
'pickupLeadTime' => $this->pickupLeadTime,
'priceCodeDependsOnOrder' => $this->priceCodeDependsOnOrder,
];
}
}