app/proxy/entity/src/Eccube/Entity/Cart.php line 36

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Entity;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Eccube\Service\PurchaseFlow\InvalidItemException;
  16. use Eccube\Service\PurchaseFlow\ItemCollection;
  17.     /**
  18.      * Cart
  19.      *
  20.      * @ORM\Table(name="dtb_cart", indexes={
  21.      *     @ORM\Index(name="dtb_cart_update_date_idx", columns={"update_date"})
  22.      *  },
  23.      *  uniqueConstraints={
  24.      *     @ORM\UniqueConstraint(name="dtb_cart_pre_order_id_idx", columns={"pre_order_id"})
  25.      *  }))
  26.      * @ORM\InheritanceType("SINGLE_TABLE")
  27.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  28.      * @ORM\HasLifecycleCallbacks()
  29.      * @ORM\Entity(repositoryClass="Eccube\Repository\CartRepository")
  30.      */
  31.     class Cart extends AbstractEntity implements PurchaseInterfaceItemHolderInterface
  32.     {
  33.         use PointTrait\Customize\Entity\CartTrait;
  34.         /**
  35.          * @var integer
  36.          *
  37.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  38.          * @ORM\Id
  39.          * @ORM\GeneratedValue(strategy="IDENTITY")
  40.          */
  41.         private $id;
  42.         /**
  43.          * @var string
  44.          *
  45.          * @ORM\Column(name="cart_key", type="string", nullable=true)
  46.          */
  47.         private $cart_key;
  48.         /**
  49.          * @var \Eccube\Entity\Customer
  50.          *
  51.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer")
  52.          * @ORM\JoinColumns({
  53.          *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
  54.          * })
  55.          */
  56.         private $Customer;
  57.         /**
  58.          * @var bool
  59.          */
  60.         private $lock false;
  61.         /**
  62.          * @var \Doctrine\Common\Collections\Collection|CartItem[]
  63.          *
  64.          * @ORM\OneToMany(targetEntity="Eccube\Entity\CartItem", mappedBy="Cart", cascade={"persist"})
  65.          * @ORM\OrderBy({"id" = "ASC"})
  66.          */
  67.         private $CartItems;
  68.         /**
  69.          * @var string|null
  70.          *
  71.          * @ORM\Column(name="pre_order_id", type="string", length=255, nullable=true)
  72.          */
  73.         private $pre_order_id null;
  74.         /**
  75.          * @var string
  76.          *
  77.          * @ORM\Column(name="total_price", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  78.          */
  79.         private $total_price;
  80.         /**
  81.          * @var string
  82.          *
  83.          * @ORM\Column(name="delivery_fee_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  84.          */
  85.         private $delivery_fee_total;
  86.         /**
  87.          * @var int|null
  88.          *
  89.          * @ORM\Column(name="sort_no", type="smallint", nullable=true, options={"unsigned":true})
  90.          */
  91.         private $sort_no;
  92.         /**
  93.          * @var \DateTime
  94.          *
  95.          * @ORM\Column(name="create_date", type="datetimetz")
  96.          */
  97.         private $create_date;
  98.         /**
  99.          * @var \DateTime
  100.          *
  101.          * @ORM\Column(name="update_date", type="datetimetz")
  102.          */
  103.         private $update_date;
  104.         /**
  105.          * @var InvalidItemException[]
  106.          */
  107.         private $errors = [];
  108.         public function __wakeup()
  109.         {
  110.             $this->errors = [];
  111.         }
  112.         public function __construct()
  113.         {
  114.             $this->CartItems = new ArrayCollection();
  115.         }
  116.         /**
  117.          * @return int
  118.          */
  119.         public function getId()
  120.         {
  121.             return $this->id;
  122.         }
  123.         /**
  124.          * @return string
  125.          */
  126.         public function getCartKey()
  127.         {
  128.             return $this->cart_key;
  129.         }
  130.         /**
  131.          * @param string $cartKey
  132.          */
  133.         public function setCartKey(string $cartKey)
  134.         {
  135.             $this->cart_key $cartKey;
  136.             return $this;
  137.         }
  138.         /**
  139.          * @return bool
  140.          *
  141.          * @deprecated 使用しないので削除予定
  142.          */
  143.         public function getLock()
  144.         {
  145.             return $this->lock;
  146.         }
  147.         /**
  148.          * @param  bool                $lock
  149.          *
  150.          * @return \Eccube\Entity\Cart
  151.          *
  152.          * @deprecated 使用しないので削除予定
  153.          */
  154.         public function setLock($lock)
  155.         {
  156.             $this->lock $lock;
  157.             return $this;
  158.         }
  159.         /**
  160.          * @return string|null
  161.          */
  162.         public function getPreOrderId()
  163.         {
  164.             return $this->pre_order_id;
  165.         }
  166.         /**
  167.          * @param  integer             $pre_order_id
  168.          *
  169.          * @return \Eccube\Entity\Cart
  170.          */
  171.         public function setPreOrderId($pre_order_id)
  172.         {
  173.             $this->pre_order_id $pre_order_id;
  174.             return $this;
  175.         }
  176.         /**
  177.          * @param  CartItem            $CartItem
  178.          *
  179.          * @return \Eccube\Entity\Cart
  180.          */
  181.         public function addCartItem(CartItem $CartItem)
  182.         {
  183.             $this->CartItems[] = $CartItem;
  184.             return $this;
  185.         }
  186.         /**
  187.          * @return \Eccube\Entity\Cart
  188.          */
  189.         public function clearCartItems()
  190.         {
  191.             $this->CartItems->clear();
  192.             return $this;
  193.         }
  194.         /**
  195.          * @return ArrayCollection|CartItem[]
  196.          */
  197.         public function getCartItems()
  198.         {
  199.             return $this->CartItems;
  200.         }
  201.         /**
  202.          * Alias of getCartItems()
  203.          */
  204.         public function getItems()
  205.         {
  206.             return (new ItemCollection($this->getCartItems()))->sort();
  207.         }
  208.         /**
  209.          * @param  CartItem[]          $CartItems
  210.          *
  211.          * @return \Eccube\Entity\Cart
  212.          */
  213.         public function setCartItems($CartItems)
  214.         {
  215.             $this->CartItems $CartItems;
  216.             return $this;
  217.         }
  218.         /**
  219.          * Set total.
  220.          *
  221.          * @param integer $total_price
  222.          *
  223.          * @return Cart
  224.          */
  225.         public function setTotalPrice($total_price)
  226.         {
  227.             $this->total_price $total_price;
  228.             return $this;
  229.         }
  230.         /**
  231.          * @return string
  232.          */
  233.         public function getTotalPrice()
  234.         {
  235.             return $this->total_price;
  236.         }
  237.         /**
  238.          * Alias of setTotalPrice.
  239.          */
  240.         public function setTotal($total)
  241.         {
  242.             return $this->setTotalPrice($total);
  243.         }
  244.         /**
  245.          * Alias of getTotalPrice
  246.          */
  247.         public function getTotal()
  248.         {
  249.             return $this->getTotalPrice();
  250.         }
  251.         /**
  252.          * @return integer
  253.          */
  254.         public function getTotalQuantity()
  255.         {
  256.             $totalQuantity 0;
  257.             foreach ($this->CartItems as $CartItem) {
  258.                 $totalQuantity += $CartItem->getQuantity();
  259.             }
  260.             return $totalQuantity;
  261.         }
  262.         /**
  263.          * @param ItemInterface $item
  264.          */
  265.         public function addItem(ItemInterface $item)
  266.         {
  267.             $this->CartItems->add($item);
  268.         }
  269.         /**
  270.          * @param ItemInterface $item
  271.          */
  272.         public function removeItem(ItemInterface $item)
  273.         {
  274.             $this->CartItems->removeElement($item);
  275.         }
  276.         /**
  277.          * 個数の合計を返します。
  278.          *
  279.          * @return integer
  280.          */
  281.         public function getQuantity()
  282.         {
  283.             return $this->getTotalQuantity();
  284.         }
  285.         /**
  286.          * {@inheritdoc}
  287.          */
  288.         public function setDeliveryFeeTotal($total)
  289.         {
  290.             $this->delivery_fee_total $total;
  291.             return $this;
  292.         }
  293.         /**
  294.          * {@inheritdoc}
  295.          */
  296.         public function getDeliveryFeeTotal()
  297.         {
  298.             return $this->delivery_fee_total;
  299.         }
  300.         /**
  301.          * @return Customer|null
  302.          */
  303.         public function getCustomer(): ?Customer
  304.         {
  305.             return $this->Customer;
  306.         }
  307.         /**
  308.          * @param Customer $Customer
  309.          */
  310.         public function setCustomer(Customer $Customer null)
  311.         {
  312.             $this->Customer $Customer;
  313.             return $this;
  314.         }
  315.         /**
  316.          * Set sortNo.
  317.          *
  318.          * @param int|null $sortNo
  319.          *
  320.          * @return Cart
  321.          */
  322.         public function setSortNo($sortNo null)
  323.         {
  324.             $this->sort_no $sortNo;
  325.             return $this;
  326.         }
  327.         /**
  328.          * Get sortNo.
  329.          *
  330.          * @return int|null
  331.          */
  332.         public function getSortNo()
  333.         {
  334.             return $this->sort_no;
  335.         }
  336.         /**
  337.          * Set createDate.
  338.          *
  339.          * @param \DateTime $createDate
  340.          *
  341.          * @return Cart
  342.          */
  343.         public function setCreateDate($createDate)
  344.         {
  345.             $this->create_date $createDate;
  346.             return $this;
  347.         }
  348.         /**
  349.          * Get createDate.
  350.          *
  351.          * @return \DateTime
  352.          */
  353.         public function getCreateDate()
  354.         {
  355.             return $this->create_date;
  356.         }
  357.         /**
  358.          * Set updateDate.
  359.          *
  360.          * @param \DateTime $updateDate
  361.          *
  362.          * @return Cart
  363.          */
  364.         public function setUpdateDate($updateDate)
  365.         {
  366.             $this->update_date $updateDate;
  367.             return $this;
  368.         }
  369.         /**
  370.          * Get updateDate.
  371.          *
  372.          * @return \DateTime
  373.          */
  374.         public function getUpdateDate()
  375.         {
  376.             return $this->update_date;
  377.         }
  378.         /**
  379.          * {@inheritdoc}
  380.          */
  381.         public function setDiscount($total)
  382.         {
  383.             // TODO quiet
  384.         }
  385.         /**
  386.          * {@inheritdoc}
  387.          */
  388.         public function setCharge($total)
  389.         {
  390.             // TODO quiet
  391.         }
  392.         /**
  393.          * {@inheritdoc}
  394.          *
  395.          * @deprecated
  396.          */
  397.         public function setTax($total)
  398.         {
  399.             // TODO quiet
  400.         }
  401.     }