Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
49:41 queued 37:58
created

Order::getDeliveryFeeTotal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.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\ORM\Mapping as ORM;
17
use Eccube\Service\Calculator\OrderItemCollection;
18
use Eccube\Service\PurchaseFlow\ItemCollection;
19
20
/**
21
 * Order
22
 *
23
 * @ORM\Table(name="dtb_order", indexes={@ORM\Index(name="dtb_order_pre_order_id_idx", columns={"pre_order_id"}), @ORM\Index(name="dtb_order_email_idx", columns={"email"}), @ORM\Index(name="dtb_order_order_date_idx", columns={"order_date"}), @ORM\Index(name="dtb_order_payment_date_idx", columns={"payment_date"}), @ORM\Index(name="dtb_order_shipping_date_idx", columns={"shipping_date"}), @ORM\Index(name="dtb_order_update_date_idx", columns={"update_date"})})
24
 * @ORM\InheritanceType("SINGLE_TABLE")
25
 * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
26
 * @ORM\HasLifecycleCallbacks()
27
 * @ORM\Entity(repositoryClass="Eccube\Repository\OrderRepository")
28
 */
29
class Order extends \Eccube\Entity\AbstractEntity implements PurchaseInterface, ItemHolderInterface
30
{
31
    use PointTrait;
32
33
    /**
34
     * isMultiple
35
     *
36
     * @return boolean
37
     */
38 50
    public function isMultiple()
39
    {
40 50
        return count($this->getShippings()) > 1 ? true : false;
41
    }
42
43
    /**
44
     * 対象となるお届け先情報を取得
45
     *
46
     * @param integer $shippingId
47
     *
48
     * @return \Eccube\Entity\Shipping|null
49
     */
50
    public function findShipping($shippingId)
51
    {
52
        foreach ($this->getShippings() as $Shipping) {
53
            if ($Shipping->getId() == $shippingId) {
54
                return $Shipping;
55
            }
56
        }
57
58
        return null;
59
    }
60
61
    /**
62
     * この注文の保持する販売種別を取得します.
63
     *
64
     * @return \Eccube\Entity\Master\SaleType[] 一意な販売種別の配列
65
     */
66 1
    public function getSaleTypes()
67
    {
68 1
        $saleTypes = [];
69 1
        foreach ($this->getOrderItems() as $OrderItem) {
70
            /* @var $ProductClass \Eccube\Entity\ProductClass */
71 1
            $ProductClass = $OrderItem->getProductClass();
72 1
            if ($ProductClass) {
73 1
                $saleTypes[] = $ProductClass->getSaleType();
74
            }
75
        }
76
77 1
        return array_unique($saleTypes);
78
    }
79
80
    /**
81
     * 合計金額を計算
82
     *
83
     * @return string
84
     *
85
     * @deprecated
86
     */
87 1
    public function getTotalPrice()
88
    {
89 1
        @trigger_error('The '.__METHOD__.' method is deprecated.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
90
91 1
        return $this->getSubtotal() + $this->getCharge() + $this->getDeliveryFeeTotal() - $this->getDiscount();
92
//        return $this->getSubtotal() + $this->getCharge() - $this->getDiscount();
93
    }
94
95
    /**
96
     * @var integer
97
     *
98
     * @ORM\Column(name="id", type="integer", options={"unsigned":true})
99
     * @ORM\Id
100
     * @ORM\GeneratedValue(strategy="IDENTITY")
101
     */
102
    private $id;
103
104
    /**
105
     * @var string|null
106
     *
107
     * @ORM\Column(name="pre_order_id", type="string", length=255, nullable=true)
108
     */
109
    private $pre_order_id;
110
111
    /**
112
     * @var string|null
113
     *
114
     * @ORM\Column(name="order_code", type="string", length=255, nullable=true)
115
     */
116
    private $order_code;
117
118
    /**
119
     * @var string|null
120
     *
121
     * @ORM\Column(name="message", type="string", length=4000, nullable=true)
122
     */
123
    private $message;
124
125
    /**
126
     * @var string|null
127
     *
128
     * @ORM\Column(name="name01", type="string", length=255, nullable=true)
129
     */
130
    private $name01;
131
132
    /**
133
     * @var string|null
134
     *
135
     * @ORM\Column(name="name02", type="string", length=255, nullable=true)
136
     */
137
    private $name02;
138
139
    /**
140
     * @var string|null
141
     *
142
     * @ORM\Column(name="kana01", type="string", length=255, nullable=true)
143
     */
144
    private $kana01;
145
146
    /**
147
     * @var string|null
148
     *
149
     * @ORM\Column(name="kana02", type="string", length=255, nullable=true)
150
     */
151
    private $kana02;
152
153
    /**
154
     * @var string|null
155
     *
156
     * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
157
     */
158
    private $company_name;
159
160
    /**
161
     * @var string|null
162
     *
163
     * @ORM\Column(name="email", type="string", length=255, nullable=true)
164
     */
165
    private $email;
166
167
    /**
168
     * @var string|null
169
     *
170
     * @ORM\Column(name="tel01", type="string", length=5, nullable=true)
171
     */
172
    private $tel01;
173
174
    /**
175
     * @var string|null
176
     *
177
     * @ORM\Column(name="tel02", type="string", length=4, nullable=true)
178
     */
179
    private $tel02;
180
181
    /**
182
     * @var string|null
183
     *
184
     * @ORM\Column(name="tel03", type="string", length=4, nullable=true)
185
     */
186
    private $tel03;
187
188
    /**
189
     * @var string|null
190
     *
191
     * @ORM\Column(name="fax01", type="string", length=5, nullable=true)
192
     */
193
    private $fax01;
194
195
    /**
196
     * @var string|null
197
     *
198
     * @ORM\Column(name="fax02", type="string", length=4, nullable=true)
199
     */
200
    private $fax02;
201
202
    /**
203
     * @var string|null
204
     *
205
     * @ORM\Column(name="fax03", type="string", length=4, nullable=true)
206
     */
207
    private $fax03;
208
209
    /**
210
     * @var string|null
211
     *
212
     * @ORM\Column(name="zip01", type="string", length=3, nullable=true)
213
     */
214
    private $zip01;
215
216
    /**
217
     * @var string|null
218
     *
219
     * @ORM\Column(name="zip02", type="string", length=4, nullable=true)
220
     */
221
    private $zip02;
222
223
    /**
224
     * @var string|null
225
     *
226
     * @ORM\Column(name="zipcode", type="string", length=7, nullable=true)
227
     */
228
    private $zipcode;
229
230
    /**
231
     * @var string|null
232
     *
233
     * @ORM\Column(name="addr01", type="string", length=255, nullable=true)
234
     */
235
    private $addr01;
236
237
    /**
238
     * @var string|null
239
     *
240
     * @ORM\Column(name="addr02", type="string", length=255, nullable=true)
241
     */
242
    private $addr02;
243
244
    /**
245
     * @var \DateTime|null
246
     *
247
     * @ORM\Column(name="birth", type="datetimetz", nullable=true)
248
     */
249
    private $birth;
250
251
    /**
252
     * @var string
253
     *
254
     * @ORM\Column(name="subtotal", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
255
     */
256
    private $subtotal = 0;
257
258
    /**
259
     * @var string
260
     *
261
     * @ORM\Column(name="discount", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
262
     */
263
    private $discount = 0;
264
265
    /**
266
     * @var string
267
     *
268
     * @ORM\Column(name="delivery_fee_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
269
     */
270
    private $delivery_fee_total = 0;
271
272
    /**
273
     * @var string
274
     *
275
     * @ORM\Column(name="charge", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
276
     */
277
    private $charge = 0;
278
279
    /**
280
     * @var string
281
     *
282
     * @ORM\Column(name="tax", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
283
     */
284
    private $tax = 0;
285
286
    /**
287
     * @var string
288
     *
289
     * @ORM\Column(name="total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
290
     */
291
    private $total = 0;
292
293
    /**
294
     * @var string
295
     *
296
     * @ORM\Column(name="payment_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
297
     */
298
    private $payment_total = 0;
299
300
    /**
301
     * @var string|null
302
     *
303
     * @ORM\Column(name="payment_method", type="string", length=255, nullable=true)
304
     */
305
    private $payment_method;
306
307
    /**
308
     * @var string|null
309
     *
310
     * @ORM\Column(name="note", type="string", length=4000, nullable=true)
311
     */
312
    private $note;
313
314
    /**
315
     * @var \DateTime
316
     *
317
     * @ORM\Column(name="create_date", type="datetimetz")
318
     */
319
    private $create_date;
320
321
    /**
322
     * @var \DateTime
323
     *
324
     * @ORM\Column(name="update_date", type="datetimetz")
325
     */
326
    private $update_date;
327
328
    /**
329
     * @var \DateTime|null
330
     *
331
     * @ORM\Column(name="order_date", type="datetimetz", nullable=true)
332
     */
333
    private $order_date;
334
335
    /**
336
     * @var \DateTime|null
337
     *
338
     * @ORM\Column(name="shipping_date", type="datetimetz", nullable=true)
339
     */
340
    private $shipping_date;
341
342
    /**
343
     * @var \DateTime|null
344
     *
345
     * @ORM\Column(name="payment_date", type="datetimetz", nullable=true)
346
     */
347
    private $payment_date;
348
349
    /**
350
     * @var string|null
351
     *
352
     * @ORM\Column(name="currency_code", type="string", nullable=true)
353
     */
354
    private $currency_code;
355
356
    /**
357
     * @var \Doctrine\Common\Collections\Collection
358
     *
359
     * @ORM\OneToMany(targetEntity="Eccube\Entity\OrderItem", mappedBy="Order", cascade={"persist","remove"})
360
     */
361
    private $OrderItems;
362
363
    /**
364
     * @var \Doctrine\Common\Collections\Collection
365
     *
366
     * @ORM\OneToMany(targetEntity="Eccube\Entity\MailHistory", mappedBy="Order", cascade={"remove"})
367
     * @ORM\OrderBy({
368
     *     "send_date"="DESC"
369
     * })
370
     */
371
    private $MailHistories;
372
373
    /**
374
     * @var \Eccube\Entity\Customer
375
     *
376
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer", inversedBy="Orders")
377
     * @ORM\JoinColumns({
378
     *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
379
     * })
380
     */
381
    private $Customer;
382
383
    /**
384
     * @var \Eccube\Entity\Master\Country
385
     *
386
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Country")
387
     * @ORM\JoinColumns({
388
     *   @ORM\JoinColumn(name="country_id", referencedColumnName="id")
389
     * })
390
     */
391
    private $Country;
392
393
    /**
394
     * @var \Eccube\Entity\Master\Pref
395
     *
396
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Pref")
397
     * @ORM\JoinColumns({
398
     *   @ORM\JoinColumn(name="pref_id", referencedColumnName="id")
399
     * })
400
     */
401
    private $Pref;
402
403
    /**
404
     * @var \Eccube\Entity\Master\Sex
405
     *
406
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Sex")
407
     * @ORM\JoinColumns({
408
     *   @ORM\JoinColumn(name="sex_id", referencedColumnName="id")
409
     * })
410
     */
411
    private $Sex;
412
413
    /**
414
     * @var \Eccube\Entity\Master\Job
415
     *
416
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Job")
417
     * @ORM\JoinColumns({
418
     *   @ORM\JoinColumn(name="job_id", referencedColumnName="id")
419
     * })
420
     */
421
    private $Job;
422
423
    /**
424
     * @var \Eccube\Entity\Payment
425
     *
426
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Payment")
427
     * @ORM\JoinColumns({
428
     *   @ORM\JoinColumn(name="payment_id", referencedColumnName="id")
429
     * })
430
     */
431
    private $Payment;
432
433
    /**
434
     * @var \Eccube\Entity\Master\DeviceType
435
     *
436
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\DeviceType")
437
     * @ORM\JoinColumns({
438
     *   @ORM\JoinColumn(name="device_type_id", referencedColumnName="id")
439
     * })
440
     */
441
    private $DeviceType;
442
443
    /**
444
     * @var \Eccube\Entity\Master\CustomerOrderStatus
445
     *
446
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\CustomerOrderStatus")
447
     * @ORM\JoinColumns({
448
     *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
449
     * })
450
     */
451
    private $CustomerOrderStatus;
452
453
    /**
454
     * @var \Eccube\Entity\Master\OrderStatus
455
     *
456
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatus")
457
     * @ORM\JoinColumns({
458
     *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
459
     * })
460
     */
461
    private $OrderStatus;
462
463
    /**
464
     * Constructor
465
     */
466 224
    public function __construct(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
467
    {
468 224
        $this->setDiscount(0)
469 224
            ->setSubtotal(0)
470 224
            ->setTotal(0)
471 224
            ->setPaymentTotal(0)
472 224
            ->setCharge(0)
473 224
            ->setTax(0)
474 224
            ->setDeliveryFeeTotal(0)
475 224
            ->setOrderStatus($orderStatus)
476
        ;
477
478 224
        $this->OrderItems = new \Doctrine\Common\Collections\ArrayCollection();
479 224
        $this->MailHistories = new \Doctrine\Common\Collections\ArrayCollection();
480
    }
481
482
    /**
483
     * Get id.
484
     *
485
     * @return int
486
     */
487 188
    public function getId()
488
    {
489 188
        return $this->id;
490
    }
491
492
    /**
493
     * Set preOrderId.
494
     *
495
     * @param string|null $preOrderId
496
     *
497
     * @return Order
498
     */
499 185
    public function setPreOrderId($preOrderId = null)
500
    {
501 185
        $this->pre_order_id = $preOrderId;
502
503 185
        return $this;
504
    }
505
506
    /**
507
     * Get preOrderId.
508
     *
509
     * @return string|null
510
     */
511 53
    public function getPreOrderId()
512
    {
513 53
        return $this->pre_order_id;
514
    }
515
516
    /**
517
     * Set orderCode
518
     *
519
     * @param string|null $orderCode
520
     *
521
     * @return Order
522
     */
523 19
    public function setOrderCode($orderCode = null)
524
    {
525 19
        $this->order_code = $orderCode;
526
527 19
        return $this;
528
    }
529
530
    /**
531
     * Get orderCode
532
     *
533
     * @return string|null
534
     */
535 30
    public function getOrderCode()
536
    {
537 30
        return $this->order_code;
538
    }
539
540
    /**
541
     * Set message.
542
     *
543
     * @param string|null $message
544
     *
545
     * @return Order
546
     */
547 161
    public function setMessage($message = null)
548
    {
549 161
        $this->message = $message;
550
551 161
        return $this;
552
    }
553
554
    /**
555
     * Get message.
556
     *
557
     * @return string|null
558
     */
559 73
    public function getMessage()
560
    {
561 73
        return $this->message;
562
    }
563
564
    /**
565
     * Set name01.
566
     *
567
     * @param string|null $name01
568
     *
569
     * @return Order
570
     */
571 18
    public function setName01($name01 = null)
572
    {
573 18
        $this->name01 = $name01;
574
575 18
        return $this;
576
    }
577
578
    /**
579
     * Get name01.
580
     *
581
     * @return string|null
582
     */
583 90
    public function getName01()
584
    {
585 90
        return $this->name01;
586
    }
587
588
    /**
589
     * Set name02.
590
     *
591
     * @param string|null $name02
592
     *
593
     * @return Order
594
     */
595 18
    public function setName02($name02 = null)
596
    {
597 18
        $this->name02 = $name02;
598
599 18
        return $this;
600
    }
601
602
    /**
603
     * Get name02.
604
     *
605
     * @return string|null
606
     */
607 82
    public function getName02()
608
    {
609 82
        return $this->name02;
610
    }
611
612
    /**
613
     * Set kana01.
614
     *
615
     * @param string|null $kana01
616
     *
617
     * @return Order
618
     */
619 19
    public function setKana01($kana01 = null)
620
    {
621 19
        $this->kana01 = $kana01;
622
623 19
        return $this;
624
    }
625
626
    /**
627
     * Get kana01.
628
     *
629
     * @return string|null
630
     */
631 75
    public function getKana01()
632
    {
633 75
        return $this->kana01;
634
    }
635
636
    /**
637
     * Set kana02.
638
     *
639
     * @param string|null $kana02
640
     *
641
     * @return Order
642
     */
643 19
    public function setKana02($kana02 = null)
644
    {
645 19
        $this->kana02 = $kana02;
646
647 19
        return $this;
648
    }
649
650
    /**
651
     * Get kana02.
652
     *
653
     * @return string|null
654
     */
655 75
    public function getKana02()
656
    {
657 75
        return $this->kana02;
658
    }
659
660
    /**
661
     * Set companyName.
662
     *
663
     * @param string|null $companyName
664
     *
665
     * @return Order
666
     */
667 16
    public function setCompanyName($companyName = null)
668
    {
669 16
        $this->company_name = $companyName;
670
671 16
        return $this;
672
    }
673
674
    /**
675
     * Get companyName.
676
     *
677
     * @return string|null
678
     */
679 46
    public function getCompanyName()
680
    {
681 46
        return $this->company_name;
682
    }
683
684
    /**
685
     * Set email.
686
     *
687
     * @param string|null $email
688
     *
689
     * @return Order
690
     */
691 16
    public function setEmail($email = null)
692
    {
693 16
        $this->email = $email;
694
695 16
        return $this;
696
    }
697
698
    /**
699
     * Get email.
700
     *
701
     * @return string|null
702
     */
703 49
    public function getEmail()
704
    {
705 49
        return $this->email;
706
    }
707
708
    /**
709
     * Set tel01.
710
     *
711
     * @param string|null $tel01
712
     *
713
     * @return Order
714
     */
715 17
    public function setTel01($tel01 = null)
716
    {
717 17
        $this->tel01 = $tel01;
718
719 17
        return $this;
720
    }
721
722
    /**
723
     * Get tel01.
724
     *
725
     * @return string|null
726
     */
727 71
    public function getTel01()
728
    {
729 71
        return $this->tel01;
730
    }
731
732
    /**
733
     * Set tel02.
734
     *
735
     * @param string|null $tel02
736
     *
737
     * @return Order
738
     */
739 17
    public function setTel02($tel02 = null)
740
    {
741 17
        $this->tel02 = $tel02;
742
743 17
        return $this;
744
    }
745
746
    /**
747
     * Get tel02.
748
     *
749
     * @return string|null
750
     */
751 71
    public function getTel02()
752
    {
753 71
        return $this->tel02;
754
    }
755
756
    /**
757
     * Set tel03.
758
     *
759
     * @param string|null $tel03
760
     *
761
     * @return Order
762
     */
763 17
    public function setTel03($tel03 = null)
764
    {
765 17
        $this->tel03 = $tel03;
766
767 17
        return $this;
768
    }
769
770
    /**
771
     * Get tel03.
772
     *
773
     * @return string|null
774
     */
775 71
    public function getTel03()
776
    {
777 71
        return $this->tel03;
778
    }
779
780
    /**
781
     * Set fax01.
782
     *
783
     * @param string|null $fax01
784
     *
785
     * @return Order
786
     */
787 16
    public function setFax01($fax01 = null)
788
    {
789 16
        $this->fax01 = $fax01;
790
791 16
        return $this;
792
    }
793
794
    /**
795
     * Get fax01.
796
     *
797
     * @return string|null
798
     */
799 32
    public function getFax01()
800
    {
801 32
        return $this->fax01;
802
    }
803
804
    /**
805
     * Set fax02.
806
     *
807
     * @param string|null $fax02
808
     *
809
     * @return Order
810
     */
811 16
    public function setFax02($fax02 = null)
812
    {
813 16
        $this->fax02 = $fax02;
814
815 16
        return $this;
816
    }
817
818
    /**
819
     * Get fax02.
820
     *
821
     * @return string|null
822
     */
823 32
    public function getFax02()
824
    {
825 32
        return $this->fax02;
826
    }
827
828
    /**
829
     * Set fax03.
830
     *
831
     * @param string|null $fax03
832
     *
833
     * @return Order
834
     */
835 16
    public function setFax03($fax03 = null)
836
    {
837 16
        $this->fax03 = $fax03;
838
839 16
        return $this;
840
    }
841
842
    /**
843
     * Get fax03.
844
     *
845
     * @return string|null
846
     */
847 32
    public function getFax03()
848
    {
849 32
        return $this->fax03;
850
    }
851
852
    /**
853
     * Set zip01.
854
     *
855
     * @param string|null $zip01
856
     *
857
     * @return Order
858
     */
859 16
    public function setZip01($zip01 = null)
860
    {
861 16
        $this->zip01 = $zip01;
862
863 16
        return $this;
864
    }
865
866
    /**
867
     * Get zip01.
868
     *
869
     * @return string|null
870
     */
871 75
    public function getZip01()
872
    {
873 75
        return $this->zip01;
874
    }
875
876
    /**
877
     * Set zip02.
878
     *
879
     * @param string|null $zip02
880
     *
881
     * @return Order
882
     */
883 16
    public function setZip02($zip02 = null)
884
    {
885 16
        $this->zip02 = $zip02;
886
887 16
        return $this;
888
    }
889
890
    /**
891
     * Get zip02.
892
     *
893
     * @return string|null
894
     */
895 75
    public function getZip02()
896
    {
897 75
        return $this->zip02;
898
    }
899
900
    /**
901
     * Set zipcode.
902
     *
903
     * @param string|null $zipcode
904
     *
905
     * @return Order
906
     */
907
    public function setZipcode($zipcode = null)
908
    {
909
        $this->zipcode = $zipcode;
910
911
        return $this;
912
    }
913
914
    /**
915
     * Get zipcode.
916
     *
917
     * @return string|null
918
     */
919
    public function getZipcode()
920
    {
921
        return $this->zipcode;
922
    }
923
924
    /**
925
     * Set addr01.
926
     *
927
     * @param string|null $addr01
928
     *
929
     * @return Order
930
     */
931 16
    public function setAddr01($addr01 = null)
932
    {
933 16
        $this->addr01 = $addr01;
934
935 16
        return $this;
936
    }
937
938
    /**
939
     * Get addr01.
940
     *
941
     * @return string|null
942
     */
943 75
    public function getAddr01()
944
    {
945 75
        return $this->addr01;
946
    }
947
948
    /**
949
     * Set addr02.
950
     *
951
     * @param string|null $addr02
952
     *
953
     * @return Order
954
     */
955 16
    public function setAddr02($addr02 = null)
956
    {
957 16
        $this->addr02 = $addr02;
958
959 16
        return $this;
960
    }
961
962
    /**
963
     * Get addr02.
964
     *
965
     * @return string|null
966
     */
967 75
    public function getAddr02()
968
    {
969 75
        return $this->addr02;
970
    }
971
972
    /**
973
     * Set birth.
974
     *
975
     * @param \DateTime|null $birth
976
     *
977
     * @return Order
978
     */
979 5
    public function setBirth($birth = null)
980
    {
981 5
        $this->birth = $birth;
982
983 5
        return $this;
984
    }
985
986
    /**
987
     * Get birth.
988
     *
989
     * @return \DateTime|null
990
     */
991 4
    public function getBirth()
992
    {
993 4
        return $this->birth;
994
    }
995
996
    /**
997
     * Set subtotal.
998
     *
999
     * @param string $subtotal
1000
     *
1001
     * @return Order
1002
     */
1003 224
    public function setSubtotal($subtotal)
1004
    {
1005 224
        $this->subtotal = $subtotal;
1006
1007 224
        return $this;
1008
    }
1009
1010
    /**
1011
     * Get subtotal.
1012
     *
1013
     * @return string
1014
     */
1015 58
    public function getSubtotal()
1016
    {
1017 58
        return $this->subtotal;
1018
    }
1019
1020
    /**
1021
     * Set discount.
1022
     *
1023
     * @param string $discount
1024
     *
1025
     * @return Order
1026
     */
1027 224
    public function setDiscount($discount)
1028
    {
1029 224
        $this->discount = $discount;
1030
1031 224
        return $this;
1032
    }
1033
1034
    /**
1035
     * Get discount.
1036
     *
1037
     * @return string
1038
     */
1039 192
    public function getDiscount()
1040
    {
1041 192
        return $this->discount;
1042
    }
1043
1044
    /**
1045
     * Set deliveryFeeTotal.
1046
     *
1047
     * @param string $deliveryFeeTotal
1048
     *
1049
     * @return Order
1050
     */
1051 224
    public function setDeliveryFeeTotal($deliveryFeeTotal)
1052
    {
1053 224
        $this->delivery_fee_total = $deliveryFeeTotal;
1054
1055 224
        return $this;
1056
    }
1057
1058
    /**
1059
     * Get deliveryFeeTotal.
1060
     *
1061
     * @return string
1062
     */
1063 73
    public function getDeliveryFeeTotal()
1064
    {
1065 73
        return $this->delivery_fee_total;
1066
    }
1067
1068
    /**
1069
     * Set charge.
1070
     *
1071
     * @param string $charge
1072
     *
1073
     * @return Order
1074
     */
1075 224
    public function setCharge($charge)
1076
    {
1077 224
        $this->charge = $charge;
1078
1079 224
        return $this;
1080
    }
1081
1082
    /**
1083
     * Get charge.
1084
     *
1085
     * @return string
1086
     */
1087 192
    public function getCharge()
1088
    {
1089 192
        return $this->charge;
1090
    }
1091
1092
    /**
1093
     * Set tax.
1094
     *
1095
     * @param string $tax
1096
     *
1097
     * @return Order
1098
     */
1099 224
    public function setTax($tax)
1100
    {
1101 224
        $this->tax = $tax;
1102
1103 224
        return $this;
1104
    }
1105
1106
    /**
1107
     * Get tax.
1108
     *
1109
     * @return string
1110
     */
1111 17
    public function getTax()
1112
    {
1113 17
        return $this->tax;
1114
    }
1115
1116
    /**
1117
     * Set total.
1118
     *
1119
     * @param string $total
1120
     *
1121
     * @return Order
1122
     */
1123 224
    public function setTotal($total)
1124
    {
1125 224
        $this->total = $total;
1126
1127 224
        return $this;
1128
    }
1129
1130
    /**
1131
     * Get total.
1132
     *
1133
     * @return string
1134
     */
1135 190
    public function getTotal()
1136
    {
1137 190
        return $this->total;
1138
    }
1139
1140
    /**
1141
     * Set paymentTotal.
1142
     *
1143
     * @param string $paymentTotal
1144
     *
1145
     * @return Order
1146
     */
1147 224
    public function setPaymentTotal($paymentTotal)
1148
    {
1149 224
        $this->payment_total = $paymentTotal;
1150
1151 224
        return $this;
1152
    }
1153
1154
    /**
1155
     * Get paymentTotal.
1156
     *
1157
     * @return string
1158
     */
1159 26
    public function getPaymentTotal()
1160
    {
1161 26
        return $this->payment_total;
1162
    }
1163
1164
    /**
1165
     * Set paymentMethod.
1166
     *
1167
     * @param string|null $paymentMethod
1168
     *
1169
     * @return Order
1170
     */
1171 198
    public function setPaymentMethod($paymentMethod = null)
1172
    {
1173 198
        $this->payment_method = $paymentMethod;
1174
1175 198
        return $this;
1176
    }
1177
1178
    /**
1179
     * Get paymentMethod.
1180
     *
1181
     * @return string|null
1182
     */
1183 21
    public function getPaymentMethod()
1184
    {
1185 21
        return $this->payment_method;
1186
    }
1187
1188
    /**
1189
     * Set note.
1190
     *
1191
     * @param string|null $note
1192
     *
1193
     * @return Order
1194
     */
1195 136
    public function setNote($note = null)
1196
    {
1197 136
        $this->note = $note;
1198
1199 136
        return $this;
1200
    }
1201
1202
    /**
1203
     * Get note.
1204
     *
1205
     * @return string|null
1206
     */
1207 28
    public function getNote()
1208
    {
1209 28
        return $this->note;
1210
    }
1211
1212
    /**
1213
     * Set createDate.
1214
     *
1215
     * @param \DateTime $createDate
1216
     *
1217
     * @return Order
1218
     */
1219 187
    public function setCreateDate($createDate)
1220
    {
1221 187
        $this->create_date = $createDate;
1222
1223 187
        return $this;
1224
    }
1225
1226
    /**
1227
     * Get createDate.
1228
     *
1229
     * @return \DateTime
1230
     */
1231
    public function getCreateDate()
1232
    {
1233
        return $this->create_date;
1234
    }
1235
1236
    /**
1237
     * Set updateDate.
1238
     *
1239
     * @param \DateTime $updateDate
1240
     *
1241
     * @return Order
1242
     */
1243 187
    public function setUpdateDate($updateDate)
1244
    {
1245 187
        $this->update_date = $updateDate;
1246
1247 187
        return $this;
1248
    }
1249
1250
    /**
1251
     * Get updateDate.
1252
     *
1253
     * @return \DateTime
1254
     */
1255 2
    public function getUpdateDate()
1256
    {
1257 2
        return $this->update_date;
1258
    }
1259
1260
    /**
1261
     * Set orderDate.
1262
     *
1263
     * @param \DateTime|null $orderDate
1264
     *
1265
     * @return Order
1266
     */
1267 34
    public function setOrderDate($orderDate = null)
1268
    {
1269 34
        $this->order_date = $orderDate;
1270
1271 34
        return $this;
1272
    }
1273
1274
    /**
1275
     * Get orderDate.
1276
     *
1277
     * @return \DateTime|null
1278
     */
1279 13
    public function getOrderDate()
1280
    {
1281 13
        return $this->order_date;
1282
    }
1283
1284
    /**
1285
     * Set shippingDate.
1286
     *
1287
     * @param \DateTime|null $shippingDate
1288
     *
1289
     * @return Order
1290
     */
1291 4
    public function setShippingDate($shippingDate = null)
1292
    {
1293 4
        $this->shipping_date = $shippingDate;
1294
1295 4
        return $this;
1296
    }
1297
1298
    /**
1299
     * Get shippingDate.
1300
     *
1301
     * @return \DateTime|null
1302
     */
1303 7
    public function getShippingDate()
1304
    {
1305 7
        return $this->shipping_date;
1306
    }
1307
1308
    /**
1309
     * Set paymentDate.
1310
     *
1311
     * @param \DateTime|null $paymentDate
1312
     *
1313
     * @return Order
1314
     */
1315 4
    public function setPaymentDate($paymentDate = null)
1316
    {
1317 4
        $this->payment_date = $paymentDate;
1318
1319 4
        return $this;
1320
    }
1321
1322
    /**
1323
     * Get paymentDate.
1324
     *
1325
     * @return \DateTime|null
1326
     */
1327 9
    public function getPaymentDate()
1328
    {
1329 9
        return $this->payment_date;
1330
    }
1331
1332
    /**
1333
     * Get currencyCode.
1334
     *
1335
     * @return string
1336
     */
1337
    public function getCurrencyCode()
1338
    {
1339
        return $this->currency_code;
1340
    }
1341
1342
    /**
1343
     * Set currencyCode.
1344
     *
1345
     * @param string|null $currencyCode
1346
     *
1347
     * @return $this
1348
     */
1349 187
    public function setCurrencyCode($currencyCode = null)
1350
    {
1351 187
        $this->currency_code = $currencyCode;
1352
1353 187
        return $this;
1354
    }
1355
1356
    /**
1357
     * 商品の受注明細を取得
1358
     *
1359
     * @return OrderItem[]
1360
     */
1361 30
    public function getProductOrderItems()
1362
    {
1363 30
        $sio = new OrderItemCollection($this->OrderItems->toArray());
1364
1365 30
        return array_values($sio->getProductClasses()->toArray());
1366
    }
1367
1368
    /**
1369
     * 同じ規格の商品の個数をまとめた受注明細を取得
1370
     *
1371
     * @return OrderItem[]
1372
     */
1373 1
    public function getMergedProductOrderItems()
1374
    {
1375 1
        $ProductOrderItems = $this->getProductOrderItems();
1376
1377 1
        $orderItemArray = [];
1378
1379
        /** @var OrderItem $ProductOrderItem */
1380 1
        foreach ($ProductOrderItems as $ProductOrderItem) {
1381 1
            $productClassId = $ProductOrderItem->getProductClass()->getId();
1382 1
            if (array_key_exists($productClassId, $orderItemArray)) {
1383
                // 同じ規格の商品がある場合は個数をまとめる
1384
                /** @var ItemInterface $OrderItem */
1385 1
                $OrderItem = $orderItemArray[$productClassId];
1386 1
                $quantity = $OrderItem->getQuantity() + $ProductOrderItem->getQuantity();
1387 1
                $OrderItem->setQuantity($quantity);
1388
            } else {
1389
                // 新規規格の商品は新しく追加する
1390 1
                $OrderItem = new OrderItem();
1391
                $OrderItem
1392 1
                    ->setProduct($ProductOrderItem->getProduct())
1393 1
                    ->setProductName($ProductOrderItem->getProductName())
1394 1
                    ->setClassCategoryName1($ProductOrderItem->getClassCategoryName1())
1395 1
                    ->setClassCategoryName2($ProductOrderItem->getClassCategoryName2())
1396 1
                    ->setPriceIncTax($ProductOrderItem->getPriceIncTax())
1397 1
                    ->setQuantity($ProductOrderItem->getQuantity());
1398 1
                $orderItemArray[$productClassId] = $OrderItem;
1399
            }
1400
        }
1401
1402 1
        return array_values($orderItemArray);
1403
    }
1404
1405
    /**
1406
     * Add orderItem.
1407
     *
1408
     * @param \Eccube\Entity\OrderItem $OrderItem
1409
     *
1410
     * @return Order
1411
     */
1412 207
    public function addOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1413
    {
1414 207
        $this->OrderItems[] = $OrderItem;
1415
1416 207
        return $this;
1417
    }
1418
1419
    /**
1420
     * Remove orderItem.
1421
     *
1422
     * @param \Eccube\Entity\OrderItem $OrderItem
1423
     *
1424
     * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1425
     */
1426 28
    public function removeOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1427
    {
1428 28
        return $this->OrderItems->removeElement($OrderItem);
1429
    }
1430
1431
    /**
1432
     * Get orderItems.
1433
     *
1434
     * @return \Doctrine\Common\Collections\Collection
1435
     */
1436 218
    public function getOrderItems()
1437
    {
1438 218
        return $this->OrderItems;
1439
    }
1440
1441
    /**
1442
     * Sorted to getOrderItems()
1443
     *
1444
     * @return ItemCollection
1445
     */
1446 197
    public function getItems()
1447
    {
1448 197
        return (new ItemCollection($this->getOrderItems()))->sort();
1449
    }
1450
1451
    /**
1452
     * Get shippings.
1453
     *
1454
     * 明細に紐づくShippingを, 重複をのぞいて取得する
1455
     *
1456
     * @return \Doctrine\Common\Collections\Collection|Shipping[]
1457
     */
1458 90
    public function getShippings()
1459
    {
1460 90
        $Shippings = [];
1461 90
        foreach ($this->getOrderItems() as $OrderItem) {
1462 89
            if ($Shipping = $OrderItem->getShipping()) {
1463
                // 永続化される前のShippingが渡ってくる場合もあるため,
1464
                // Shipping::id()ではなくspl_object_id()を使用している
1465 89
                $id = \spl_object_id($Shipping);
1466 89
                if (!isset($Shippings[$id])) {
1467 89
                    $Shippings[$id] = $Shipping;
1468
                }
1469
            }
1470
        }
1471
1472 90
        usort($Shippings, function (Shipping $a, Shipping $b) {
1473 16
            $result = strnatcmp($a->getName01(), $b->getName01());
1474 16
            if ($result === 0) {
1475 1
                return strnatcmp($a->getName02(), $b->getName02());
1476
            } else {
1477 16
                return $result;
1478
            }
1479 90
        });
1480
1481 90
        $Result = new \Doctrine\Common\Collections\ArrayCollection();
1482 90
        foreach ($Shippings as $Shipping) {
1483 89
            $Result->add($Shipping);
1484
        }
1485
1486 90
        return $Result;
1487
        // XXX 以下のロジックだと何故か空の Collection になってしまう場合がある
1488
        // return new \Doctrine\Common\Collections\ArrayCollection(array_values($Shippings));
1489
    }
1490
1491 25
    public function setShippings($dummy)
0 ignored issues
show
Unused Code introduced by
The parameter $dummy is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1492
    {
1493
        // XXX これが無いと Eccube\Form\Type\Shopping\OrderType がエラーになる
1494 25
        return $this;
1495
    }
1496
1497
    /**
1498
     * Add mailHistory.
1499
     *
1500
     * @param \Eccube\Entity\MailHistory $mailHistory
1501
     *
1502
     * @return Order
1503
     */
1504
    public function addMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1505
    {
1506
        $this->MailHistories[] = $mailHistory;
1507
1508
        return $this;
1509
    }
1510
1511
    /**
1512
     * Remove mailHistory.
1513
     *
1514
     * @param \Eccube\Entity\MailHistory $mailHistory
1515
     *
1516
     * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1517
     */
1518
    public function removeMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1519
    {
1520
        return $this->MailHistories->removeElement($mailHistory);
1521
    }
1522
1523
    /**
1524
     * Get mailHistories.
1525
     *
1526
     * @return \Doctrine\Common\Collections\Collection
1527
     */
1528 1
    public function getMailHistories()
1529
    {
1530 1
        return $this->MailHistories;
1531
    }
1532
1533
    /**
1534
     * Set customer.
1535
     *
1536
     * @param \Eccube\Entity\Customer|null $customer
1537
     *
1538
     * @return Order
1539
     */
1540 170
    public function setCustomer(\Eccube\Entity\Customer $customer = null)
1541
    {
1542 170
        $this->Customer = $customer;
1543
1544 170
        return $this;
1545
    }
1546
1547
    /**
1548
     * Get customer.
1549
     *
1550
     * @return \Eccube\Entity\Customer|null
1551
     */
1552 81
    public function getCustomer()
1553
    {
1554 81
        return $this->Customer;
1555
    }
1556
1557
    /**
1558
     * Set country.
1559
     *
1560
     * @param \Eccube\Entity\Master\Country|null $country
1561
     *
1562
     * @return Order
1563
     */
1564
    public function setCountry(\Eccube\Entity\Master\Country $country = null)
1565
    {
1566
        $this->Country = $country;
1567
1568
        return $this;
1569
    }
1570
1571
    /**
1572
     * Get country.
1573
     *
1574
     * @return \Eccube\Entity\Master\Country|null
1575
     */
1576
    public function getCountry()
1577
    {
1578
        return $this->Country;
1579
    }
1580
1581
    /**
1582
     * Set pref.
1583
     *
1584
     * @param \Eccube\Entity\Master\Pref|null $pref
1585
     *
1586
     * @return Order
1587
     */
1588 147
    public function setPref(\Eccube\Entity\Master\Pref $pref = null)
1589
    {
1590 147
        $this->Pref = $pref;
1591
1592 147
        return $this;
1593
    }
1594
1595
    /**
1596
     * Get pref.
1597
     *
1598
     * @return \Eccube\Entity\Master\Pref|null
1599
     */
1600 75
    public function getPref()
1601
    {
1602 75
        return $this->Pref;
1603
    }
1604
1605
    /**
1606
     * Set sex.
1607
     *
1608
     * @param \Eccube\Entity\Master\Sex|null $sex
1609
     *
1610
     * @return Order
1611
     */
1612 6
    public function setSex(\Eccube\Entity\Master\Sex $sex = null)
1613
    {
1614 6
        $this->Sex = $sex;
1615
1616 6
        return $this;
1617
    }
1618
1619
    /**
1620
     * Get sex.
1621
     *
1622
     * @return \Eccube\Entity\Master\Sex|null
1623
     */
1624 4
    public function getSex()
1625
    {
1626 4
        return $this->Sex;
1627
    }
1628
1629
    /**
1630
     * Set job.
1631
     *
1632
     * @param \Eccube\Entity\Master\Job|null $job
1633
     *
1634
     * @return Order
1635
     */
1636 5
    public function setJob(\Eccube\Entity\Master\Job $job = null)
1637
    {
1638 5
        $this->Job = $job;
1639
1640 5
        return $this;
1641
    }
1642
1643
    /**
1644
     * Get job.
1645
     *
1646
     * @return \Eccube\Entity\Master\Job|null
1647
     */
1648 4
    public function getJob()
1649
    {
1650 4
        return $this->Job;
1651
    }
1652
1653
    /**
1654
     * Set payment.
1655
     *
1656
     * @param \Eccube\Entity\Payment|null $payment
1657
     *
1658
     * @return Order
1659
     */
1660 198
    public function setPayment(\Eccube\Entity\Payment $payment = null)
1661
    {
1662 198
        $this->Payment = $payment;
1663
1664 198
        return $this;
1665
    }
1666
1667
    /**
1668
     * Get payment.
1669
     *
1670
     * @return \Eccube\Entity\Payment|null
1671
     */
1672 198
    public function getPayment()
1673
    {
1674 198
        return $this->Payment;
1675
    }
1676
1677
    /**
1678
     * Set deviceType.
1679
     *
1680
     * @param \Eccube\Entity\Master\DeviceType|null $deviceType
1681
     *
1682
     * @return Order
1683
     */
1684 3
    public function setDeviceType(\Eccube\Entity\Master\DeviceType $deviceType = null)
1685
    {
1686 3
        $this->DeviceType = $deviceType;
1687
1688 3
        return $this;
1689
    }
1690
1691
    /**
1692
     * Get deviceType.
1693
     *
1694
     * @return \Eccube\Entity\Master\DeviceType|null
1695
     */
1696
    public function getDeviceType()
1697
    {
1698
        return $this->DeviceType;
1699
    }
1700
1701
    /**
1702
     * Set customerOrderStatus.
1703
     *
1704
     * @param \Eccube\Entity\Master\CustomerOrderStatus|null $customerOrderStatus
1705
     *
1706
     * @return Order
1707
     */
1708
    public function setCustomerOrderStatus(\Eccube\Entity\Master\CustomerOrderStatus $customerOrderStatus = null)
1709
    {
1710
        $this->CustomerOrderStatus = $customerOrderStatus;
1711
1712
        return $this;
1713
    }
1714
1715
    /**
1716
     * Get customerOrderStatus.
1717
     *
1718
     * @return \Eccube\Entity\Master\CustomerOrderStatus|null
1719
     */
1720
    public function getCustomerOrderStatus()
1721
    {
1722
        return $this->CustomerOrderStatus;
1723
    }
1724
1725
    /**
1726
     * Set orderStatus.
1727
     *
1728
     * @param \Eccube\Entity\Master\OrderStatus|null $orderStatus
1729
     *
1730
     * @return Order
1731
     */
1732 224
    public function setOrderStatus(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
1733
    {
1734 224
        $this->OrderStatus = $orderStatus;
1735
1736 224
        return $this;
1737
    }
1738
1739
    /**
1740
     * Get orderStatus.
1741
     *
1742
     * @return \Eccube\Entity\Master\OrderStatus|null
1743
     */
1744 154
    public function getOrderStatus()
1745
    {
1746 154
        return $this->OrderStatus;
1747
    }
1748
1749
    /**
1750
     * @param ItemInterface $item
1751
     */
1752 56
    public function addItem(ItemInterface $item)
1753
    {
1754 56
        $this->OrderItems->add($item);
1755
    }
1756
1757 1
    public function getQuantity()
1758
    {
1759 1
        $quantity = 0;
1760 1
        foreach ($this->getItems() as $item) {
1761 1
            $quantity += $item->getQuantity();
1762
        }
1763
1764 1
        return $quantity;
1765
    }
1766
}
1767