Completed
Push — 4.0 ( 87d096...bcc1be )
by Kiyotaka
05:44 queued 11s
created

src/Eccube/Entity/Order.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Entity;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\Common\Collections\Criteria;
18
use Doctrine\ORM\Mapping as ORM;
19
use Eccube\Service\Calculator\OrderItemCollection;
20
use Eccube\Service\PurchaseFlow\ItemCollection;
21
22 1
if (!class_exists('\Eccube\Entity\Order')) {
23
    /**
24
     * Order
25
     *
26
     * @ORM\Table(name="dtb_order", indexes={
27
     *     @ORM\Index(name="dtb_order_email_idx", columns={"email"}),
28
     *     @ORM\Index(name="dtb_order_order_date_idx", columns={"order_date"}),
29
     *     @ORM\Index(name="dtb_order_payment_date_idx", columns={"payment_date"}),
30
     *     @ORM\Index(name="dtb_order_update_date_idx", columns={"update_date"}),
31
     *     @ORM\Index(name="dtb_order_order_no_idx", columns={"order_no"})
32
     *  },
33
     *  uniqueConstraints={
34
     *     @ORM\UniqueConstraint(name="dtb_order_pre_order_id_idx", columns={"pre_order_id"})
35
     *  })
36
     * @ORM\InheritanceType("SINGLE_TABLE")
37
     * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
38
     * @ORM\HasLifecycleCallbacks()
39
     * @ORM\Entity(repositoryClass="Eccube\Repository\OrderRepository")
40
     */
41
    class Order extends \Eccube\Entity\AbstractEntity implements PurchaseInterface, ItemHolderInterface
42
    {
43
        use NameTrait, PointTrait;
44
45
        /**
46
         * 複数配送かどうかの判定を行う.
47
         *
48 65
         * @return boolean
49
         */
50 65
        public function isMultiple()
51
        {
52
            $Shippings = [];
53 65
            // クエリビルダ使用時に絞り込まれる場合があるため,
54 64
            // getShippingsではなくOrderItem経由でShippingを取得する.
55 62
            foreach ($this->getOrderItems() as $OrderItem) {
56 62
                if ($Shipping = $OrderItem->getShipping()) {
57 62
                    $id = $Shipping->getId();
58
                    if (isset($Shippings[$id])) {
59 64
                        continue;
60
                    }
61
                    $Shippings[$id] = $Shipping;
62
                }
63 65
            }
64
65
            return count($Shippings) > 1 ? true : false;
66
        }
67
68
        /**
69
         * 対象となるお届け先情報を取得
70
         *
71
         * @param integer $shippingId
72
         *
73
         * @return \Eccube\Entity\Shipping|null
74
         */
75
        public function findShipping($shippingId)
76
        {
77
            foreach ($this->getShippings() as $Shipping) {
78
                if ($Shipping->getId() == $shippingId) {
79
                    return $Shipping;
80
                }
81
            }
82
83
            return null;
84
        }
85
86
        /**
87
         * この注文の保持する販売種別を取得します.
88
         *
89 1
         * @return \Eccube\Entity\Master\SaleType[] 一意な販売種別の配列
90
         */
91 1
        public function getSaleTypes()
92 1
        {
93
            $saleTypes = [];
94 1
            foreach ($this->getOrderItems() as $OrderItem) {
95 1
                /* @var $ProductClass \Eccube\Entity\ProductClass */
96 1
                $ProductClass = $OrderItem->getProductClass();
97
                if ($ProductClass) {
98
                    $saleTypes[] = $ProductClass->getSaleType();
99
                }
100 1
            }
101
102
            return array_unique($saleTypes);
103
        }
104
105
        /**
106
         * 同じ規格の商品の個数をまとめた受注明細を取得
107
         *
108 1
         * @return OrderItem[]
109
         */
110 1
        public function getMergedProductOrderItems()
111 1
        {
112
            $ProductOrderItems = $this->getProductOrderItems();
113 1
            $orderItemArray = [];
114 1
            /** @var OrderItem $ProductOrderItem */
115 1
            foreach ($ProductOrderItems as $ProductOrderItem) {
116
                $productClassId = $ProductOrderItem->getProductClass()->getId();
117
                if (array_key_exists($productClassId, $orderItemArray)) {
118 1
                    // 同じ規格の商品がある場合は個数をまとめる
119 1
                    /** @var ItemInterface $OrderItem */
120 1
                    $OrderItem = $orderItemArray[$productClassId];
121
                    $quantity = $OrderItem->getQuantity() + $ProductOrderItem->getQuantity();
122
                    $OrderItem->setQuantity($quantity);
123 1
                } else {
124
                    // 新規規格の商品は新しく追加する
125 1
                    $OrderItem = new OrderItem();
126 1
                    $OrderItem
127 1
                    ->setProduct($ProductOrderItem->getProduct())
128 1
                    ->setProductName($ProductOrderItem->getProductName())
129 1
                    ->setProductCode($ProductOrderItem->getProductCode())
130 1
                    ->setClassCategoryName1($ProductOrderItem->getClassCategoryName1())
131 1
                    ->setClassCategoryName2($ProductOrderItem->getClassCategoryName2())
132 1
                    ->setPrice($ProductOrderItem->getPrice())
133
                    ->setTax($ProductOrderItem->getTax())
134
                    ->setQuantity($ProductOrderItem->getQuantity());
135
                    $orderItemArray[$productClassId] = $OrderItem;
136 1
                }
137
            }
138
139
            return array_values($orderItemArray);
140
        }
141
142
        /**
143
         * 合計金額を計算
144
         *
145
         * @return string
146 1
         *
147
         * @deprecated
148 1
         */
149
        public function getTotalPrice()
150 1
        {
151
            @trigger_error('The '.__METHOD__.' method is deprecated.', E_USER_DEPRECATED);
152
153
            return $this->getSubtotal() + $this->getCharge() + $this->getDeliveryFeeTotal() - $this->getDiscount();
154
//        return $this->getSubtotal() + $this->getCharge() - $this->getDiscount();
155
        }
156
157
        /**
158
         * @var integer
159
         *
160
         * @ORM\Column(name="id", type="integer", options={"unsigned":true})
161
         * @ORM\Id
162
         * @ORM\GeneratedValue(strategy="IDENTITY")
163
         */
164
        private $id;
165
166
        /**
167
         * @var string|null
168
         *
169
         * @ORM\Column(name="pre_order_id", type="string", length=255, nullable=true)
170
         */
171
        private $pre_order_id;
172
173
        /**
174
         * @var string|null
175
         *
176
         * @ORM\Column(name="order_no", type="string", length=255, nullable=true)
177
         */
178
        private $order_no;
179
180
        /**
181
         * @var string|null
182
         *
183
         * @ORM\Column(name="message", type="string", length=4000, nullable=true)
184
         */
185
        private $message;
186
187
        /**
188
         * @var string|null
189
         *
190
         * @ORM\Column(name="name01", type="string", length=255)
191
         */
192
        private $name01;
193
194
        /**
195
         * @var string|null
196
         *
197
         * @ORM\Column(name="name02", type="string", length=255)
198
         */
199
        private $name02;
200
201
        /**
202
         * @var string|null
203
         *
204
         * @ORM\Column(name="kana01", type="string", length=255, nullable=true)
205
         */
206
        private $kana01;
207
208
        /**
209
         * @var string|null
210
         *
211
         * @ORM\Column(name="kana02", type="string", length=255, nullable=true)
212
         */
213
        private $kana02;
214
215
        /**
216
         * @var string|null
217
         *
218
         * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
219
         */
220
        private $company_name;
221
222
        /**
223
         * @var string|null
224
         *
225
         * @ORM\Column(name="email", type="string", length=255, nullable=true)
226
         */
227
        private $email;
228
229
        /**
230
         * @var string|null
231
         *
232
         * @ORM\Column(name="phone_number", type="string", length=14, nullable=true)
233
         */
234
        private $phone_number;
235
236
        /**
237
         * @var string|null
238
         *
239
         * @ORM\Column(name="postal_code", type="string", length=8, nullable=true)
240
         */
241
        private $postal_code;
242
243
        /**
244
         * @var string|null
245
         *
246
         * @ORM\Column(name="addr01", type="string", length=255, nullable=true)
247
         */
248
        private $addr01;
249
250
        /**
251
         * @var string|null
252
         *
253
         * @ORM\Column(name="addr02", type="string", length=255, nullable=true)
254
         */
255
        private $addr02;
256
257
        /**
258
         * @var \DateTime|null
259
         *
260
         * @ORM\Column(name="birth", type="datetimetz", nullable=true)
261
         */
262
        private $birth;
263
264
        /**
265
         * @var string
266
         *
267
         * @ORM\Column(name="subtotal", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
268
         */
269
        private $subtotal = 0;
270
271
        /**
272
         * @var string
273
         *
274
         * @ORM\Column(name="discount", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
275
         */
276
        private $discount = 0;
277
278
        /**
279
         * @var string
280
         *
281
         * @ORM\Column(name="delivery_fee_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
282
         */
283
        private $delivery_fee_total = 0;
284
285
        /**
286
         * @var string
287
         *
288
         * @ORM\Column(name="charge", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
289
         */
290
        private $charge = 0;
291
292
        /**
293
         * @var string
294
         *
295
         * @ORM\Column(name="tax", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
296
         *
297
         * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
298
         */
299
        private $tax = 0;
300
301
        /**
302
         * @var string
303
         *
304
         * @ORM\Column(name="total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
305
         */
306
        private $total = 0;
307
308
        /**
309
         * @var string
310
         *
311
         * @ORM\Column(name="payment_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
312
         */
313
        private $payment_total = 0;
314
315
        /**
316
         * @var string|null
317
         *
318
         * @ORM\Column(name="payment_method", type="string", length=255, nullable=true)
319
         */
320
        private $payment_method;
321
322
        /**
323
         * @var string|null
324
         *
325
         * @ORM\Column(name="note", type="string", length=4000, nullable=true)
326
         */
327
        private $note;
328
329
        /**
330
         * @var \DateTime
331
         *
332
         * @ORM\Column(name="create_date", type="datetimetz")
333
         */
334
        private $create_date;
335
336
        /**
337
         * @var \DateTime
338
         *
339
         * @ORM\Column(name="update_date", type="datetimetz")
340
         */
341
        private $update_date;
342
343
        /**
344
         * @var \DateTime|null
345
         *
346
         * @ORM\Column(name="order_date", type="datetimetz", nullable=true)
347
         */
348
        private $order_date;
349
350
        /**
351
         * @var \DateTime|null
352
         *
353
         * @ORM\Column(name="payment_date", type="datetimetz", nullable=true)
354
         */
355
        private $payment_date;
356
357
        /**
358
         * @var string|null
359
         *
360
         * @ORM\Column(name="currency_code", type="string", nullable=true)
361
         */
362
        private $currency_code;
363
364
        /**
365
         * 注文完了画面に表示するメッセージ
366
         *
367
         * プラグインから注文完了時にメッセージを表示したい場合, このフィールドにセットすることで, 注文完了画面で表示されます。
368
         * 複数のプラグインから利用されるため, appendCompleteMesssage()で追加してください.
369
         * 表示する際にHTMLは利用可能です。
370
         *
371
         * @var string|null
372
         *
373
         * @ORM\Column(name="complete_message", type="text", nullable=true)
374
         */
375
        private $complete_message;
376
377
        /**
378
         * 注文完了メールに表示するメッセージ
379
         *
380
         * プラグインから注文完了メールにメッセージを表示したい場合, このフィールドにセットすることで, 注文完了メールで表示されます。
381
         * 複数のプラグインから利用されるため, appendCompleteMailMesssage()で追加してください.
382
         *
383
         * @var string|null
384
         *
385
         * @ORM\Column(name="complete_mail_message", type="text", nullable=true)
386
         */
387
        private $complete_mail_message;
388
389
        /**
390
         * @var \Doctrine\Common\Collections\Collection|OrderItem[]
391
         *
392
         * @ORM\OneToMany(targetEntity="Eccube\Entity\OrderItem", mappedBy="Order", cascade={"persist","remove"})
393
         */
394
        private $OrderItems;
395
396
        /**
397
         * @var \Doctrine\Common\Collections\Collection|Shipping[]
398
         *
399
         * @ORM\OneToMany(targetEntity="Eccube\Entity\Shipping", mappedBy="Order", cascade={"persist","remove"})
400
         */
401
        private $Shippings;
402
403
        /**
404
         * @var \Doctrine\Common\Collections\Collection
405
         *
406
         * @ORM\OneToMany(targetEntity="Eccube\Entity\MailHistory", mappedBy="Order", cascade={"remove"})
407
         * @ORM\OrderBy({
408
         *     "send_date"="DESC"
409
         * })
410
         */
411
        private $MailHistories;
412
413
        /**
414
         * @var \Eccube\Entity\Customer
415
         *
416
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer", inversedBy="Orders")
417
         * @ORM\JoinColumns({
418
         *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
419
         * })
420
         */
421
        private $Customer;
422
423
        /**
424
         * @var \Eccube\Entity\Master\Country
425
         *
426
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Country")
427
         * @ORM\JoinColumns({
428
         *   @ORM\JoinColumn(name="country_id", referencedColumnName="id")
429
         * })
430
         */
431
        private $Country;
432
433
        /**
434
         * @var \Eccube\Entity\Master\Pref
435
         *
436
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Pref")
437
         * @ORM\JoinColumns({
438
         *   @ORM\JoinColumn(name="pref_id", referencedColumnName="id")
439
         * })
440
         */
441
        private $Pref;
442
443
        /**
444
         * @var \Eccube\Entity\Master\Sex
445
         *
446
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Sex")
447
         * @ORM\JoinColumns({
448
         *   @ORM\JoinColumn(name="sex_id", referencedColumnName="id")
449
         * })
450
         */
451
        private $Sex;
452
453
        /**
454
         * @var \Eccube\Entity\Master\Job
455
         *
456
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Job")
457
         * @ORM\JoinColumns({
458
         *   @ORM\JoinColumn(name="job_id", referencedColumnName="id")
459
         * })
460
         */
461
        private $Job;
462
463
        /**
464
         * @var \Eccube\Entity\Payment
465
         *
466
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Payment")
467
         * @ORM\JoinColumns({
468
         *   @ORM\JoinColumn(name="payment_id", referencedColumnName="id")
469
         * })
470
         */
471
        private $Payment;
472
473
        /**
474
         * @var \Eccube\Entity\Master\DeviceType
475
         *
476
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\DeviceType")
477
         * @ORM\JoinColumns({
478
         *   @ORM\JoinColumn(name="device_type_id", referencedColumnName="id")
479
         * })
480
         */
481
        private $DeviceType;
482
483
        /**
484
         * OrderStatusより先にプロパティを定義しておかないとセットされなくなる
485
         *
486
         * @var \Eccube\Entity\Master\CustomerOrderStatus
487
         *
488
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\CustomerOrderStatus")
489
         * @ORM\JoinColumns({
490
         *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
491
         * })
492
         */
493
        private $CustomerOrderStatus;
494
495
        /**
496
         * OrderStatusより先にプロパティを定義しておかないとセットされなくなる
497
         *
498
         * @var \Eccube\Entity\Master\OrderStatusColor
499
         *
500
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatusColor")
501 356
         * @ORM\JoinColumns({
502
         *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
503 356
         * })
504 356
         */
505 356
        private $OrderStatusColor;
506 356
507 356
        /**
508 356
         * @var \Eccube\Entity\Master\OrderStatus
509 356
         *
510 356
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatus")
511
         * @ORM\JoinColumns({
512
         *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
513 356
         * })
514 356
         */
515 356
        private $OrderStatus;
516
517
        /**
518
         * Constructor
519
         */
520
        public function __construct(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
521 7
        {
522
            $this->setDiscount(0)
0 ignored issues
show
Deprecated Code introduced by
The method Eccube\Entity\Order::setTax() has been deprecated with message: 明細ごとに集計した税額と差異が発生する場合があるため非推奨

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
523 7
            ->setSubtotal(0)
524 7
            ->setTotal(0)
525 4
            ->setPaymentTotal(0)
526
            ->setCharge(0)
527 7
            ->setTax(0)
528
            ->setDeliveryFeeTotal(0)
529
            ->setOrderStatus($orderStatus)
530
        ;
531
532
            $this->OrderItems = new \Doctrine\Common\Collections\ArrayCollection();
533
            $this->Shippings = new \Doctrine\Common\Collections\ArrayCollection();
534
            $this->MailHistories = new \Doctrine\Common\Collections\ArrayCollection();
535 124
        }
536
537 124
        /**
538
         * Clone
539
         */
540
        public function __clone()
541
        {
542
            $OriginOrderItems = $this->OrderItems;
543
            $OrderItems = new ArrayCollection();
544
            foreach ($this->OrderItems as $OrderItem) {
545
                $OrderItems->add(clone $OrderItem);
546
            }
547 205
            $this->OrderItems = $OrderItems;
548
549 205
//            // ShippingとOrderItemが循環参照するため, 手動でヒモ付を変更する.
550
//            $Shippings = new ArrayCollection();
551 205
//            foreach ($this->Shippings as $Shipping) {
552
//                $CloneShipping = clone $Shipping;
553
//                foreach ($OriginOrderItems as $OrderItem) {
554
//                    //$CloneShipping->removeOrderItem($OrderItem);
555
//                }
556
//                foreach ($this->OrderItems as $OrderItem) {
557
//                    if ($OrderItem->getShipping() && $OrderItem->getShipping()->getId() == $Shipping->getId()) {
558
//                        $OrderItem->setShipping($CloneShipping);
559 53
//                    }
560
//                    $CloneShipping->addOrderItem($OrderItem);
561 53
//                }
562
//                $Shippings->add($CloneShipping);
563
//            }
564
//            $this->Shippings = $Shippings;
565
        }
566
567
        /**
568
         * Get id.
569
         *
570
         * @return int
571 227
         */
572
        public function getId()
573 227
        {
574
            return $this->id;
575 227
        }
576
577
        /**
578
         * Set preOrderId.
579
         *
580
         * @param string|null $preOrderId
581
         *
582
         * @return Order
583 97
         */
584
        public function setPreOrderId($preOrderId = null)
585 97
        {
586
            $this->pre_order_id = $preOrderId;
587
588
            return $this;
589
        }
590
591
        /**
592
         * Get preOrderId.
593
         *
594
         * @return string|null
595 181
         */
596
        public function getPreOrderId()
597 181
        {
598
            return $this->pre_order_id;
599 181
        }
600
601
        /**
602
         * Set orderNo
603
         *
604
         * @param string|null $orderNo
605
         *
606
         * @return Order
607 81
         */
608
        public function setOrderNo($orderNo = null)
609 81
        {
610
            $this->order_no = $orderNo;
611
612
            return $this;
613
        }
614
615
        /**
616
         * Get orderNo
617
         *
618
         * @return string|null
619 18
         */
620
        public function getOrderNo()
621 18
        {
622
            return $this->order_no;
623 18
        }
624
625
        /**
626
         * Set message.
627
         *
628
         * @param string|null $message
629
         *
630
         * @return Order
631 80
         */
632
        public function setMessage($message = null)
633 80
        {
634
            $this->message = $message;
635
636
            return $this;
637
        }
638
639
        /**
640
         * Get message.
641
         *
642
         * @return string|null
643 18
         */
644
        public function getMessage()
645 18
        {
646
            return $this->message;
647 18
        }
648
649
        /**
650
         * Set name01.
651
         *
652
         * @param string|null $name01
653
         *
654
         * @return Order
655 80
         */
656
        public function setName01($name01 = null)
657 80
        {
658
            $this->name01 = $name01;
659
660
            return $this;
661
        }
662
663
        /**
664
         * Get name01.
665
         *
666
         * @return string|null
667 19
         */
668
        public function getName01()
669 19
        {
670
            return $this->name01;
671 19
        }
672
673
        /**
674
         * Set name02.
675
         *
676
         * @param string|null $name02
677
         *
678
         * @return Order
679 70
         */
680
        public function setName02($name02 = null)
681 70
        {
682
            $this->name02 = $name02;
683
684
            return $this;
685
        }
686
687
        /**
688
         * Get name02.
689
         *
690
         * @return string|null
691 19
         */
692
        public function getName02()
693 19
        {
694
            return $this->name02;
695 19
        }
696
697
        /**
698
         * Set kana01.
699
         *
700
         * @param string|null $kana01
701
         *
702
         * @return Order
703 70
         */
704
        public function setKana01($kana01 = null)
705 70
        {
706
            $this->kana01 = $kana01;
707
708
            return $this;
709
        }
710
711
        /**
712
         * Get kana01.
713
         *
714
         * @return string|null
715 16
         */
716
        public function getKana01()
717 16
        {
718
            return $this->kana01;
719 16
        }
720
721
        /**
722
         * Set kana02.
723
         *
724
         * @param string|null $kana02
725
         *
726
         * @return Order
727 71
         */
728
        public function setKana02($kana02 = null)
729 71
        {
730
            $this->kana02 = $kana02;
731
732
            return $this;
733
        }
734
735
        /**
736
         * Get kana02.
737
         *
738
         * @return string|null
739 16
         */
740
        public function getKana02()
741 16
        {
742
            return $this->kana02;
743 16
        }
744
745
        /**
746
         * Set companyName.
747
         *
748
         * @param string|null $companyName
749
         *
750
         * @return Order
751 74
         */
752
        public function setCompanyName($companyName = null)
753 74
        {
754
            $this->company_name = $companyName;
755
756
            return $this;
757
        }
758
759
        /**
760
         * Get companyName.
761
         *
762
         * @return string|null
763 17
         */
764
        public function getCompanyName()
765 17
        {
766
            return $this->company_name;
767 17
        }
768
769
        /**
770
         * Set email.
771
         *
772
         * @param string|null $email
773
         *
774
         * @return Order
775 70
         */
776
        public function setEmail($email = null)
777 70
        {
778
            $this->email = $email;
779
780
            return $this;
781
        }
782
783
        /**
784
         * Get email.
785
         *
786
         * @return string|null
787 16
         */
788
        public function getEmail()
789 16
        {
790
            return $this->email;
791 16
        }
792
793
        /**
794
         * Set phone_number.
795
         *
796
         * @param string|null $phone_number
797
         *
798
         * @return Order
799 70
         */
800
        public function setPhoneNumber($phone_number = null)
801 70
        {
802
            $this->phone_number = $phone_number;
803
804
            return $this;
805
        }
806
807
        /**
808
         * Get phone_number.
809
         *
810
         * @return string|null
811 16
         */
812
        public function getPhoneNumber()
813 16
        {
814
            return $this->phone_number;
815 16
        }
816
817
        /**
818
         * Set postal_code.
819
         *
820
         * @param string|null $postal_code
821
         *
822
         * @return Order
823 73
         */
824
        public function setPostalCode($postal_code = null)
825 73
        {
826
            $this->postal_code = $postal_code;
827
828
            return $this;
829
        }
830
831
        /**
832
         * Get postal_code.
833
         *
834
         * @return string|null
835 16
         */
836
        public function getPostalCode()
837 16
        {
838
            return $this->postal_code;
839 16
        }
840
841
        /**
842
         * Set addr01.
843
         *
844
         * @param string|null $addr01
845
         *
846
         * @return Order
847 73
         */
848
        public function setAddr01($addr01 = null)
849 73
        {
850
            $this->addr01 = $addr01;
851
852
            return $this;
853
        }
854
855
        /**
856
         * Get addr01.
857
         *
858
         * @return string|null
859 5
         */
860
        public function getAddr01()
861 5
        {
862
            return $this->addr01;
863 5
        }
864
865
        /**
866
         * Set addr02.
867
         *
868
         * @param string|null $addr02
869
         *
870
         * @return Order
871 3
         */
872
        public function setAddr02($addr02 = null)
873 3
        {
874
            $this->addr02 = $addr02;
875
876
            return $this;
877
        }
878
879
        /**
880
         * Get addr02.
881
         *
882
         * @return string|null
883 356
         */
884
        public function getAddr02()
885 356
        {
886
            return $this->addr02;
887 356
        }
888
889
        /**
890
         * Set birth.
891
         *
892
         * @param \DateTime|null $birth
893
         *
894
         * @return Order
895 60
         */
896
        public function setBirth($birth = null)
897 60
        {
898
            $this->birth = $birth;
899
900
            return $this;
901
        }
902
903
        /**
904
         * Get birth.
905
         *
906
         * @return \DateTime|null
907 356
         */
908
        public function getBirth()
909 356
        {
910
            return $this->birth;
911 356
        }
912
913
        /**
914
         * Set subtotal.
915
         *
916
         * @param string $subtotal
917
         *
918
         * @return Order
919 212
         */
920
        public function setSubtotal($subtotal)
921 212
        {
922
            $this->subtotal = $subtotal;
923
924
            return $this;
925
        }
926
927
        /**
928
         * Get subtotal.
929
         *
930
         * @return string
931 356
         */
932
        public function getSubtotal()
933 356
        {
934
            return $this->subtotal;
935 356
        }
936
937
        /**
938
         * Set discount.
939
         *
940
         * @param string $discount
941
         *
942
         * @return Order
943 75
         */
944
        public function setDiscount($discount)
945 75
        {
946
            $this->discount = $discount;
947
948
            return $this;
949
        }
950
951
        /**
952
         * Get discount.
953
         *
954
         * @return string
955 356
         */
956
        public function getDiscount()
957 356
        {
958
            return $this->discount;
959 356
        }
960
961
        /**
962
         * Set deliveryFeeTotal.
963
         *
964
         * @param string $deliveryFeeTotal
965
         *
966
         * @return Order
967 212
         */
968
        public function setDeliveryFeeTotal($deliveryFeeTotal)
969 212
        {
970
            $this->delivery_fee_total = $deliveryFeeTotal;
971
972
            return $this;
973
        }
974
975
        /**
976
         * Get deliveryFeeTotal.
977
         *
978
         * @return string
979 356
         */
980
        public function getDeliveryFeeTotal()
981 356
        {
982
            return $this->delivery_fee_total;
983 356
        }
984
985
        /**
986
         * Set charge.
987
         *
988
         * @param string $charge
989
         *
990
         * @return Order
991 16
         */
992
        public function setCharge($charge)
993 16
        {
994
            $this->charge = $charge;
995
996
            return $this;
997
        }
998
999
        /**
1000
         * Get charge.
1001
         *
1002
         * @return string
1003 356
         */
1004
        public function getCharge()
1005 356
        {
1006
            return $this->charge;
1007 356
        }
1008
1009
        /**
1010
         * Set tax.
1011
         *
1012
         * @param string $tax
1013
         *
1014
         * @return Order
1015 237
         *
1016
         * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
1017 237
         */
1018
        public function setTax($tax)
1019
        {
1020
            $this->tax = $tax;
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\Order::$tax has been deprecated with message: 明細ごとに集計した税額と差異が発生する場合があるため非推奨

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
1021
1022
            return $this;
1023
        }
1024
1025
        /**
1026
         * Get tax.
1027 356
         *
1028
         * @return string
1029 356
         *
1030
         * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
1031 356
         */
1032
        public function getTax()
1033
        {
1034
            return $this->tax;
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\Order::$tax has been deprecated with message: 明細ごとに集計した税額と差異が発生する場合があるため非推奨

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
1035
        }
1036
1037
        /**
1038
         * Set total.
1039 28
         *
1040
         * @param string $total
1041 28
         *
1042
         * @return Order
1043
         */
1044
        public function setTotal($total)
1045
        {
1046
            $this->total = $total;
1047
1048
            return $this;
1049
        }
1050
1051 218
        /**
1052
         * Get total.
1053 218
         *
1054
         * @return string
1055 218
         */
1056
        public function getTotal()
1057
        {
1058
            return $this->total;
1059
        }
1060
1061
        /**
1062
         * Set paymentTotal.
1063 20
         *
1064
         * @param string $paymentTotal
1065 20
         *
1066
         * @return Order
1067
         */
1068
        public function setPaymentTotal($paymentTotal)
1069
        {
1070
            $this->payment_total = $paymentTotal;
1071
1072
            return $this;
1073
        }
1074
1075 156
        /**
1076
         * Get paymentTotal.
1077 156
         *
1078
         * @return string
1079 156
         */
1080
        public function getPaymentTotal()
1081
        {
1082
            return $this->payment_total;
1083
        }
1084
1085
        /**
1086
         * Set paymentMethod.
1087 20
         *
1088
         * @param string|null $paymentMethod
1089 20
         *
1090
         * @return Order
1091
         */
1092
        public function setPaymentMethod($paymentMethod = null)
1093
        {
1094
            $this->payment_method = $paymentMethod;
1095
1096
            return $this;
1097
        }
1098
1099 207
        /**
1100
         * Get paymentMethod.
1101 207
         *
1102
         * @return string|null
1103 207
         */
1104
        public function getPaymentMethod()
1105
        {
1106
            return $this->payment_method;
1107
        }
1108
1109
        /**
1110
         * Set note.
1111 3
         *
1112
         * @param string|null $note
1113 3
         *
1114
         * @return Order
1115
         */
1116
        public function setNote($note = null)
1117
        {
1118
            $this->note = $note;
1119
1120
            return $this;
1121
        }
1122
1123 207
        /**
1124
         * Get note.
1125 207
         *
1126
         * @return string|null
1127 207
         */
1128
        public function getNote()
1129
        {
1130
            return $this->note;
1131
        }
1132
1133
        /**
1134
         * Set createDate.
1135 2
         *
1136
         * @param \DateTime $createDate
1137 2
         *
1138
         * @return Order
1139
         */
1140
        public function setCreateDate($createDate)
1141
        {
1142
            $this->create_date = $createDate;
1143
1144
            return $this;
1145
        }
1146
1147 47
        /**
1148
         * Get createDate.
1149 47
         *
1150
         * @return \DateTime
1151 47
         */
1152
        public function getCreateDate()
1153
        {
1154
            return $this->create_date;
1155
        }
1156
1157
        /**
1158
         * Set updateDate.
1159 33
         *
1160
         * @param \DateTime $updateDate
1161 33
         *
1162
         * @return Order
1163
         */
1164
        public function setUpdateDate($updateDate)
1165
        {
1166
            $this->update_date = $updateDate;
1167
1168
            return $this;
1169
        }
1170
1171 4
        /**
1172
         * Get updateDate.
1173 4
         *
1174
         * @return \DateTime
1175 4
         */
1176
        public function getUpdateDate()
1177
        {
1178
            return $this->update_date;
1179
        }
1180
1181
        /**
1182
         * Set orderDate.
1183 15
         *
1184
         * @param \DateTime|null $orderDate
1185 15
         *
1186
         * @return Order
1187
         */
1188
        public function setOrderDate($orderDate = null)
1189
        {
1190
            $this->order_date = $orderDate;
1191
1192
            return $this;
1193
        }
1194
1195
        /**
1196
         * Get orderDate.
1197
         *
1198
         * @return \DateTime|null
1199
         */
1200
        public function getOrderDate()
1201
        {
1202
            return $this->order_date;
1203
        }
1204
1205 207
        /**
1206
         * Set paymentDate.
1207 207
         *
1208
         * @param \DateTime|null $paymentDate
1209 207
         *
1210
         * @return Order
1211
         */
1212
        public function setPaymentDate($paymentDate = null)
1213
        {
1214
            $this->payment_date = $paymentDate;
1215 1
1216
            return $this;
1217 1
        }
1218
1219
        /**
1220
         * Get paymentDate.
1221
         *
1222
         * @return \DateTime|null
1223
         */
1224
        public function getPaymentDate()
1225
        {
1226
            return $this->payment_date;
1227
        }
1228
1229
        /**
1230
         * Get currencyCode.
1231
         *
1232
         * @return string
1233
         */
1234
        public function getCurrencyCode()
1235
        {
1236
            return $this->currency_code;
1237
        }
1238
1239
        /**
1240
         * Set currencyCode.
1241
         *
1242
         * @param string|null $currencyCode
1243
         *
1244
         * @return $this
1245
         */
1246
        public function setCurrencyCode($currencyCode = null)
1247 11
        {
1248
            $this->currency_code = $currencyCode;
1249 11
1250
            return $this;
1251
        }
1252
1253
        /**
1254
         * @return null|string
1255
         */
1256
        public function getCompleteMessage()
1257
        {
1258
            return $this->complete_message;
1259
        }
1260
1261
        /**
1262
         * @param null|string $complete_message
1263
         *
1264
         * @return $this
1265
         */
1266
        public function setCompleteMessage($complete_message = null)
1267
        {
1268
            $this->complete_message = $complete_message;
1269
1270
            return $this;
1271
        }
1272
1273
        /**
1274
         * @param null|string $complete_message
1275
         *
1276
         * @return $this
1277
         */
1278
        public function appendCompleteMessage($complete_message = null)
1279
        {
1280
            $this->complete_message .= $complete_message;
1281 36
1282
            return $this;
1283 36
        }
1284
1285 36
        /**
1286
         * @return null|string
1287
         */
1288
        public function getCompleteMailMessage()
1289
        {
1290
            return $this->complete_mail_message;
1291
        }
1292
1293
        /**
1294
         * @param null|string $complete_mail_message
1295 282
         *
1296
         * @return
1297 282
         */
1298
        public function setCompleteMailMessage($complete_mail_message = null)
1299 282
        {
1300
            $this->complete_mail_message = $complete_mail_message;
1301
1302
            return $this;
1303
        }
1304
1305
        /**
1306
         * @param null|string $complete_mail_message
1307
         *
1308
         * @return
1309 28
         */
1310
        public function appendCompleteMailMessage($complete_mail_message = null)
1311 28
        {
1312
            $this->complete_mail_message .= $complete_mail_message;
1313
1314
            return $this;
1315
        }
1316
1317
        /**
1318
         * 商品の受注明細を取得
1319 284
         *
1320
         * @return OrderItem[]
1321 284
         */
1322
        public function getProductOrderItems()
1323
        {
1324
            $sio = new OrderItemCollection($this->OrderItems->toArray());
1325
1326
            return array_values($sio->getProductClasses()->toArray());
1327
        }
1328
1329 273
        /**
1330
         * Add orderItem.
1331 273
         *
1332
         * @param \Eccube\Entity\OrderItem $OrderItem
1333
         *
1334
         * @return Order
1335
         */
1336
        public function addOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1337
        {
1338
            $this->OrderItems[] = $OrderItem;
1339
1340
            return $this;
1341 218
        }
1342
1343 218
        /**
1344
         * Remove orderItem.
1345 218
         *
1346
         * @param \Eccube\Entity\OrderItem $OrderItem
1347
         *
1348
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1349
         */
1350
        public function removeOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1351
        {
1352
            return $this->OrderItems->removeElement($OrderItem);
1353
        }
1354
1355 25
        /**
1356
         * Get orderItems.
1357 25
         *
1358
         * @return \Doctrine\Common\Collections\Collection|OrderItem[]
1359
         */
1360
        public function getOrderItems()
1361
        {
1362
            return $this->OrderItems;
1363
        }
1364
1365 115
        /**
1366
         * Sorted to getOrderItems()
1367 115
         *
1368 115
         * @return ItemCollection
1369
         */
1370 115
        public function getItems()
1371
        {
1372
            return (new ItemCollection($this->getOrderItems()))->sort();
1373
        }
1374
1375
        /**
1376
         * Add shipping.
1377
         *
1378
         * @param \Eccube\Entity\Shipping $Shipping
1379
         *
1380
         * @return Order
1381
         */
1382
        public function addShipping(\Eccube\Entity\Shipping $Shipping)
1383
        {
1384
            $this->Shippings[] = $Shipping;
1385
1386
            return $this;
1387
        }
1388
1389
        /**
1390
         * Remove shipping.
1391
         *
1392
         * @param \Eccube\Entity\Shipping $Shipping
1393
         *
1394
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1395
         */
1396
        public function removeShipping(\Eccube\Entity\Shipping $Shipping)
1397
        {
1398
            return $this->Shippings->removeElement($Shipping);
1399
        }
1400
1401
        /**
1402
         * Get shippings.
1403
         *
1404 1
         * @return \Doctrine\Common\Collections\Collection|\Eccube\Entity\Shipping[]
1405
         */
1406 1
        public function getShippings()
1407
        {
1408
            $criteria = Criteria::create()
1409
            ->orderBy(['name01' => Criteria::ASC, 'name02' => Criteria::ASC, 'id' => Criteria::ASC]);
1410
1411
            return $this->Shippings->matching($criteria);
1412
        }
1413
1414
        /**
1415
         * Add mailHistory.
1416 246
         *
1417
         * @param \Eccube\Entity\MailHistory $mailHistory
1418 246
         *
1419
         * @return Order
1420 246
         */
1421
        public function addMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1422
        {
1423
            $this->MailHistories[] = $mailHistory;
1424
1425
            return $this;
1426
        }
1427
1428 273
        /**
1429
         * Remove mailHistory.
1430 273
         *
1431
         * @param \Eccube\Entity\MailHistory $mailHistory
1432
         *
1433
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1434
         */
1435
        public function removeMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1436
        {
1437
            return $this->MailHistories->removeElement($mailHistory);
1438
        }
1439
1440
        /**
1441
         * Get mailHistories.
1442
         *
1443
         * @return \Doctrine\Common\Collections\Collection
1444
         */
1445
        public function getMailHistories()
1446
        {
1447
            return $this->MailHistories;
1448
        }
1449
1450
        /**
1451
         * Set customer.
1452
         *
1453
         * @param \Eccube\Entity\Customer|null $customer
1454
         *
1455
         * @return Order
1456
         */
1457
        public function setCustomer(\Eccube\Entity\Customer $customer = null)
1458
        {
1459
            $this->Customer = $customer;
1460
1461
            return $this;
1462
        }
1463
1464 167
        /**
1465
         * Get customer.
1466 167
         *
1467
         * @return \Eccube\Entity\Customer|null
1468 167
         */
1469
        public function getCustomer()
1470
        {
1471
            return $this->Customer;
1472
        }
1473
1474
        /**
1475
         * Set country.
1476 73
         *
1477
         * @param \Eccube\Entity\Master\Country|null $country
1478 73
         *
1479
         * @return Order
1480
         */
1481
        public function setCountry(\Eccube\Entity\Master\Country $country = null)
1482
        {
1483
            $this->Country = $country;
1484
1485
            return $this;
1486
        }
1487
1488 6
        /**
1489
         * Get country.
1490 6
         *
1491
         * @return \Eccube\Entity\Master\Country|null
1492 6
         */
1493
        public function getCountry()
1494
        {
1495
            return $this->Country;
1496
        }
1497
1498
        /**
1499
         * Set pref.
1500 3
         *
1501
         * @param \Eccube\Entity\Master\Pref|null $pref
1502 3
         *
1503
         * @return Order
1504
         */
1505
        public function setPref(\Eccube\Entity\Master\Pref $pref = null)
1506
        {
1507
            $this->Pref = $pref;
1508
1509
            return $this;
1510
        }
1511
1512 5
        /**
1513
         * Get pref.
1514 5
         *
1515
         * @return \Eccube\Entity\Master\Pref|null
1516 5
         */
1517
        public function getPref()
1518
        {
1519
            return $this->Pref;
1520
        }
1521
1522
        /**
1523
         * Set sex.
1524 3
         *
1525
         * @param \Eccube\Entity\Master\Sex|null $sex
1526 3
         *
1527
         * @return Order
1528
         */
1529
        public function setSex(\Eccube\Entity\Master\Sex $sex = null)
1530
        {
1531
            $this->Sex = $sex;
1532
1533
            return $this;
1534
        }
1535
1536 218
        /**
1537
         * Get sex.
1538 218
         *
1539
         * @return \Eccube\Entity\Master\Sex|null
1540 218
         */
1541
        public function getSex()
1542
        {
1543
            return $this->Sex;
1544
        }
1545
1546
        /**
1547
         * Set job.
1548 218
         *
1549
         * @param \Eccube\Entity\Master\Job|null $job
1550 218
         *
1551
         * @return Order
1552
         */
1553
        public function setJob(\Eccube\Entity\Master\Job $job = null)
1554
        {
1555
            $this->Job = $job;
1556
1557
            return $this;
1558
        }
1559
1560 51
        /**
1561
         * Get job.
1562 51
         *
1563
         * @return \Eccube\Entity\Master\Job|null
1564 51
         */
1565
        public function getJob()
1566
        {
1567
            return $this->Job;
1568
        }
1569
1570
        /**
1571
         * Set payment.
1572 2
         *
1573
         * @param \Eccube\Entity\Payment|null $payment
1574 2
         *
1575
         * @return Order
1576
         */
1577
        public function setPayment(\Eccube\Entity\Payment $payment = null)
1578
        {
1579
            $this->Payment = $payment;
1580
1581
            return $this;
1582
        }
1583
1584
        /**
1585
         * Get payment.
1586
         *
1587
         * @return \Eccube\Entity\Payment|null
1588
         */
1589
        public function getPayment()
1590
        {
1591
            return $this->Payment;
1592
        }
1593
1594
        /**
1595
         * Set deviceType.
1596
         *
1597
         * @param \Eccube\Entity\Master\DeviceType|null $deviceType
1598
         *
1599
         * @return Order
1600
         */
1601
        public function setDeviceType(\Eccube\Entity\Master\DeviceType $deviceType = null)
1602
        {
1603
            $this->DeviceType = $deviceType;
1604
1605
            return $this;
1606
        }
1607
1608 356
        /**
1609
         * Get deviceType.
1610 356
         *
1611
         * @return \Eccube\Entity\Master\DeviceType|null
1612 356
         */
1613
        public function getDeviceType()
1614
        {
1615
            return $this->DeviceType;
1616
        }
1617
1618
        /**
1619
         * Set customerOrderStatus.
1620 237
         *
1621
         * @param \Eccube\Entity\Master\CustomerOrderStatus|null $customerOrderStatus
1622 237
         *
1623
         * @return Order
1624
         */
1625
        public function setCustomerOrderStatus(\Eccube\Entity\Master\CustomerOrderStatus $customerOrderStatus = null)
1626
        {
1627
            $this->CustomerOrderStatus = $customerOrderStatus;
1628 72
1629
            return $this;
1630 72
        }
1631
1632
        /**
1633 1
         * Get customerOrderStatus.
1634
         *
1635 1
         * @return \Eccube\Entity\Master\CustomerOrderStatus|null
1636 1
         */
1637 1
        public function getCustomerOrderStatus()
1638
        {
1639
            return $this->CustomerOrderStatus;
1640 1
        }
1641
1642
        /**
1643
         * Set orderStatusColor.
1644
         *
1645
         * @param \Eccube\Entity\Master\OrderStatusColor|null $orderStatusColor
1646
         *
1647
         * @return Order
1648
         */
1649
        public function setOrderStatusColor(\Eccube\Entity\Master\OrderStatusColor $orderStatusColor = null)
1650
        {
1651
            $this->OrderStatusColor = $orderStatusColor;
1652
1653
            return $this;
1654
        }
1655
1656
        /**
1657
         * Get orderStatusColor.
1658
         *
1659
         * @return \Eccube\Entity\Master\OrderStatusColor|null
1660
         */
1661
        public function getOrderStatusColor()
1662
        {
1663
            return $this->OrderStatusColor;
1664
        }
1665
1666
        /**
1667
         * Set orderStatus.
1668
         *
1669
         * @param \Eccube\Entity\Master\OrderStatus|null|object $orderStatus
1670
         *
1671
         * @return Order
1672
         */
1673
        public function setOrderStatus(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
1674
        {
1675
            $this->OrderStatus = $orderStatus;
1676
1677
            return $this;
1678
        }
1679
1680
        /**
1681
         * Get orderStatus.
1682
         *
1683
         * @return \Eccube\Entity\Master\OrderStatus|null
1684
         */
1685
        public function getOrderStatus()
1686
        {
1687
            return $this->OrderStatus;
1688
        }
1689
1690
        /**
1691
         * @param ItemInterface $item
1692
         */
1693
        public function addItem(ItemInterface $item)
1694
        {
1695
            $this->OrderItems->add($item);
1696
        }
1697
1698
        public function getQuantity()
1699
        {
1700
            $quantity = 0;
1701
            foreach ($this->getItems() as $item) {
1702
                $quantity += $item->getQuantity();
1703
            }
1704
1705
            return $quantity;
1706
        }
1707
    }
1708
}
1709