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