src/Eccube/Entity/Order.php line 25

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\Common\Collections\Criteria;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Eccube\Entity\Master\RoundingType;
  17. use Eccube\Entity\Master\TaxType;
  18. use Eccube\Service\Calculator\OrderItemCollection;
  19. use Eccube\Service\PurchaseFlow\ItemCollection;
  20. use Eccube\Service\TaxRuleService;
  21. if (!class_exists('\Eccube\Entity\Order')) {
  22.     /**
  23.      * Order
  24.      *
  25.      * @ORM\Table(name="dtb_order", indexes={
  26.      *     @ORM\Index(name="dtb_order_email_idx", columns={"email"}),
  27.      *     @ORM\Index(name="dtb_order_order_date_idx", columns={"order_date"}),
  28.      *     @ORM\Index(name="dtb_order_payment_date_idx", columns={"payment_date"}),
  29.      *     @ORM\Index(name="dtb_order_update_date_idx", columns={"update_date"}),
  30.      *     @ORM\Index(name="dtb_order_order_no_idx", columns={"order_no"})
  31.      *  },
  32.      *  uniqueConstraints={
  33.      *     @ORM\UniqueConstraint(name="dtb_order_pre_order_id_idx", columns={"pre_order_id"})
  34.      *  })
  35.      * @ORM\InheritanceType("SINGLE_TABLE")
  36.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  37.      * @ORM\HasLifecycleCallbacks()
  38.      * @ORM\Entity(repositoryClass="Eccube\Repository\OrderRepository")
  39.      */
  40.     class Order extends \Eccube\Entity\AbstractEntity implements PurchaseInterfaceItemHolderInterface
  41.     {
  42.         use NameTrait;
  43.         use PointTrait;
  44.         /**
  45.          * 課税対象の明細を返す.
  46.          *
  47.          * @return OrderItem[]
  48.          */
  49.         public function getTaxableItems()
  50.         {
  51.             $Items = [];
  52.             foreach ($this->OrderItems as $Item) {
  53.                 if (null === $Item->getTaxType()) {
  54.                     continue;
  55.                 }
  56.                 if ($Item->getTaxType()->getId() == TaxType::TAXATION) {
  57.                     $Items[] = $Item;
  58.                 }
  59.             }
  60.             return $Items;
  61.         }
  62.         /**
  63.          * 課税対象の明細の合計金額を返す.
  64.          * 商品合計 + 送料 + 手数料 + 値引き(課税).
  65.          */
  66.         public function getTaxableTotal()
  67.         {
  68.             $total 0;
  69.             foreach ($this->getTaxableItems() as $Item) {
  70.                 $total += $Item->getTotalPrice();
  71.             }
  72.             return $total;
  73.         }
  74.         /**
  75.          * 課税対象の明細の合計金額を、税率ごとに集計する.
  76.          *
  77.          * @return array
  78.          */
  79.         public function getTaxableTotalByTaxRate()
  80.         {
  81.             $total = [];
  82.             foreach ($this->getTaxableItems() as $Item) {
  83.                 $totalPrice $Item->getTotalPrice();
  84.                 $taxRate $Item->getTaxRate();
  85.                 $total[$taxRate] = isset($total[$taxRate])
  86.                     ? $total[$taxRate] + $totalPrice
  87.                     $totalPrice;
  88.             }
  89.             krsort($total);
  90.             return $total;
  91.         }
  92.         /**
  93.          * 明細の合計額を税率ごとに集計する.
  94.          *
  95.          * 不課税, 非課税の値引明細は税率ごとに按分する.
  96.          *
  97.          * @return int[]
  98.          */
  99.         public function getTotalByTaxRate()
  100.         {
  101.             // $roundingTypes = $this->getRoundingTypeByTaxRate();
  102.             // カスタマイズ実装↓ *******
  103.             // NOTE: 税金の内訳計算はデフォルトの課税規律を参照せずに四捨五入で処理
  104.             $roundingType \Eccube\Entity\Master\RoundingType::ROUND;
  105.             // カスタマイズ実装↑ *******
  106.             
  107.             $total = [];
  108.             foreach ($this->getTaxableTotalByTaxRate() as $rate => $totalPrice) {
  109.                 $total[$rate] = TaxRuleService::roundByRoundingType(
  110.                     $this->getTaxableTotal() ?
  111.                         $totalPrice abs($this->getTaxFreeDiscount()) * $totalPrice $this->getTaxableTotal() : 0,
  112.                     // カスタマイズ実装↓ *******
  113.                     // $roundingTypes[$rate]->getId()
  114.                     $roundingType
  115.                     // カスタマイズ実装↑ *******
  116.                 );
  117.             }
  118.             ksort($total);
  119.             return $total;
  120.         }
  121.         /**
  122.          * 税額を税率ごとに集計する.
  123.          *
  124.          * 不課税, 非課税の値引明細は税率ごとに按分する.
  125.          *
  126.          * @return int[]
  127.          */
  128.         public function getTaxByTaxRate()
  129.         {
  130.             // カスタマイズ実装↓ *******
  131.             // NOTE: 税金の内訳計算はデフォルトの課税規律を参照せずに四捨五入で処理
  132.             // $roundingTypes = $this->getRoundingTypeByTaxRate();
  133.             $roundingType \Eccube\Entity\Master\RoundingType::ROUND;
  134.             // カスタマイズ実装↑ *******
  135.             $tax = [];
  136.             foreach ($this->getTaxableTotalByTaxRate() as $rate => $totalPrice) {
  137.                 $tax[$rate] = TaxRuleService::roundByRoundingType(
  138.                     $this->getTaxableTotal() ?
  139.                         ($totalPrice abs($this->getTaxFreeDiscount()) * $totalPrice $this->getTaxableTotal()) * ($rate / (100 $rate)) : 0,
  140.                     // カスタマイズ実装↓ *******
  141.                     // $roundingTypes[$rate]->getId()
  142.                     $roundingType
  143.                     // カスタマイズ実装↑ *******
  144.                 );
  145.             }
  146.             ksort($tax);
  147.             return $tax;
  148.         }
  149.         /**
  150.          * 課税対象の値引き明細を返す.
  151.          *
  152.          * @return array
  153.          */
  154.         public function getTaxableDiscountItems()
  155.         {
  156.             $items = (new ItemCollection($this->getTaxableItems()))->sort()->toArray();
  157.             return array_filter($items, function (OrderItem $Item) {
  158.                 return $Item->isDiscount();
  159.             });
  160.         }
  161.         /**
  162.          * 課税対象の値引き金額合計を返す.
  163.          *
  164.          * @return mixed
  165.          */
  166.         public function getTaxableDiscount()
  167.         {
  168.             return array_reduce($this->getTaxableDiscountItems(), function ($sumOrderItem $Item) {
  169.                 return $sum += $Item->getTotalPrice();
  170.             }, 0);
  171.         }
  172.         /**
  173.          * 非課税・不課税の値引き明細を返す.
  174.          *
  175.          * @return array
  176.          */
  177.         public function getTaxFreeDiscountItems()
  178.         {
  179.             $items = (new ItemCollection($this->getOrderItems()))->sort()->toArray();
  180.             return array_filter($items, function (OrderItem $Item) {
  181.                 return $Item->isPoint() || ($Item->isDiscount() && $Item->getTaxType()->getId() != TaxType::TAXATION);
  182.             });
  183.         }
  184.         /**
  185.          * 非課税・不課税の値引き額を返す.
  186.          *
  187.          * @return int|float
  188.          */
  189.         public function getTaxFreeDiscount()
  190.         {
  191.             return array_reduce($this->getTaxFreeDiscountItems(), function ($sumOrderItem $Item) {
  192.                 return $sum += $Item->getTotalPrice();
  193.             }, 0);
  194.         }
  195.         /**
  196.          * 税率ごとの丸め規則を取得する.
  197.          *
  198.          * @return array<string, RoundingType>
  199.          */
  200.         public function getRoundingTypeByTaxRate()
  201.         {
  202.             $roundingTypes = [];
  203.             foreach ($this->getTaxableItems() as $Item) {
  204.                 $roundingTypes[$Item->getTaxRate()] = $Item->getRoundingType();
  205.             }
  206.             return $roundingTypes;
  207.         }
  208.         /**
  209.          * 複数配送かどうかの判定を行う.
  210.          *
  211.          * @return boolean
  212.          */
  213.         public function isMultiple()
  214.         {
  215.             $Shippings = [];
  216.             // クエリビルダ使用時に絞り込まれる場合があるため,
  217.             // getShippingsではなくOrderItem経由でShippingを取得する.
  218.             foreach ($this->getOrderItems() as $OrderItem) {
  219.                 if ($Shipping $OrderItem->getShipping()) {
  220.                     $id $Shipping->getId();
  221.                     if (isset($Shippings[$id])) {
  222.                         continue;
  223.                     }
  224.                     $Shippings[$id] = $Shipping;
  225.                 }
  226.             }
  227.             return count($Shippings) > true false;
  228.         }
  229.         /**
  230.          * 対象となるお届け先情報を取得
  231.          *
  232.          * @param integer $shippingId
  233.          *
  234.          * @return \Eccube\Entity\Shipping|null
  235.          */
  236.         public function findShipping($shippingId)
  237.         {
  238.             foreach ($this->getShippings() as $Shipping) {
  239.                 if ($Shipping->getId() == $shippingId) {
  240.                     return $Shipping;
  241.                 }
  242.             }
  243.             return null;
  244.         }
  245.         /**
  246.          * この注文の保持する販売種別を取得します.
  247.          *
  248.          * @return \Eccube\Entity\Master\SaleType[] 一意な販売種別の配列
  249.          */
  250.         public function getSaleTypes()
  251.         {
  252.             $saleTypes = [];
  253.             foreach ($this->getOrderItems() as $OrderItem) {
  254.                 /* @var $ProductClass \Eccube\Entity\ProductClass */
  255.                 $ProductClass $OrderItem->getProductClass();
  256.                 if ($ProductClass) {
  257.                     $saleTypes[] = $ProductClass->getSaleType();
  258.                 }
  259.             }
  260.             return array_unique($saleTypes);
  261.         }
  262.         /**
  263.          * 同じ規格の商品の個数をまとめた受注明細を取得
  264.          *
  265.          * @return OrderItem[]
  266.          */
  267.         public function getMergedProductOrderItems()
  268.         {
  269.             $ProductOrderItems $this->getProductOrderItems();
  270.             $orderItemArray = [];
  271.             /** @var OrderItem $ProductOrderItem */
  272.             foreach ($ProductOrderItems as $ProductOrderItem) {
  273.                 $productClassId $ProductOrderItem->getProductClass()->getId();
  274.                 if (array_key_exists($productClassId$orderItemArray)) {
  275.                     // 同じ規格の商品がある場合は個数をまとめる
  276.                     /** @var ItemInterface $OrderItem */
  277.                     $OrderItem $orderItemArray[$productClassId];
  278.                     $quantity $OrderItem->getQuantity() + $ProductOrderItem->getQuantity();
  279.                     $OrderItem->setQuantity($quantity);
  280.                 } else {
  281.                     // 新規規格の商品は新しく追加する
  282.                     $OrderItem = new OrderItem();
  283.                     $OrderItem->copyProperties($ProductOrderItem, ['id']);
  284.                     $orderItemArray[$productClassId] = $OrderItem;
  285.                 }
  286.             }
  287.             return array_values($orderItemArray);
  288.         }
  289.         /**
  290.          * 合計金額を計算
  291.          *
  292.          * @return string
  293.          *
  294.          * @deprecated
  295.          */
  296.         public function getTotalPrice()
  297.         {
  298.             @trigger_error('The ' __METHOD__ ' method is deprecated.'E_USER_DEPRECATED);
  299.             return $this->getPaymentTotal();
  300.         }
  301.         /**
  302.          * @var integer
  303.          *
  304.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  305.          * @ORM\Id
  306.          * @ORM\GeneratedValue(strategy="IDENTITY")
  307.          */
  308.         private $id;
  309.         /**
  310.          * @var string|null
  311.          *
  312.          * @ORM\Column(name="pre_order_id", type="string", length=255, nullable=true)
  313.          */
  314.         private $pre_order_id;
  315.         /**
  316.          * @var string|null
  317.          *
  318.          * @ORM\Column(name="order_no", type="string", length=255, nullable=true)
  319.          */
  320.         private $order_no;
  321.         /**
  322.          * @var string|null
  323.          *
  324.          * @ORM\Column(name="message", type="string", length=4000, nullable=true)
  325.          */
  326.         private $message;
  327.         /**
  328.          * @var string|null
  329.          *
  330.          * @ORM\Column(name="name01", type="string", length=255)
  331.          */
  332.         private $name01;
  333.         /**
  334.          * @var string|null
  335.          *
  336.          * @ORM\Column(name="name02", type="string", length=255)
  337.          */
  338.         private $name02;
  339.         /**
  340.          * @var string|null
  341.          *
  342.          * @ORM\Column(name="kana01", type="string", length=255, nullable=true)
  343.          */
  344.         private $kana01;
  345.         /**
  346.          * @var string|null
  347.          *
  348.          * @ORM\Column(name="kana02", type="string", length=255, nullable=true)
  349.          */
  350.         private $kana02;
  351.         /**
  352.          * @var string|null
  353.          *
  354.          * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
  355.          */
  356.         private $company_name;
  357.         /**
  358.          * @var string|null
  359.          *
  360.          * @ORM\Column(name="email", type="string", length=255, nullable=true)
  361.          */
  362.         private $email;
  363.         /**
  364.          * @var string|null
  365.          *
  366.          * @ORM\Column(name="phone_number", type="string", length=14, nullable=true)
  367.          */
  368.         private $phone_number;
  369.         /**
  370.          * @var string|null
  371.          *
  372.          * @ORM\Column(name="postal_code", type="string", length=8, nullable=true)
  373.          */
  374.         private $postal_code;
  375.         /**
  376.          * @var string|null
  377.          *
  378.          * @ORM\Column(name="addr01", type="string", length=255, nullable=true)
  379.          */
  380.         private $addr01;
  381.         /**
  382.          * @var string|null
  383.          *
  384.          * @ORM\Column(name="addr02", type="string", length=255, nullable=true)
  385.          */
  386.         private $addr02;
  387.         /**
  388.          * @var \DateTime|null
  389.          *
  390.          * @ORM\Column(name="birth", type="datetimetz", nullable=true)
  391.          */
  392.         private $birth;
  393.         /**
  394.          * @var string
  395.          *
  396.          * @ORM\Column(name="subtotal", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  397.          */
  398.         private $subtotal 0;
  399.         /**
  400.          * @var string
  401.          *
  402.          * @ORM\Column(name="discount", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  403.          */
  404.         private $discount 0;
  405.         /**
  406.          * @var string
  407.          *
  408.          * @ORM\Column(name="delivery_fee_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  409.          */
  410.         private $delivery_fee_total 0;
  411.         /**
  412.          * @var string
  413.          *
  414.          * @ORM\Column(name="charge", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  415.          */
  416.         private $charge 0;
  417.         /**
  418.          * @var string
  419.          *
  420.          * @ORM\Column(name="tax", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  421.          *
  422.          * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
  423.          */
  424.         private $tax 0;
  425.         /**
  426.          * @var string
  427.          *
  428.          * @ORM\Column(name="total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  429.          */
  430.         private $total 0;
  431.         /**
  432.          * @var string
  433.          *
  434.          * @ORM\Column(name="payment_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
  435.          */
  436.         private $payment_total 0;
  437.         /**
  438.          * @var string|null
  439.          *
  440.          * @ORM\Column(name="payment_method", type="string", length=255, nullable=true)
  441.          */
  442.         private $payment_method;
  443.         /**
  444.          * @var string|null
  445.          *
  446.          * @ORM\Column(name="note", type="string", length=4000, nullable=true)
  447.          */
  448.         private $note;
  449.         /**
  450.          * @var \DateTime
  451.          *
  452.          * @ORM\Column(name="create_date", type="datetimetz")
  453.          */
  454.         private $create_date;
  455.         /**
  456.          * @var \DateTime
  457.          *
  458.          * @ORM\Column(name="update_date", type="datetimetz")
  459.          */
  460.         private $update_date;
  461.         /**
  462.          * @var \DateTime|null
  463.          *
  464.          * @ORM\Column(name="order_date", type="datetimetz", nullable=true)
  465.          */
  466.         private $order_date;
  467.         /**
  468.          * @var \DateTime|null
  469.          *
  470.          * @ORM\Column(name="payment_date", type="datetimetz", nullable=true)
  471.          */
  472.         private $payment_date;
  473.         /**
  474.          * @var string|null
  475.          *
  476.          * @ORM\Column(name="currency_code", type="string", nullable=true)
  477.          */
  478.         private $currency_code;
  479.         /**
  480.          * 注文完了画面に表示するメッセージ
  481.          *
  482.          * プラグインから注文完了時にメッセージを表示したい場合, このフィールドにセットすることで, 注文完了画面で表示されます。
  483.          * 複数のプラグインから利用されるため, appendCompleteMesssage()で追加してください.
  484.          * 表示する際にHTMLは利用可能です。
  485.          *
  486.          * @var string|null
  487.          *
  488.          * @ORM\Column(name="complete_message", type="text", nullable=true)
  489.          */
  490.         private $complete_message;
  491.         /**
  492.          * 注文完了メールに表示するメッセージ
  493.          *
  494.          * プラグインから注文完了メールにメッセージを表示したい場合, このフィールドにセットすることで, 注文完了メールで表示されます。
  495.          * 複数のプラグインから利用されるため, appendCompleteMailMesssage()で追加してください.
  496.          *
  497.          * @var string|null
  498.          *
  499.          * @ORM\Column(name="complete_mail_message", type="text", nullable=true)
  500.          */
  501.         private $complete_mail_message;
  502.         /**
  503.          * @var \Doctrine\Common\Collections\Collection|OrderItem[]
  504.          *
  505.          * @ORM\OneToMany(targetEntity="Eccube\Entity\OrderItem", mappedBy="Order", cascade={"persist","remove"})
  506.          */
  507.         private $OrderItems;
  508.         /**
  509.          * @var \Doctrine\Common\Collections\Collection|Shipping[]
  510.          *
  511.          * @ORM\OneToMany(targetEntity="Eccube\Entity\Shipping", mappedBy="Order", cascade={"persist","remove"})
  512.          */
  513.         private $Shippings;
  514.         /**
  515.          * @var \Doctrine\Common\Collections\Collection
  516.          *
  517.          * @ORM\OneToMany(targetEntity="Eccube\Entity\MailHistory", mappedBy="Order", cascade={"remove"})
  518.          * @ORM\OrderBy({
  519.          *     "send_date"="DESC"
  520.          * })
  521.          */
  522.         private $MailHistories;
  523.         /**
  524.          * @var \Eccube\Entity\Customer
  525.          *
  526.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer", inversedBy="Orders")
  527.          * @ORM\JoinColumns({
  528.          *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
  529.          * })
  530.          */
  531.         private $Customer;
  532.         /**
  533.          * @var \Eccube\Entity\Master\Country
  534.          *
  535.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Country")
  536.          * @ORM\JoinColumns({
  537.          *   @ORM\JoinColumn(name="country_id", referencedColumnName="id")
  538.          * })
  539.          */
  540.         private $Country;
  541.         /**
  542.          * @var \Eccube\Entity\Master\Pref
  543.          *
  544.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Pref")
  545.          * @ORM\JoinColumns({
  546.          *   @ORM\JoinColumn(name="pref_id", referencedColumnName="id")
  547.          * })
  548.          */
  549.         private $Pref;
  550.         /**
  551.          * @var \Eccube\Entity\Master\Sex
  552.          *
  553.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Sex")
  554.          * @ORM\JoinColumns({
  555.          *   @ORM\JoinColumn(name="sex_id", referencedColumnName="id")
  556.          * })
  557.          */
  558.         private $Sex;
  559.         /**
  560.          * @var \Eccube\Entity\Master\Job
  561.          *
  562.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Job")
  563.          * @ORM\JoinColumns({
  564.          *   @ORM\JoinColumn(name="job_id", referencedColumnName="id")
  565.          * })
  566.          */
  567.         private $Job;
  568.         /**
  569.          * @var \Eccube\Entity\Payment
  570.          *
  571.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Payment")
  572.          * @ORM\JoinColumns({
  573.          *   @ORM\JoinColumn(name="payment_id", referencedColumnName="id")
  574.          * })
  575.          */
  576.         private $Payment;
  577.         /**
  578.          * @var \Eccube\Entity\Master\DeviceType
  579.          *
  580.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\DeviceType")
  581.          * @ORM\JoinColumns({
  582.          *   @ORM\JoinColumn(name="device_type_id", referencedColumnName="id")
  583.          * })
  584.          */
  585.         private $DeviceType;
  586.         /**
  587.          * OrderStatusより先にプロパティを定義しておかないとセットされなくなる
  588.          *
  589.          * @var \Eccube\Entity\Master\CustomerOrderStatus
  590.          *
  591.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\CustomerOrderStatus")
  592.          * @ORM\JoinColumns({
  593.          *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
  594.          * })
  595.          */
  596.         private $CustomerOrderStatus;
  597.         /**
  598.          * OrderStatusより先にプロパティを定義しておかないとセットされなくなる
  599.          *
  600.          * @var \Eccube\Entity\Master\OrderStatusColor
  601.          *
  602.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatusColor")
  603.          * @ORM\JoinColumns({
  604.          *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
  605.          * })
  606.          */
  607.         private $OrderStatusColor;
  608.         /**
  609.          * @var \Eccube\Entity\Master\OrderStatus
  610.          *
  611.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatus")
  612.          * @ORM\JoinColumns({
  613.          *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
  614.          * })
  615.          */
  616.         private $OrderStatus;
  617.         /**
  618.          * Constructor
  619.          */
  620.         public function __construct(Master\OrderStatus $orderStatus null)
  621.         {
  622.             $this->setDiscount(0)
  623.                 ->setSubtotal(0)
  624.                 ->setTotal(0)
  625.                 ->setPaymentTotal(0)
  626.                 ->setCharge(0)
  627.                 ->setTax(0)
  628.                 ->setDeliveryFeeTotal(0)
  629.                 ->setOrderStatus($orderStatus);
  630.             $this->OrderItems = new \Doctrine\Common\Collections\ArrayCollection();
  631.             $this->Shippings = new \Doctrine\Common\Collections\ArrayCollection();
  632.             $this->MailHistories = new \Doctrine\Common\Collections\ArrayCollection();
  633.         }
  634.         /**
  635.          * Clone
  636.          */
  637.         public function __clone()
  638.         {
  639.             $OriginOrderItems $this->OrderItems;
  640.             $OrderItems = new ArrayCollection();
  641.             foreach ($this->OrderItems as $OrderItem) {
  642.                 $OrderItems->add(clone $OrderItem);
  643.             }
  644.             $this->OrderItems $OrderItems;
  645. //            // ShippingとOrderItemが循環参照するため, 手動でヒモ付を変更する.
  646. //            $Shippings = new ArrayCollection();
  647. //            foreach ($this->Shippings as $Shipping) {
  648. //                $CloneShipping = clone $Shipping;
  649. //                foreach ($OriginOrderItems as $OrderItem) {
  650. //                    //$CloneShipping->removeOrderItem($OrderItem);
  651. //                }
  652. //                foreach ($this->OrderItems as $OrderItem) {
  653. //                    if ($OrderItem->getShipping() && $OrderItem->getShipping()->getId() == $Shipping->getId()) {
  654. //                        $OrderItem->setShipping($CloneShipping);
  655. //                    }
  656. //                    $CloneShipping->addOrderItem($OrderItem);
  657. //                }
  658. //                $Shippings->add($CloneShipping);
  659. //            }
  660. //            $this->Shippings = $Shippings;
  661.         }
  662.         /**
  663.          * Get id.
  664.          *
  665.          * @return int
  666.          */
  667.         public function getId()
  668.         {
  669.             return $this->id;
  670.         }
  671.         /**
  672.          * Set preOrderId.
  673.          *
  674.          * @param string|null $preOrderId
  675.          *
  676.          * @return Order
  677.          */
  678.         public function setPreOrderId($preOrderId null)
  679.         {
  680.             $this->pre_order_id $preOrderId;
  681.             return $this;
  682.         }
  683.         /**
  684.          * Get preOrderId.
  685.          *
  686.          * @return string|null
  687.          */
  688.         public function getPreOrderId()
  689.         {
  690.             return $this->pre_order_id;
  691.         }
  692.         /**
  693.          * Set orderNo
  694.          *
  695.          * @param string|null $orderNo
  696.          *
  697.          * @return Order
  698.          */
  699.         public function setOrderNo($orderNo null)
  700.         {
  701.             $this->order_no $orderNo;
  702.             return $this;
  703.         }
  704.         /**
  705.          * Get orderNo
  706.          *
  707.          * @return string|null
  708.          */
  709.         public function getOrderNo()
  710.         {
  711.             return $this->order_no;
  712.         }
  713.         /**
  714.          * Set message.
  715.          *
  716.          * @param string|null $message
  717.          *
  718.          * @return Order
  719.          */
  720.         public function setMessage($message null)
  721.         {
  722.             $this->message $message;
  723.             return $this;
  724.         }
  725.         /**
  726.          * Get message.
  727.          *
  728.          * @return string|null
  729.          */
  730.         public function getMessage()
  731.         {
  732.             return $this->message;
  733.         }
  734.         /**
  735.          * Set name01.
  736.          *
  737.          * @param string|null $name01
  738.          *
  739.          * @return Order
  740.          */
  741.         public function setName01($name01 null)
  742.         {
  743.             $this->name01 $name01;
  744.             return $this;
  745.         }
  746.         /**
  747.          * Get name01.
  748.          *
  749.          * @return string|null
  750.          */
  751.         public function getName01()
  752.         {
  753.             return $this->name01;
  754.         }
  755.         /**
  756.          * Set name02.
  757.          *
  758.          * @param string|null $name02
  759.          *
  760.          * @return Order
  761.          */
  762.         public function setName02($name02 null)
  763.         {
  764.             $this->name02 $name02;
  765.             return $this;
  766.         }
  767.         /**
  768.          * Get name02.
  769.          *
  770.          * @return string|null
  771.          */
  772.         public function getName02()
  773.         {
  774.             return $this->name02;
  775.         }
  776.         /**
  777.          * Set kana01.
  778.          *
  779.          * @param string|null $kana01
  780.          *
  781.          * @return Order
  782.          */
  783.         public function setKana01($kana01 null)
  784.         {
  785.             $this->kana01 $kana01;
  786.             return $this;
  787.         }
  788.         /**
  789.          * Get kana01.
  790.          *
  791.          * @return string|null
  792.          */
  793.         public function getKana01()
  794.         {
  795.             return $this->kana01;
  796.         }
  797.         /**
  798.          * Set kana02.
  799.          *
  800.          * @param string|null $kana02
  801.          *
  802.          * @return Order
  803.          */
  804.         public function setKana02($kana02 null)
  805.         {
  806.             $this->kana02 $kana02;
  807.             return $this;
  808.         }
  809.         /**
  810.          * Get kana02.
  811.          *
  812.          * @return string|null
  813.          */
  814.         public function getKana02()
  815.         {
  816.             return $this->kana02;
  817.         }
  818.         /**
  819.          * Set companyName.
  820.          *
  821.          * @param string|null $companyName
  822.          *
  823.          * @return Order
  824.          */
  825.         public function setCompanyName($companyName null)
  826.         {
  827.             $this->company_name $companyName;
  828.             return $this;
  829.         }
  830.         /**
  831.          * Get companyName.
  832.          *
  833.          * @return string|null
  834.          */
  835.         public function getCompanyName()
  836.         {
  837.             return $this->company_name;
  838.         }
  839.         /**
  840.          * Set email.
  841.          *
  842.          * @param string|null $email
  843.          *
  844.          * @return Order
  845.          */
  846.         public function setEmail($email null)
  847.         {
  848.             $this->email $email;
  849.             return $this;
  850.         }
  851.         /**
  852.          * Get email.
  853.          *
  854.          * @return string|null
  855.          */
  856.         public function getEmail()
  857.         {
  858.             return $this->email;
  859.         }
  860.         /**
  861.          * Set phone_number.
  862.          *
  863.          * @param string|null $phone_number
  864.          *
  865.          * @return Order
  866.          */
  867.         public function setPhoneNumber($phone_number null)
  868.         {
  869.             $this->phone_number $phone_number;
  870.             return $this;
  871.         }
  872.         /**
  873.          * Get phone_number.
  874.          *
  875.          * @return string|null
  876.          */
  877.         public function getPhoneNumber()
  878.         {
  879.             return $this->phone_number;
  880.         }
  881.         /**
  882.          * Set postal_code.
  883.          *
  884.          * @param string|null $postal_code
  885.          *
  886.          * @return Order
  887.          */
  888.         public function setPostalCode($postal_code null)
  889.         {
  890.             $this->postal_code $postal_code;
  891.             return $this;
  892.         }
  893.         /**
  894.          * Get postal_code.
  895.          *
  896.          * @return string|null
  897.          */
  898.         public function getPostalCode()
  899.         {
  900.             return $this->postal_code;
  901.         }
  902.         /**
  903.          * Set addr01.
  904.          *
  905.          * @param string|null $addr01
  906.          *
  907.          * @return Order
  908.          */
  909.         public function setAddr01($addr01 null)
  910.         {
  911.             $this->addr01 $addr01;
  912.             return $this;
  913.         }
  914.         /**
  915.          * Get addr01.
  916.          *
  917.          * @return string|null
  918.          */
  919.         public function getAddr01()
  920.         {
  921.             return $this->addr01;
  922.         }
  923.         /**
  924.          * Set addr02.
  925.          *
  926.          * @param string|null $addr02
  927.          *
  928.          * @return Order
  929.          */
  930.         public function setAddr02($addr02 null)
  931.         {
  932.             $this->addr02 $addr02;
  933.             return $this;
  934.         }
  935.         /**
  936.          * Get addr02.
  937.          *
  938.          * @return string|null
  939.          */
  940.         public function getAddr02()
  941.         {
  942.             return $this->addr02;
  943.         }
  944.         /**
  945.          * Set birth.
  946.          *
  947.          * @param \DateTime|null $birth
  948.          *
  949.          * @return Order
  950.          */
  951.         public function setBirth($birth null)
  952.         {
  953.             $this->birth $birth;
  954.             return $this;
  955.         }
  956.         /**
  957.          * Get birth.
  958.          *
  959.          * @return \DateTime|null
  960.          */
  961.         public function getBirth()
  962.         {
  963.             return $this->birth;
  964.         }
  965.         /**
  966.          * Set subtotal.
  967.          *
  968.          * @param string $subtotal
  969.          *
  970.          * @return Order
  971.          */
  972.         public function setSubtotal($subtotal)
  973.         {
  974.             $this->subtotal $subtotal;
  975.             return $this;
  976.         }
  977.         /**
  978.          * Get subtotal.
  979.          *
  980.          * @return string
  981.          */
  982.         public function getSubtotal()
  983.         {
  984.             return $this->subtotal;
  985.         }
  986.         /**
  987.          * Set discount.
  988.          *
  989.          * @param string $discount
  990.          *
  991.          * @return Order
  992.          */
  993.         public function setDiscount($discount)
  994.         {
  995.             $this->discount $discount;
  996.             return $this;
  997.         }
  998.         /**
  999.          * Get discount.
  1000.          *
  1001.          * @return string
  1002.          * @deprecated 4.0.3 から値引きは課税値引きと 非課税・不課税の値引きの2種に分かれる. 課税値引きについてはgetTaxableDiscountを利用してください.
  1003.          *
  1004.          */
  1005.         public function getDiscount()
  1006.         {
  1007.             return $this->discount;
  1008.         }
  1009.         /**
  1010.          * Set deliveryFeeTotal.
  1011.          *
  1012.          * @param string $deliveryFeeTotal
  1013.          *
  1014.          * @return Order
  1015.          */
  1016.         public function setDeliveryFeeTotal($deliveryFeeTotal)
  1017.         {
  1018.             $this->delivery_fee_total $deliveryFeeTotal;
  1019.             return $this;
  1020.         }
  1021.         /**
  1022.          * Get deliveryFeeTotal.
  1023.          *
  1024.          * @return string
  1025.          */
  1026.         public function getDeliveryFeeTotal()
  1027.         {
  1028.             return $this->delivery_fee_total;
  1029.         }
  1030.         /**
  1031.          * Set charge.
  1032.          *
  1033.          * @param string $charge
  1034.          *
  1035.          * @return Order
  1036.          */
  1037.         public function setCharge($charge)
  1038.         {
  1039.             $this->charge $charge;
  1040.             return $this;
  1041.         }
  1042.         /**
  1043.          * Get charge.
  1044.          *
  1045.          * @return string
  1046.          */
  1047.         public function getCharge()
  1048.         {
  1049.             return $this->charge;
  1050.         }
  1051.         /**
  1052.          * Set tax.
  1053.          *
  1054.          * @param string $tax
  1055.          *
  1056.          * @return Order
  1057.          *
  1058.          * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
  1059.          */
  1060.         public function setTax($tax)
  1061.         {
  1062.             $this->tax $tax;
  1063.             return $this;
  1064.         }
  1065.         /**
  1066.          * Get tax.
  1067.          *
  1068.          * @return string
  1069.          *
  1070.          * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
  1071.          */
  1072.         public function getTax()
  1073.         {
  1074.             return $this->tax;
  1075.         }
  1076.         /**
  1077.          * Set total.
  1078.          *
  1079.          * @param string $total
  1080.          *
  1081.          * @return Order
  1082.          */
  1083.         public function setTotal($total)
  1084.         {
  1085.             $this->total $total;
  1086.             return $this;
  1087.         }
  1088.         /**
  1089.          * Get total.
  1090.          *
  1091.          * @return string
  1092.          */
  1093.         public function getTotal()
  1094.         {
  1095.             return $this->total;
  1096.         }
  1097.         /**
  1098.          * Set paymentTotal.
  1099.          *
  1100.          * @param string $paymentTotal
  1101.          *
  1102.          * @return Order
  1103.          */
  1104.         public function setPaymentTotal($paymentTotal)
  1105.         {
  1106.             $this->payment_total $paymentTotal;
  1107.             return $this;
  1108.         }
  1109.         /**
  1110.          * Get paymentTotal.
  1111.          *
  1112.          * @return string
  1113.          */
  1114.         public function getPaymentTotal()
  1115.         {
  1116.             return $this->payment_total;
  1117.         }
  1118.         /**
  1119.          * Set paymentMethod.
  1120.          *
  1121.          * @param string|null $paymentMethod
  1122.          *
  1123.          * @return Order
  1124.          */
  1125.         public function setPaymentMethod($paymentMethod null)
  1126.         {
  1127.             $this->payment_method $paymentMethod;
  1128.             return $this;
  1129.         }
  1130.         /**
  1131.          * Get paymentMethod.
  1132.          *
  1133.          * @return string|null
  1134.          */
  1135.         public function getPaymentMethod()
  1136.         {
  1137.             return $this->payment_method;
  1138.         }
  1139.         /**
  1140.          * Set note.
  1141.          *
  1142.          * @param string|null $note
  1143.          *
  1144.          * @return Order
  1145.          */
  1146.         public function setNote($note null)
  1147.         {
  1148.             $this->note $note;
  1149.             return $this;
  1150.         }
  1151.         /**
  1152.          * Get note.
  1153.          *
  1154.          * @return string|null
  1155.          */
  1156.         public function getNote()
  1157.         {
  1158.             return $this->note;
  1159.         }
  1160.         /**
  1161.          * Set createDate.
  1162.          *
  1163.          * @param \DateTime $createDate
  1164.          *
  1165.          * @return Order
  1166.          */
  1167.         public function setCreateDate($createDate)
  1168.         {
  1169.             $this->create_date $createDate;
  1170.             return $this;
  1171.         }
  1172.         /**
  1173.          * Get createDate.
  1174.          *
  1175.          * @return \DateTime
  1176.          */
  1177.         public function getCreateDate()
  1178.         {
  1179.             return $this->create_date;
  1180.         }
  1181.         /**
  1182.          * Set updateDate.
  1183.          *
  1184.          * @param \DateTime $updateDate
  1185.          *
  1186.          * @return Order
  1187.          */
  1188.         public function setUpdateDate($updateDate)
  1189.         {
  1190.             $this->update_date $updateDate;
  1191.             return $this;
  1192.         }
  1193.         /**
  1194.          * Get updateDate.
  1195.          *
  1196.          * @return \DateTime
  1197.          */
  1198.         public function getUpdateDate()
  1199.         {
  1200.             return $this->update_date;
  1201.         }
  1202.         /**
  1203.          * Set orderDate.
  1204.          *
  1205.          * @param \DateTime|null $orderDate
  1206.          *
  1207.          * @return Order
  1208.          */
  1209.         public function setOrderDate($orderDate null)
  1210.         {
  1211.             $this->order_date $orderDate;
  1212.             return $this;
  1213.         }
  1214.         /**
  1215.          * Get orderDate.
  1216.          *
  1217.          * @return \DateTime|null
  1218.          */
  1219.         public function getOrderDate()
  1220.         {
  1221.             return $this->order_date;
  1222.         }
  1223.         /**
  1224.          * Set paymentDate.
  1225.          *
  1226.          * @param \DateTime|null $paymentDate
  1227.          *
  1228.          * @return Order
  1229.          */
  1230.         public function setPaymentDate($paymentDate null)
  1231.         {
  1232.             $this->payment_date $paymentDate;
  1233.             return $this;
  1234.         }
  1235.         /**
  1236.          * Get paymentDate.
  1237.          *
  1238.          * @return \DateTime|null
  1239.          */
  1240.         public function getPaymentDate()
  1241.         {
  1242.             return $this->payment_date;
  1243.         }
  1244.         /**
  1245.          * Get currencyCode.
  1246.          *
  1247.          * @return string
  1248.          */
  1249.         public function getCurrencyCode()
  1250.         {
  1251.             return $this->currency_code;
  1252.         }
  1253.         /**
  1254.          * Set currencyCode.
  1255.          *
  1256.          * @param string|null $currencyCode
  1257.          *
  1258.          * @return $this
  1259.          */
  1260.         public function setCurrencyCode($currencyCode null)
  1261.         {
  1262.             $this->currency_code $currencyCode;
  1263.             return $this;
  1264.         }
  1265.         /**
  1266.          * @return string|null
  1267.          */
  1268.         public function getCompleteMessage()
  1269.         {
  1270.             return $this->complete_message;
  1271.         }
  1272.         /**
  1273.          * @param string|null $complete_message
  1274.          *
  1275.          * @return $this
  1276.          */
  1277.         public function setCompleteMessage($complete_message null)
  1278.         {
  1279.             $this->complete_message $complete_message;
  1280.             return $this;
  1281.         }
  1282.         /**
  1283.          * @param string|null $complete_message
  1284.          *
  1285.          * @return $this
  1286.          */
  1287.         public function appendCompleteMessage($complete_message null)
  1288.         {
  1289.             $this->complete_message .= $complete_message;
  1290.             return $this;
  1291.         }
  1292.         /**
  1293.          * @return string|null
  1294.          */
  1295.         public function getCompleteMailMessage()
  1296.         {
  1297.             return $this->complete_mail_message;
  1298.         }
  1299.         /**
  1300.          * @param string|null $complete_mail_message
  1301.          *
  1302.          * @return
  1303.          */
  1304.         public function setCompleteMailMessage($complete_mail_message null)
  1305.         {
  1306.             $this->complete_mail_message $complete_mail_message;
  1307.             return $this;
  1308.         }
  1309.         /**
  1310.          * @param string|null $complete_mail_message
  1311.          *
  1312.          * @return
  1313.          */
  1314.         public function appendCompleteMailMessage($complete_mail_message null)
  1315.         {
  1316.             $this->complete_mail_message .= $complete_mail_message;
  1317.             return $this;
  1318.         }
  1319.         /**
  1320.          * 商品の受注明細を取得
  1321.          *
  1322.          * @return OrderItem[]
  1323.          */
  1324.         public function getProductOrderItems()
  1325.         {
  1326.             $sio = new OrderItemCollection($this->OrderItems->toArray());
  1327.             return array_values($sio->getProductClasses()->toArray());
  1328.         }
  1329.         /**
  1330.          * Add orderItem.
  1331.          *
  1332.          * @param \Eccube\Entity\OrderItem $OrderItem
  1333.          *
  1334.          * @return Order
  1335.          */
  1336.         public function addOrderItem(OrderItem $OrderItem)
  1337.         {
  1338.             $this->OrderItems[] = $OrderItem;
  1339.             return $this;
  1340.         }
  1341.         /**
  1342.          * Remove orderItem.
  1343.          *
  1344.          * @param \Eccube\Entity\OrderItem $OrderItem
  1345.          *
  1346.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  1347.          */
  1348.         public function removeOrderItem(OrderItem $OrderItem)
  1349.         {
  1350.             return $this->OrderItems->removeElement($OrderItem);
  1351.         }
  1352.         /**
  1353.          * Get orderItems.
  1354.          *
  1355.          * @return \Doctrine\Common\Collections\Collection|OrderItem[]
  1356.          */
  1357.         public function getOrderItems()
  1358.         {
  1359.             return $this->OrderItems;
  1360.         }
  1361.         /**
  1362.          * Sorted to getOrderItems()
  1363.          *
  1364.          * @return ItemCollection
  1365.          */
  1366.         public function getItems()
  1367.         {
  1368.             return (new ItemCollection($this->getOrderItems()))->sort();
  1369.         }
  1370.         /**
  1371.          * Add shipping.
  1372.          *
  1373.          * @param \Eccube\Entity\Shipping $Shipping
  1374.          *
  1375.          * @return Order
  1376.          */
  1377.         public function addShipping(Shipping $Shipping)
  1378.         {
  1379.             $this->Shippings[] = $Shipping;
  1380.             return $this;
  1381.         }
  1382.         /**
  1383.          * Remove shipping.
  1384.          *
  1385.          * @param \Eccube\Entity\Shipping $Shipping
  1386.          *
  1387.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  1388.          */
  1389.         public function removeShipping(Shipping $Shipping)
  1390.         {
  1391.             return $this->Shippings->removeElement($Shipping);
  1392.         }
  1393.         /**
  1394.          * Get shippings.
  1395.          *
  1396.          * @return \Doctrine\Common\Collections\Collection|\Eccube\Entity\Shipping[]
  1397.          */
  1398.         public function getShippings()
  1399.         {
  1400.             $criteria Criteria::create()
  1401.                 ->orderBy(['name01' => Criteria::ASC'name02' => Criteria::ASC'id' => Criteria::ASC]);
  1402.             return $this->Shippings->matching($criteria);
  1403.         }
  1404.         /**
  1405.          * Add mailHistory.
  1406.          *
  1407.          * @param \Eccube\Entity\MailHistory $mailHistory
  1408.          *
  1409.          * @return Order
  1410.          */
  1411.         public function addMailHistory(MailHistory $mailHistory)
  1412.         {
  1413.             $this->MailHistories[] = $mailHistory;
  1414.             return $this;
  1415.         }
  1416.         /**
  1417.          * Remove mailHistory.
  1418.          *
  1419.          * @param \Eccube\Entity\MailHistory $mailHistory
  1420.          *
  1421.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  1422.          */
  1423.         public function removeMailHistory(MailHistory $mailHistory)
  1424.         {
  1425.             return $this->MailHistories->removeElement($mailHistory);
  1426.         }
  1427.         /**
  1428.          * Get mailHistories.
  1429.          *
  1430.          * @return \Doctrine\Common\Collections\Collection
  1431.          */
  1432.         public function getMailHistories()
  1433.         {
  1434.             return $this->MailHistories;
  1435.         }
  1436.         /**
  1437.          * Set customer.
  1438.          *
  1439.          * @param \Eccube\Entity\Customer|null $customer
  1440.          *
  1441.          * @return Order
  1442.          */
  1443.         public function setCustomer(Customer $customer null)
  1444.         {
  1445.             $this->Customer $customer;
  1446.             return $this;
  1447.         }
  1448.         /**
  1449.          * Get customer.
  1450.          *
  1451.          * @return \Eccube\Entity\Customer|null
  1452.          */
  1453.         public function getCustomer()
  1454.         {
  1455.             return $this->Customer;
  1456.         }
  1457.         /**
  1458.          * Set country.
  1459.          *
  1460.          * @param \Eccube\Entity\Master\Country|null $country
  1461.          *
  1462.          * @return Order
  1463.          */
  1464.         public function setCountry(Master\Country $country null)
  1465.         {
  1466.             $this->Country $country;
  1467.             return $this;
  1468.         }
  1469.         /**
  1470.          * Get country.
  1471.          *
  1472.          * @return \Eccube\Entity\Master\Country|null
  1473.          */
  1474.         public function getCountry()
  1475.         {
  1476.             return $this->Country;
  1477.         }
  1478.         /**
  1479.          * Set pref.
  1480.          *
  1481.          * @param \Eccube\Entity\Master\Pref|null $pref
  1482.          *
  1483.          * @return Order
  1484.          */
  1485.         public function setPref(Master\Pref $pref null)
  1486.         {
  1487.             $this->Pref $pref;
  1488.             return $this;
  1489.         }
  1490.         /**
  1491.          * Get pref.
  1492.          *
  1493.          * @return \Eccube\Entity\Master\Pref|null
  1494.          */
  1495.         public function getPref()
  1496.         {
  1497.             return $this->Pref;
  1498.         }
  1499.         /**
  1500.          * Set sex.
  1501.          *
  1502.          * @param \Eccube\Entity\Master\Sex|null $sex
  1503.          *
  1504.          * @return Order
  1505.          */
  1506.         public function setSex(Master\Sex $sex null)
  1507.         {
  1508.             $this->Sex $sex;
  1509.             return $this;
  1510.         }
  1511.         /**
  1512.          * Get sex.
  1513.          *
  1514.          * @return \Eccube\Entity\Master\Sex|null
  1515.          */
  1516.         public function getSex()
  1517.         {
  1518.             return $this->Sex;
  1519.         }
  1520.         /**
  1521.          * Set job.
  1522.          *
  1523.          * @param \Eccube\Entity\Master\Job|null $job
  1524.          *
  1525.          * @return Order
  1526.          */
  1527.         public function setJob(Master\Job $job null)
  1528.         {
  1529.             $this->Job $job;
  1530.             return $this;
  1531.         }
  1532.         /**
  1533.          * Get job.
  1534.          *
  1535.          * @return \Eccube\Entity\Master\Job|null
  1536.          */
  1537.         public function getJob()
  1538.         {
  1539.             return $this->Job;
  1540.         }
  1541.         /**
  1542.          * Set payment.
  1543.          *
  1544.          * @param \Eccube\Entity\Payment|null $payment
  1545.          *
  1546.          * @return Order
  1547.          */
  1548.         public function setPayment(Payment $payment null)
  1549.         {
  1550.             $this->Payment $payment;
  1551.             return $this;
  1552.         }
  1553.         /**
  1554.          * Get payment.
  1555.          *
  1556.          * @return \Eccube\Entity\Payment|null
  1557.          */
  1558.         public function getPayment()
  1559.         {
  1560.             return $this->Payment;
  1561.         }
  1562.         /**
  1563.          * Set deviceType.
  1564.          *
  1565.          * @param \Eccube\Entity\Master\DeviceType|null $deviceType
  1566.          *
  1567.          * @return Order
  1568.          */
  1569.         public function setDeviceType(Master\DeviceType $deviceType null)
  1570.         {
  1571.             $this->DeviceType $deviceType;
  1572.             return $this;
  1573.         }
  1574.         /**
  1575.          * Get deviceType.
  1576.          *
  1577.          * @return \Eccube\Entity\Master\DeviceType|null
  1578.          */
  1579.         public function getDeviceType()
  1580.         {
  1581.             return $this->DeviceType;
  1582.         }
  1583.         /**
  1584.          * Set customerOrderStatus.
  1585.          *
  1586.          * @param \Eccube\Entity\Master\CustomerOrderStatus|null $customerOrderStatus
  1587.          *
  1588.          * @return Order
  1589.          */
  1590.         public function setCustomerOrderStatus(Master\CustomerOrderStatus $customerOrderStatus null)
  1591.         {
  1592.             $this->CustomerOrderStatus $customerOrderStatus;
  1593.             return $this;
  1594.         }
  1595.         /**
  1596.          * Get customerOrderStatus.
  1597.          *
  1598.          * @return \Eccube\Entity\Master\CustomerOrderStatus|null
  1599.          */
  1600.         public function getCustomerOrderStatus()
  1601.         {
  1602.             return $this->CustomerOrderStatus;
  1603.         }
  1604.         /**
  1605.          * Set orderStatusColor.
  1606.          *
  1607.          * @param \Eccube\Entity\Master\OrderStatusColor|null $orderStatusColor
  1608.          *
  1609.          * @return Order
  1610.          */
  1611.         public function setOrderStatusColor(Master\OrderStatusColor $orderStatusColor null)
  1612.         {
  1613.             $this->OrderStatusColor $orderStatusColor;
  1614.             return $this;
  1615.         }
  1616.         /**
  1617.          * Get orderStatusColor.
  1618.          *
  1619.          * @return \Eccube\Entity\Master\OrderStatusColor|null
  1620.          */
  1621.         public function getOrderStatusColor()
  1622.         {
  1623.             return $this->OrderStatusColor;
  1624.         }
  1625.         /**
  1626.          * Set orderStatus.
  1627.          *
  1628.          * @param \Eccube\Entity\Master\OrderStatus|object|null $orderStatus
  1629.          *
  1630.          * @return Order
  1631.          */
  1632.         public function setOrderStatus(Master\OrderStatus $orderStatus null)
  1633.         {
  1634.             $this->OrderStatus $orderStatus;
  1635.             return $this;
  1636.         }
  1637.         /**
  1638.          * Get orderStatus.
  1639.          *
  1640.          * @return \Eccube\Entity\Master\OrderStatus|null
  1641.          */
  1642.         public function getOrderStatus()
  1643.         {
  1644.             return $this->OrderStatus;
  1645.         }
  1646.         /**
  1647.          * @param ItemInterface $item
  1648.          */
  1649.         public function addItem(ItemInterface $item)
  1650.         {
  1651.             $this->OrderItems->add($item);
  1652.         }
  1653.         public function getQuantity()
  1654.         {
  1655.             $quantity 0;
  1656.             foreach ($this->getItems() as $item) {
  1657.                 $quantity += $item->getQuantity();
  1658.             }
  1659.             return $quantity;
  1660.         }
  1661.     }
  1662. }