app/proxy/entity/src/Eccube/Entity/Order.php line 44

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