<?php
namespace App\Entity;
use App\Repository\ProductRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ProductRepository::class)
* @ORM\Table(indexes={@ORM\Index(name="name", columns={"category_id", "is_enabled", "sales"})})
* @ORM\Table(indexes={@ORM\Index(name="res", columns={"is_home", "is_enabled"})})
* 商品表
*/
class Product
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100, nullable=true, options={"comment"="名称"})
*/
private $name;
/**
* @ORM\Column(type="boolean", nullable=true, options={"comment"="状态", "default"=1})
*/
private $isEnabled = 1;
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true, options={"comment"="原始价格", "default"=0})
*/
private $oldPrice = 0;
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true, options={"comment"="价格", "default"=0})
*/
private $price = 0;
/**
* @ORM\Column(type="boolean", nullable=true, options={"comment"="是否上架售卖", "default"=1})
*/
private $isSell = 1;
/**
* @ORM\Column(type="text", nullable=true, options={"comment"="详情"})
*/
private $content;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="string", length=150, nullable=true, options={"comment"="商品图片"})
*/
private $image;
/**
* @ORM\Column(type="string", length=25, nullable=true, unique=true)
*/
private $sno;
/**
* @ORM\Column(type="json", nullable=true, options={"comment"="规格"})
*/
private $specs = [];
/**
* @ORM\Column(type="integer", nullable=true, options={"comment"="库存", "default"=0, "unsigned"=true})
*/
private $stock = 0;
/**
* @ORM\Column(type="integer", nullable=true, options={"comment"="销量", "default"=0})
*/
private $sales = 0;
/**
* @ORM\Column(type="integer", nullable=true, options={"comment"="实际销量", "default"=0})
*/
private $realSales = 0;
/**
* @ORM\Column(type="integer", nullable=true, options={"comment"="运费", "default"=0})
*/
private $shipping = 0;
/**
* @ORM\ManyToOne(targetEntity=ProductCategory::class)
*/
private $category;
/**
* @ORM\Column(type="json", nullable=true, options={"comment"="图片列表"})
*/
private $imageList = [];
/**
* @ORM\Column(type="string", length=150, nullable=true, options={"comment"="商品描述副标题"})
*/
private $descript;
/**
* @ORM\Column(type="boolean", nullable=true, options={"comment"="是否推荐商品", "default"=0})
*/
private $isHome = 0;
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
$this->sno = (new \DatetimeImmutable())->format('YmdHisu') . mt_rand(1000, 9999);
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getIsEnabled(): ?bool
{
return $this->isEnabled;
}
public function setIsEnabled(?bool $isEnabled): self
{
$this->isEnabled = $isEnabled;
return $this;
}
public function getOldPrice(): ?string
{
return $this->oldPrice;
}
public function setOldPrice(?string $oldPrice): self
{
$this->oldPrice = $oldPrice;
return $this;
}
public function getPrice(): ?string
{
return $this->price;
}
public function setPrice(?string $price): self
{
$this->price = $price;
return $this;
}
public function getIsSell(): ?bool
{
return $this->isSell;
}
public function setIsSell(?bool $isSell): self
{
$this->isSell = $isSell;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getSno(): ?string
{
return $this->sno;
}
public function setSno(?string $sno): self
{
$this->sno = $sno;
return $this;
}
public function getSpecs(): ?array
{
return $this->specs;
}
public function setSpecs(?array $specs): self
{
$this->specs = $specs;
return $this;
}
public function getStock(): ?int
{
return $this->stock;
}
public function setStock(?int $stock): self
{
$this->stock = $stock;
return $this;
}
public function getSales(): ?int
{
return $this->sales;
}
public function setSales(?int $sales): self
{
$this->sales = $sales;
return $this;
}
public function getRealSales(): ?int
{
return $this->realSales;
}
public function setRealSales(?int $realSales): self
{
$this->realSales = $realSales;
return $this;
}
public function getIsTj(): ?bool
{
return $this->isTj;
}
public function setIsTj(?bool $isTj): self
{
$this->isTj = $isTj;
return $this;
}
public function getShipping(): ?int
{
return $this->shipping;
}
public function setShipping(?int $shipping): self
{
$this->shipping = $shipping;
return $this;
}
public function getRewardRate(): ?int
{
return $this->rewardRate;
}
public function setRewardRate(?int $rewardRate): self
{
$this->rewardRate = $rewardRate;
return $this;
}
public function getCategory(): ?ProductCategory
{
return $this->category;
}
public function setCategory(?ProductCategory $category): self
{
$this->category = $category;
return $this;
}
public function getImageList(): ?array
{
return $this->imageList;
}
public function setImageList(?array $imageList): self
{
$this->imageList = $imageList;
return $this;
}
public function getDescript(): ?string
{
return $this->descript;
}
public function setDescript(?string $descript): self
{
$this->descript = $descript;
return $this;
}
public function isIsHome(): ?bool
{
return $this->isHome;
}
public function setIsHome(?bool $isHome): self
{
$this->isHome = $isHome;
return $this;
}
}