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