src/Entity/Product.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=ProductRepository::class)
  7.  * @ORM\Table(indexes={@ORM\Index(name="name", columns={"category_id", "is_enabled", "sales"})})
  8.  * @ORM\Table(indexes={@ORM\Index(name="res", columns={"is_home", "is_enabled"})})
  9.  * 商品表
  10.  */
  11. class Product
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=100, nullable=true, options={"comment"="名称"})
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\Column(type="boolean", nullable=true, options={"comment"="状态", "default"=1})
  25.      */
  26.     private $isEnabled 1;
  27.     /**
  28.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true, options={"comment"="原始价格", "default"=0})
  29.      */
  30.     private $oldPrice 0;
  31.     /**
  32.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true, options={"comment"="价格", "default"=0})
  33.      */
  34.     private $price 0;
  35.     /**
  36.      * @ORM\Column(type="boolean", nullable=true, options={"comment"="是否上架售卖", "default"=1})
  37.      */
  38.     private $isSell 1;
  39.     /**
  40.      * @ORM\Column(type="text", nullable=true, options={"comment"="详情"})
  41.      */
  42.     private $content;
  43.     /**
  44.      * @ORM\Column(type="datetime_immutable", nullable=true)
  45.      */
  46.     private $createdAt;
  47.     /**
  48.      * @ORM\Column(type="string", length=150, nullable=true, options={"comment"="商品图片"})
  49.      */
  50.     private $image;
  51.     /**
  52.      * @ORM\Column(type="string", length=25, nullable=true, unique=true)
  53.      */
  54.     private $sno;
  55.     /**
  56.      * @ORM\Column(type="json", nullable=true, options={"comment"="规格"})
  57.      */
  58.     private $specs = [];
  59.     /**
  60.      * @ORM\Column(type="integer", nullable=true, options={"comment"="库存", "default"=0, "unsigned"=true})
  61.      */
  62.     private $stock 0;
  63.     /**
  64.      * @ORM\Column(type="integer", nullable=true, options={"comment"="销量", "default"=0})
  65.      */
  66.     private $sales 0;
  67.     /**
  68.      * @ORM\Column(type="integer", nullable=true, options={"comment"="实际销量", "default"=0})
  69.      */
  70.     private $realSales 0;
  71.     /**
  72.      * @ORM\Column(type="integer", nullable=true, options={"comment"="运费", "default"=0})
  73.      */
  74.     private $shipping 0;
  75.     /**
  76.      * @ORM\ManyToOne(targetEntity=ProductCategory::class)
  77.      */
  78.     private $category;
  79.     /**
  80.      * @ORM\Column(type="json", nullable=true, options={"comment"="图片列表"})
  81.      */
  82.     private $imageList = [];
  83.     
  84.     /**
  85.      * @ORM\Column(type="string", length=150, nullable=true, options={"comment"="商品描述副标题"})
  86.      */
  87.     private $descript;
  88.     /**
  89.      * @ORM\Column(type="boolean", nullable=true, options={"comment"="是否推荐商品", "default"=0})
  90.      */
  91.     private $isHome 0;
  92.     public function __construct()
  93.     {
  94.         $this->createdAt = new \DateTimeImmutable();
  95.         $this->sno = (new \DatetimeImmutable())->format('YmdHisu') . mt_rand(10009999);
  96.     }    
  97.     public function getId(): ?int
  98.     {
  99.         return $this->id;
  100.     }
  101.     public function getName(): ?string
  102.     {
  103.         return $this->name;
  104.     }
  105.     public function setName(?string $name): self
  106.     {
  107.         $this->name $name;
  108.         return $this;
  109.     }
  110.     public function getIsEnabled(): ?bool
  111.     {
  112.         return $this->isEnabled;
  113.     }
  114.     public function setIsEnabled(?bool $isEnabled): self
  115.     {
  116.         $this->isEnabled $isEnabled;
  117.         return $this;
  118.     }
  119.     public function getOldPrice(): ?string
  120.     {
  121.         return $this->oldPrice;
  122.     }
  123.     public function setOldPrice(?string $oldPrice): self
  124.     {
  125.         $this->oldPrice $oldPrice;
  126.         return $this;
  127.     }
  128.     public function getPrice(): ?string
  129.     {
  130.         return $this->price;
  131.     }
  132.     public function setPrice(?string $price): self
  133.     {
  134.         $this->price $price;
  135.         return $this;
  136.     }
  137.     public function getIsSell(): ?bool
  138.     {
  139.         return $this->isSell;
  140.     }
  141.     public function setIsSell(?bool $isSell): self
  142.     {
  143.         $this->isSell $isSell;
  144.         return $this;
  145.     }
  146.     public function getContent(): ?string
  147.     {
  148.         return $this->content;
  149.     }
  150.     public function setContent(?string $content): self
  151.     {
  152.         $this->content $content;
  153.         return $this;
  154.     }
  155.     public function getCreatedAt(): ?\DateTimeImmutable
  156.     {
  157.         return $this->createdAt;
  158.     }
  159.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  160.     {
  161.         $this->createdAt $createdAt;
  162.         return $this;
  163.     }
  164.     public function getImage(): ?string
  165.     {
  166.         return $this->image;
  167.     }
  168.     public function setImage(?string $image): self
  169.     {
  170.         $this->image $image;
  171.         return $this;
  172.     }
  173.     public function getSno(): ?string
  174.     {
  175.         return $this->sno;
  176.     }
  177.     public function setSno(?string $sno): self
  178.     {
  179.         $this->sno $sno;
  180.         return $this;
  181.     }
  182.     public function getSpecs(): ?array
  183.     {
  184.         return $this->specs;
  185.     }
  186.     public function setSpecs(?array $specs): self
  187.     {
  188.         $this->specs $specs;
  189.         return $this;
  190.     }
  191.     public function getStock(): ?int
  192.     {
  193.         return $this->stock;
  194.     }
  195.     public function setStock(?int $stock): self
  196.     {
  197.         $this->stock $stock;
  198.         return $this;
  199.     }
  200.     public function getSales(): ?int
  201.     {
  202.         return $this->sales;
  203.     }
  204.     public function setSales(?int $sales): self
  205.     {
  206.         $this->sales $sales;
  207.         return $this;
  208.     }
  209.     public function getRealSales(): ?int
  210.     {
  211.         return $this->realSales;
  212.     }
  213.     public function setRealSales(?int $realSales): self
  214.     {
  215.         $this->realSales $realSales;
  216.         return $this;
  217.     }
  218.     public function getIsTj(): ?bool
  219.     {
  220.         return $this->isTj;
  221.     }
  222.     public function setIsTj(?bool $isTj): self
  223.     {
  224.         $this->isTj $isTj;
  225.         return $this;
  226.     }
  227.     public function getShipping(): ?int
  228.     {
  229.         return $this->shipping;
  230.     }
  231.     public function setShipping(?int $shipping): self
  232.     {
  233.         $this->shipping $shipping;
  234.         return $this;
  235.     }
  236.     public function getRewardRate(): ?int
  237.     {
  238.         return $this->rewardRate;
  239.     }
  240.     public function setRewardRate(?int $rewardRate): self
  241.     {
  242.         $this->rewardRate $rewardRate;
  243.         return $this;
  244.     }
  245.     public function getCategory(): ?ProductCategory
  246.     {
  247.         return $this->category;
  248.     }
  249.     public function setCategory(?ProductCategory $category): self
  250.     {
  251.         $this->category $category;
  252.         return $this;
  253.     }
  254.     public function getImageList(): ?array
  255.     {
  256.         return $this->imageList;
  257.     }
  258.     public function setImageList(?array $imageList): self
  259.     {
  260.         $this->imageList $imageList;
  261.         return $this;
  262.     }   
  263.     public function getDescript(): ?string
  264.     {
  265.         return $this->descript;
  266.     }
  267.     public function setDescript(?string $descript): self
  268.     {
  269.         $this->descript $descript;
  270.         return $this;
  271.     }
  272.     public function isIsHome(): ?bool
  273.     {
  274.         return $this->isHome;
  275.     }
  276.     public function setIsHome(?bool $isHome): self
  277.     {
  278.         $this->isHome $isHome;
  279.         return $this;
  280.     }
  281. }