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