src/Eccube/Entity/Order.php line 44

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