src/Eccube/Entity/OrderItem.php line 31

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\ORM\Mapping as ORM;
  14. use Eccube\Entity\Master\OrderItemType;
  15. use Eccube\Entity\Master\RoundingType;
  16. use Eccube\Entity\Master\TaxDisplayType;
  17. if (!class_exists('\Eccube\Entity\OrderItem')) {
  18.     /**
  19.      * OrderItem
  20.      *
  21.      * @ORM\Table(name="dtb_order_item")
  22.      * @ORM\InheritanceType("SINGLE_TABLE")
  23.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  24.      * @ORM\HasLifecycleCallbacks()
  25.      * @ORM\Entity(repositoryClass="Eccube\Repository\OrderItemRepository")
  26.      */
  27.     class OrderItem extends \Eccube\Entity\AbstractEntity implements ItemInterface
  28.     {
  29.         use PointRateTrait;
  30.         /**
  31.          * Get price IncTax
  32.          *
  33.          * @return string
  34.          */
  35.         public function getPriceIncTax()
  36.         {
  37.             // 税表示区分が税込の場合は, priceに税込金額が入っている.
  38.             if ($this->TaxDisplayType && $this->TaxDisplayType->getId() == TaxDisplayType::INCLUDED) {
  39.                 return $this->price;
  40.             }
  41.             return $this->price $this->tax;
  42.         }
  43.         /**
  44.          * @return integer
  45.          */
  46.         public function getTotalPrice()
  47.         {
  48.             return $this->getPriceIncTax() * $this->getQuantity();
  49.         }
  50.         /**
  51.          * @return integer
  52.          */
  53.         public function getOrderItemTypeId()
  54.         {
  55.             if (is_object($this->getOrderItemType())) {
  56.                 return $this->getOrderItemType()->getId();
  57.             }
  58.             return null;
  59.         }
  60.         /**
  61.          * 商品明細かどうか.
  62.          *
  63.          * @return boolean 商品明細の場合 true
  64.          */
  65.         public function isProduct()
  66.         {
  67.             return $this->getOrderItemTypeId() === OrderItemType::PRODUCT;
  68.         }
  69.         /**
  70.          * 送料明細かどうか.
  71.          *
  72.          * @return boolean 送料明細の場合 true
  73.          */
  74.         public function isDeliveryFee()
  75.         {
  76.             return $this->getOrderItemTypeId() === OrderItemType::DELIVERY_FEE;
  77.         }
  78.         /**
  79.          * 手数料明細かどうか.
  80.          *
  81.          * @return boolean 手数料明細の場合 true
  82.          */
  83.         public function isCharge()
  84.         {
  85.             return $this->getOrderItemTypeId() === OrderItemType::CHARGE;
  86.         }
  87.         /**
  88.          * 値引き明細かどうか.
  89.          *
  90.          * @return boolean 値引き明細の場合 true
  91.          */
  92.         public function isDiscount()
  93.         {
  94.             return $this->getOrderItemTypeId() === OrderItemType::DISCOUNT;
  95.         }
  96.         /**
  97.          * 税額明細かどうか.
  98.          *
  99.          * @return boolean 税額明細の場合 true
  100.          */
  101.         public function isTax()
  102.         {
  103.             return $this->getOrderItemTypeId() === OrderItemType::TAX;
  104.         }
  105.         /**
  106.          * ポイント明細かどうか.
  107.          *
  108.          * @return boolean ポイント明細の場合 true
  109.          */
  110.         public function isPoint()
  111.         {
  112.             return $this->getOrderItemTypeId() === OrderItemType::POINT;
  113.         }
  114.         /**
  115.          * @var integer
  116.          *
  117.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  118.          * @ORM\Id
  119.          * @ORM\GeneratedValue(strategy="IDENTITY")
  120.          */
  121.         private $id;
  122.         /**
  123.          * @var string
  124.          *
  125.          * @ORM\Column(name="product_name", type="string", length=255)
  126.          */
  127.         private $product_name;
  128.         /**
  129.          * @var string|null
  130.          *
  131.          * @ORM\Column(name="product_code", type="string", length=255, nullable=true)
  132.          */
  133.         private $product_code;
  134.         /**
  135.          * @var string|null
  136.          *
  137.          * @ORM\Column(name="class_name1", type="string", length=255, nullable=true)
  138.          */
  139.         private $class_name1;
  140.         /**
  141.          * @var string|null
  142.          *
  143.          * @ORM\Column(name="class_name2", type="string", length=255, nullable=true)
  144.          */
  145.         private $class_name2;
  146.         /**
  147.          * @var string|null
  148.          *
  149.          * @ORM\Column(name="class_category_name1", type="string", length=255, nullable=true)
  150.          */
  151.         private $class_category_name1;
  152.         /**
  153.          * @var string|null
  154.          *
  155.          * @ORM\Column(name="class_category_name2", type="string", length=255, nullable=true)
  156.          */
  157.         private $class_category_name2;
  158.         /**
  159.          * @var string
  160.          *
  161.          * @ORM\Column(name="price", type="decimal", precision=12, scale=2, options={"default":0})
  162.          */
  163.         private $price 0;
  164.         /**
  165.          * @var string
  166.          *
  167.          * @ORM\Column(name="quantity", type="decimal", precision=10, scale=0, options={"default":0})
  168.          */
  169.         private $quantity 0;
  170.         /**
  171.          * @var string
  172.          *
  173.          * @ORM\Column(name="tax", type="decimal", precision=10, scale=0, options={"default":0})
  174.          */
  175.         private $tax 0;
  176.         /**
  177.          * @var string
  178.          *
  179.          * @ORM\Column(name="tax_rate", type="decimal", precision=10, scale=0, options={"unsigned":true,"default":0})
  180.          */
  181.         private $tax_rate 0;
  182.         /**
  183.          * @var string
  184.          *
  185.          * @ORM\Column(name="tax_adjust", type="decimal", precision=10, scale=0, options={"unsigned":true,"default":0})
  186.          */
  187.         private $tax_adjust 0;
  188.         /**
  189.          * @var int|null
  190.          *
  191.          * @ORM\Column(name="tax_rule_id", type="smallint", nullable=true, options={"unsigned":true})
  192.          */
  193.         private $tax_rule_id;
  194.         /**
  195.          * @var string|null
  196.          *
  197.          * @ORM\Column(name="currency_code", type="string", nullable=true)
  198.          */
  199.         private $currency_code;
  200.         /**
  201.          * @var string|null
  202.          *
  203.          * @ORM\Column(name="processor_name", type="string", nullable=true)
  204.          */
  205.         private $processor_name;
  206.         /**
  207.          * @var \Eccube\Entity\Order
  208.          *
  209.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Order", inversedBy="OrderItems")
  210.          * @ORM\JoinColumns({
  211.          *   @ORM\JoinColumn(name="order_id", referencedColumnName="id")
  212.          * })
  213.          */
  214.         private $Order;
  215.         /**
  216.          * @var \Eccube\Entity\Product
  217.          *
  218.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Product")
  219.          * @ORM\JoinColumns({
  220.          *   @ORM\JoinColumn(name="product_id", referencedColumnName="id")
  221.          * })
  222.          */
  223.         private $Product;
  224.         /**
  225.          * @var \Eccube\Entity\ProductClass
  226.          *
  227.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\ProductClass")
  228.          * @ORM\JoinColumns({
  229.          *   @ORM\JoinColumn(name="product_class_id", referencedColumnName="id")
  230.          * })
  231.          */
  232.         private $ProductClass;
  233.         /**
  234.          * @var \Eccube\Entity\Shipping
  235.          *
  236.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Shipping", inversedBy="OrderItems")
  237.          * @ORM\JoinColumns({
  238.          *   @ORM\JoinColumn(name="shipping_id", referencedColumnName="id")
  239.          * })
  240.          */
  241.         private $Shipping;
  242.         /**
  243.          * @var \Eccube\Entity\Master\RoundingType
  244.          *
  245.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\RoundingType")
  246.          * @ORM\JoinColumns({
  247.          *   @ORM\JoinColumn(name="rounding_type_id", referencedColumnName="id")
  248.          * })
  249.          */
  250.         private $RoundingType;
  251.         /**
  252.          * @var \Eccube\Entity\Master\TaxType
  253.          *
  254.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxType")
  255.          * @ORM\JoinColumns({
  256.          *   @ORM\JoinColumn(name="tax_type_id", referencedColumnName="id")
  257.          * })
  258.          */
  259.         private $TaxType;
  260.         /**
  261.          * @var \Eccube\Entity\Master\TaxDisplayType
  262.          *
  263.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxDisplayType")
  264.          * @ORM\JoinColumns({
  265.          *   @ORM\JoinColumn(name="tax_display_type_id", referencedColumnName="id")
  266.          * })
  267.          */
  268.         private $TaxDisplayType;
  269.         /**
  270.          * @var \Eccube\Entity\Master\OrderItemType
  271.          *
  272.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderItemType")
  273.          * @ORM\JoinColumns({
  274.          *   @ORM\JoinColumn(name="order_item_type_id", referencedColumnName="id")
  275.          * })
  276.          */
  277.         private $OrderItemType;
  278.         /**
  279.          * Get id.
  280.          *
  281.          * @return int
  282.          */
  283.         public function getId()
  284.         {
  285.             return $this->id;
  286.         }
  287.         /**
  288.          * Set productName.
  289.          *
  290.          * @param string $productName
  291.          *
  292.          * @return OrderItem
  293.          */
  294.         public function setProductName($productName)
  295.         {
  296.             $this->product_name $productName;
  297.             return $this;
  298.         }
  299.         /**
  300.          * Get productName.
  301.          *
  302.          * @return string
  303.          */
  304.         public function getProductName()
  305.         {
  306.             return $this->product_name;
  307.         }
  308.         /**
  309.          * Set productCode.
  310.          *
  311.          * @param string|null $productCode
  312.          *
  313.          * @return OrderItem
  314.          */
  315.         public function setProductCode($productCode null)
  316.         {
  317.             $this->product_code $productCode;
  318.             return $this;
  319.         }
  320.         /**
  321.          * Get productCode.
  322.          *
  323.          * @return string|null
  324.          */
  325.         public function getProductCode()
  326.         {
  327.             return $this->product_code;
  328.         }
  329.         /**
  330.          * Set className1.
  331.          *
  332.          * @param string|null $className1
  333.          *
  334.          * @return OrderItem
  335.          */
  336.         public function setClassName1($className1 null)
  337.         {
  338.             $this->class_name1 $className1;
  339.             return $this;
  340.         }
  341.         /**
  342.          * Get className1.
  343.          *
  344.          * @return string|null
  345.          */
  346.         public function getClassName1()
  347.         {
  348.             return $this->class_name1;
  349.         }
  350.         /**
  351.          * Set className2.
  352.          *
  353.          * @param string|null $className2
  354.          *
  355.          * @return OrderItem
  356.          */
  357.         public function setClassName2($className2 null)
  358.         {
  359.             $this->class_name2 $className2;
  360.             return $this;
  361.         }
  362.         /**
  363.          * Get className2.
  364.          *
  365.          * @return string|null
  366.          */
  367.         public function getClassName2()
  368.         {
  369.             return $this->class_name2;
  370.         }
  371.         /**
  372.          * Set classCategoryName1.
  373.          *
  374.          * @param string|null $classCategoryName1
  375.          *
  376.          * @return OrderItem
  377.          */
  378.         public function setClassCategoryName1($classCategoryName1 null)
  379.         {
  380.             $this->class_category_name1 $classCategoryName1;
  381.             return $this;
  382.         }
  383.         /**
  384.          * Get classCategoryName1.
  385.          *
  386.          * @return string|null
  387.          */
  388.         public function getClassCategoryName1()
  389.         {
  390.             return $this->class_category_name1;
  391.         }
  392.         /**
  393.          * Set classCategoryName2.
  394.          *
  395.          * @param string|null $classCategoryName2
  396.          *
  397.          * @return OrderItem
  398.          */
  399.         public function setClassCategoryName2($classCategoryName2 null)
  400.         {
  401.             $this->class_category_name2 $classCategoryName2;
  402.             return $this;
  403.         }
  404.         /**
  405.          * Get classCategoryName2.
  406.          *
  407.          * @return string|null
  408.          */
  409.         public function getClassCategoryName2()
  410.         {
  411.             return $this->class_category_name2;
  412.         }
  413.         /**
  414.          * Set price.
  415.          *
  416.          * @param string $price
  417.          *
  418.          * @return OrderItem
  419.          */
  420.         public function setPrice($price)
  421.         {
  422.             $this->price $price;
  423.             return $this;
  424.         }
  425.         /**
  426.          * Get price.
  427.          *
  428.          * @return string
  429.          */
  430.         public function getPrice()
  431.         {
  432.             return $this->price;
  433.         }
  434.         /**
  435.          * Set quantity.
  436.          *
  437.          * @param string $quantity
  438.          *
  439.          * @return OrderItem
  440.          */
  441.         public function setQuantity($quantity)
  442.         {
  443.             $this->quantity $quantity;
  444.             return $this;
  445.         }
  446.         /**
  447.          * Get quantity.
  448.          *
  449.          * @return string
  450.          */
  451.         public function getQuantity()
  452.         {
  453.             return $this->quantity;
  454.         }
  455.         /**
  456.          * @return string
  457.          */
  458.         public function getTax()
  459.         {
  460.             return $this->tax;
  461.         }
  462.         /**
  463.          * @param string $tax
  464.          *
  465.          * @return $this
  466.          */
  467.         public function setTax($tax)
  468.         {
  469.             $this->tax $tax;
  470.             return $this;
  471.         }
  472.         /**
  473.          * Set taxRate.
  474.          *
  475.          * @param string $taxRate
  476.          *
  477.          * @return OrderItem
  478.          */
  479.         public function setTaxRate($taxRate)
  480.         {
  481.             $this->tax_rate $taxRate;
  482.             return $this;
  483.         }
  484.         /**
  485.          * Get taxRate.
  486.          *
  487.          * @return string
  488.          */
  489.         public function getTaxRate()
  490.         {
  491.             return $this->tax_rate;
  492.         }
  493.         /**
  494.          * Set taxAdjust.
  495.          *
  496.          * @param string $tax_adjust
  497.          *
  498.          * @return OrderItem
  499.          */
  500.         public function setTaxAdjust($tax_adjust)
  501.         {
  502.             $this->tax_adjust $tax_adjust;
  503.             return $this;
  504.         }
  505.         /**
  506.          * Get taxAdjust.
  507.          *
  508.          * @return string
  509.          */
  510.         public function getTaxAdjust()
  511.         {
  512.             return $this->tax_adjust;
  513.         }
  514.         /**
  515.          * Set taxRuleId.
  516.          *
  517.          * @deprecated 税率設定は受注作成時に決定するため廃止予定
  518.          *
  519.          * @param int|null $taxRuleId
  520.          *
  521.          * @return OrderItem
  522.          */
  523.         public function setTaxRuleId($taxRuleId null)
  524.         {
  525.             $this->tax_rule_id $taxRuleId;
  526.             return $this;
  527.         }
  528.         /**
  529.          * Get taxRuleId.
  530.          *
  531.          * @deprecated 税率設定は受注作成時に決定するため廃止予定
  532.          *
  533.          * @return int|null
  534.          */
  535.         public function getTaxRuleId()
  536.         {
  537.             return $this->tax_rule_id;
  538.         }
  539.         /**
  540.          * Get currencyCode.
  541.          *
  542.          * @return string
  543.          */
  544.         public function getCurrencyCode()
  545.         {
  546.             return $this->currency_code;
  547.         }
  548.         /**
  549.          * Set currencyCode.
  550.          *
  551.          * @param string|null $currencyCode
  552.          *
  553.          * @return OrderItem
  554.          */
  555.         public function setCurrencyCode($currencyCode null)
  556.         {
  557.             $this->currency_code $currencyCode;
  558.             return $this;
  559.         }
  560.         /**
  561.          * Get processorName.
  562.          *
  563.          * @return string
  564.          */
  565.         public function getProcessorName()
  566.         {
  567.             return $this->processor_name;
  568.         }
  569.         /**
  570.          * Set processorName.
  571.          *
  572.          * @param string|null $processorName
  573.          *
  574.          * @return $this
  575.          */
  576.         public function setProcessorName($processorName null)
  577.         {
  578.             $this->processor_name $processorName;
  579.             return $this;
  580.         }
  581.         /**
  582.          * Set order.
  583.          *
  584.          * @param \Eccube\Entity\Order|null $order
  585.          *
  586.          * @return OrderItem
  587.          */
  588.         public function setOrder(Order $order null)
  589.         {
  590.             $this->Order $order;
  591.             return $this;
  592.         }
  593.         /**
  594.          * Get order.
  595.          *
  596.          * @return \Eccube\Entity\Order|null
  597.          */
  598.         public function getOrder()
  599.         {
  600.             return $this->Order;
  601.         }
  602.         public function getOrderId()
  603.         {
  604.             if (is_object($this->getOrder())) {
  605.                 return $this->getOrder()->getId();
  606.             }
  607.             return null;
  608.         }
  609.         /**
  610.          * Set product.
  611.          *
  612.          * @param \Eccube\Entity\Product|null $product
  613.          *
  614.          * @return OrderItem
  615.          */
  616.         public function setProduct(Product $product null)
  617.         {
  618.             $this->Product $product;
  619.             return $this;
  620.         }
  621.         /**
  622.          * Get product.
  623.          *
  624.          * @return \Eccube\Entity\Product|null
  625.          */
  626.         public function getProduct()
  627.         {
  628.             return $this->Product;
  629.         }
  630.         /**
  631.          * Set productClass.
  632.          *
  633.          * @param \Eccube\Entity\ProductClass|null $productClass
  634.          *
  635.          * @return OrderItem
  636.          */
  637.         public function setProductClass(ProductClass $productClass null)
  638.         {
  639.             $this->ProductClass $productClass;
  640.             return $this;
  641.         }
  642.         /**
  643.          * Get productClass.
  644.          *
  645.          * @return \Eccube\Entity\ProductClass|null
  646.          */
  647.         public function getProductClass()
  648.         {
  649.             return $this->ProductClass;
  650.         }
  651.         /**
  652.          * Set shipping.
  653.          *
  654.          * @param \Eccube\Entity\Shipping|null $shipping
  655.          *
  656.          * @return OrderItem
  657.          */
  658.         public function setShipping(Shipping $shipping null)
  659.         {
  660.             $this->Shipping $shipping;
  661.             return $this;
  662.         }
  663.         /**
  664.          * Get shipping.
  665.          *
  666.          * @return \Eccube\Entity\Shipping|null
  667.          */
  668.         public function getShipping()
  669.         {
  670.             return $this->Shipping;
  671.         }
  672.         /**
  673.          * @return RoundingType
  674.          */
  675.         public function getRoundingType()
  676.         {
  677.             return $this->RoundingType;
  678.         }
  679.         /**
  680.          * @param RoundingType $RoundingType
  681.          */
  682.         public function setRoundingType(RoundingType $RoundingType null)
  683.         {
  684.             $this->RoundingType $RoundingType;
  685.             return $this;
  686.         }
  687.         /**
  688.          * Set taxType
  689.          *
  690.          * @param \Eccube\Entity\Master\TaxType $taxType
  691.          *
  692.          * @return OrderItem
  693.          */
  694.         public function setTaxType(Master\TaxType $taxType null)
  695.         {
  696.             $this->TaxType $taxType;
  697.             return $this;
  698.         }
  699.         /**
  700.          * Get taxType
  701.          *
  702.          * @return \Eccube\Entity\Master\TaxType
  703.          */
  704.         public function getTaxType()
  705.         {
  706.             return $this->TaxType;
  707.         }
  708.         /**
  709.          * Set taxDisplayType
  710.          *
  711.          * @param \Eccube\Entity\Master\TaxDisplayType $taxDisplayType
  712.          *
  713.          * @return OrderItem
  714.          */
  715.         public function setTaxDisplayType(TaxDisplayType $taxDisplayType null)
  716.         {
  717.             $this->TaxDisplayType $taxDisplayType;
  718.             return $this;
  719.         }
  720.         /**
  721.          * Get taxDisplayType
  722.          *
  723.          * @return \Eccube\Entity\Master\TaxDisplayType
  724.          */
  725.         public function getTaxDisplayType()
  726.         {
  727.             return $this->TaxDisplayType;
  728.         }
  729.         /**
  730.          * Set orderItemType
  731.          *
  732.          * @param \Eccube\Entity\Master\OrderItemType $orderItemType
  733.          *
  734.          * @return OrderItem
  735.          */
  736.         public function setOrderItemType(OrderItemType $orderItemType null)
  737.         {
  738.             $this->OrderItemType $orderItemType;
  739.             return $this;
  740.         }
  741.         /**
  742.          * Get orderItemType
  743.          *
  744.          * @return \Eccube\Entity\Master\OrderItemType
  745.          */
  746.         public function getOrderItemType()
  747.         {
  748.             return $this->OrderItemType;
  749.         }
  750.     }
  751. }