Files
kupshop/bundles/KupShop/SalesBundle/Entity/Sale.php
2025-08-02 16:30:27 +02:00

66 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace KupShop\SalesBundle\Entity;
use KupShop\CatalogBundle\ProductList\ProductCollection;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
use KupShop\KupShopBundle\Util\Price\TotalPrice;
use KupShop\SellerBundle\Utils\SellerUtil;
class Sale
{
public int $id;
public string $code;
public ?string $currency = null;
public ?string $languageId = null;
public \DateTimeImmutable $dateCreated;
public ?int $userId = null;
public ?int $orderId = null;
public ?int $deliveryTypeId = null;
public ?int $sellerId = null;
public TotalPrice $totalPrice;
public ?string $note = null;
public array $data;
public array $items;
public function __construct(
public ProductCollection $productCollection = new ProductCollection(),
) {
}
public function getUser(): ?\User
{
return $this->userId ? \User::createFromId($this->userId) : null;
}
public function getDeliveryType(): ?\DeliveryType
{
return $this->deliveryTypeId ? \DeliveryType::get($this->deliveryTypeId, true) : null;
}
public function getSeller(): ?array
{
if (!$this->sellerId) {
return null;
}
$sellerUtil = ServiceContainer::getService(SellerUtil::class);
return $sellerUtil->getSeller($this->sellerId);
}
}