-
Notifications
You must be signed in to change notification settings - Fork 720
Expand file tree
/
Copy pathOrder.php
More file actions
1540 lines (1289 loc) · 37.6 KB
/
Copy pathOrder.php
File metadata and controls
1540 lines (1289 loc) · 37.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eccube\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use Eccube\Entity\Master\AgentProtocol;
use Eccube\Entity\Master\Country;
use Eccube\Entity\Master\CustomerOrderStatus;
use Eccube\Entity\Master\DeviceType;
use Eccube\Entity\Master\Job;
use Eccube\Entity\Master\OrderStatus;
use Eccube\Entity\Master\OrderStatusColor;
use Eccube\Entity\Master\Pref;
use Eccube\Entity\Master\RoundingType;
use Eccube\Entity\Master\Sex;
use Eccube\Entity\Master\TaxType;
use Eccube\Repository\OrderRepository;
use Eccube\Service\Calculator\OrderItemCollection;
use Eccube\Service\PurchaseFlow\ItemCollection;
use Eccube\Service\TaxRuleService;
/**
* Order
*/
#[ORM\Table(name: 'dtb_order')]
#[ORM\Index(columns: ['email'], name: 'dtb_order_email_idx')]
#[ORM\Index(columns: ['order_date'], name: 'dtb_order_order_date_idx')]
#[ORM\Index(columns: ['payment_date'], name: 'dtb_order_payment_date_idx')]
#[ORM\Index(columns: ['update_date'], name: 'dtb_order_update_date_idx')]
#[ORM\Index(columns: ['order_no'], name: 'dtb_order_order_no_idx')]
#[ORM\UniqueConstraint(name: 'dtb_order_pre_order_id_idx', columns: ['pre_order_id'])]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discriminator_type', type: 'string', length: 255)]
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: OrderRepository::class)]
class Order extends AbstractEntity implements PurchaseInterface, ItemHolderInterface
{
use NameTrait;
use PointTrait;
/**
* 課税対象の明細を返す.
*
* @return OrderItem[]
*/
public function getTaxableItems(): array
{
$Items = [];
foreach ($this->OrderItems as $Item) {
if (null === $Item->getTaxType()) {
continue;
}
if ($Item->getTaxType()->getId() == TaxType::TAXATION) {
$Items[] = $Item;
}
}
return $Items;
}
/**
* 課税対象の明細の合計金額を返す.
* 商品合計 + 送料 + 手数料 + 値引き(課税).
*/
public function getTaxableTotal(): string
{
$total = '0';
foreach ($this->getTaxableItems() as $Item) {
$total = bcadd($total, $Item->getTotalPrice(), 2);
}
return $total;
}
/**
* 課税対象の明細の合計金額を、税率ごとに集計する.
*
* @return array<string, string> [税率 => 合計金額]
*/
public function getTaxableTotalByTaxRate(): array
{
$total = [];
foreach ($this->getTaxableItems() as $Item) {
$totalPrice = $Item->getTotalPrice();
$taxRate = $Item->getTaxRate();
$total[$taxRate] = isset($total[$taxRate])
? bcadd($total[$taxRate], $totalPrice, 2)
: $totalPrice;
}
krsort($total, SORT_NUMERIC);
return $total;
}
/**
* 明細の合計額を税率ごとに集計する.
*
* 不課税, 非課税の値引明細は税率ごとに按分する.
*
* @return array<string, string>
*/
public function getTotalByTaxRate(): array
{
$roundingTypes = $this->getRoundingTypeByTaxRate();
$total = [];
$taxableTotal = $this->getTaxableTotal();
$taxFreeDiscount = $this->getTaxFreeDiscount();
foreach ($this->getTaxableTotalByTaxRate() as $rate => $totalPrice) {
if (!array_key_exists($rate, $roundingTypes) || null === $roundingTypes[$rate]) {
continue;
}
if (bccomp($taxableTotal, '0', 2) !== 0) {
// 按分計算: totalPrice - (abs(taxFreeDiscount) * totalPrice / taxableTotal)
$absDiscount = ltrim($taxFreeDiscount, '-');
$discountPortion = bcdiv(bcmul($absDiscount, $totalPrice, 6), $taxableTotal, 6);
$value = bcsub($totalPrice, $discountPortion, 6);
} else {
$value = '0';
}
$total[$rate] = TaxRuleService::roundByRoundingType(
$value,
$roundingTypes[$rate]->getId()
);
}
ksort($total);
return $total;
}
/**
* 税額を税率ごとに集計する.
*
* 不課税, 非課税の値引明細は税率ごとに按分する.
*
* @return array<string, string>
*/
public function getTaxByTaxRate(): array
{
$roundingTypes = $this->getRoundingTypeByTaxRate();
$tax = [];
$taxableTotal = $this->getTaxableTotal();
$taxFreeDiscount = $this->getTaxFreeDiscount();
foreach ($this->getTaxableTotalByTaxRate() as $rate => $totalPrice) {
if (!array_key_exists($rate, $roundingTypes) || null === $roundingTypes[$rate]) {
continue;
}
if (bccomp($taxableTotal, '0', 2) !== 0) {
// (totalPrice - abs(taxFreeDiscount) * totalPrice / taxableTotal) * (rate / (100 + rate))
$absDiscount = ltrim($taxFreeDiscount, '-');
// abs(taxFreeDiscount) * totalPrice / taxableTotal
$discountPortion = bcdiv(bcmul($absDiscount, $totalPrice, 6), $taxableTotal, 6);
// totalPrice - discountPortion
$afterDiscount = bcsub($totalPrice, $discountPortion, 6);
// rate / (100 + rate)
$rateStr = $rate;
$taxRate = bcdiv($rateStr, bcadd('100', $rateStr, 6), 6);
// 最終計算
$value = bcmul($afterDiscount, $taxRate, 6);
} else {
$value = '0';
}
$tax[$rate] = TaxRuleService::roundByRoundingType(
$value,
$roundingTypes[$rate]->getId()
);
}
ksort($tax);
return $tax;
}
/**
* 課税対象の値引き明細を返す.
*
* @return array<int, OrderItem>
*/
public function getTaxableDiscountItems(): array
{
/** @var OrderItem[] $items */
$items = (new ItemCollection($this->getTaxableItems()))->sort()->toArray();
return array_filter($items, fn (OrderItem $Item) => $Item->isDiscount());
}
/**
* 課税対象の値引き金額合計を返す.
*/
public function getTaxableDiscount(): string
{
return array_reduce($this->getTaxableDiscountItems(), fn ($sum, OrderItem $Item) => bcadd($sum, $Item->getTotalPrice(), 2), '0');
}
/**
* 非課税・不課税の値引き明細を返す.
*
* @return array<int, OrderItem>
*/
public function getTaxFreeDiscountItems(): array
{
/** @var OrderItem[] $items */
$items = (new ItemCollection($this->getOrderItems()))->sort()->toArray();
return array_filter($items, fn (OrderItem $Item) => $Item->isPoint() || ($Item->isDiscount() && $Item->getTaxType()->getId() != TaxType::TAXATION));
}
/**
* 非課税・不課税の値引き額を返す.
*/
public function getTaxFreeDiscount(): string
{
return array_reduce($this->getTaxFreeDiscountItems(), fn ($sum, OrderItem $Item) => bcadd($sum, $Item->getTotalPrice(), 2), '0');
}
/**
* 税率ごとの丸め規則を取得する.
*
* @return array<string, RoundingType|null>
*/
public function getRoundingTypeByTaxRate(): array
{
$roundingTypes = [];
foreach ($this->getTaxableItems() as $Item) {
$roundingTypes[$Item->getTaxRate()] = $Item->getRoundingType();
}
return $roundingTypes;
}
/**
* 複数配送かどうかの判定を行う.
*/
public function isMultiple(): bool
{
$Shippings = [];
// クエリビルダ使用時に絞り込まれる場合があるため,
// getShippingsではなくOrderItem経由でShippingを取得する.
foreach ($this->getOrderItems() as $OrderItem) {
if ($Shipping = $OrderItem->getShipping()) {
$id = $Shipping->getId();
if (isset($Shippings[$id])) {
continue;
}
$Shippings[$id] = $Shipping;
}
}
return count($Shippings) > 1 ? true : false;
}
/**
* 対象となるお届け先情報を取得
*/
public function findShipping(int $shippingId): ?Shipping
{
foreach ($this->getShippings() as $Shipping) {
if ($Shipping->getId() == $shippingId) {
return $Shipping;
}
}
return null;
}
/**
* この注文の保持する販売種別を取得します.
*
* @return Master\SaleType[] 一意な販売種別の配列
*/
public function getSaleTypes(): array
{
$saleTypes = [];
foreach ($this->getOrderItems() as $OrderItem) {
$ProductClass = $OrderItem->getProductClass();
if ($ProductClass) {
$saleTypes[] = $ProductClass->getSaleType();
}
}
return array_unique($saleTypes);
}
/**
* 同じ規格の商品の個数をまとめた受注明細を取得
*
* @return OrderItem[]
*/
public function getMergedProductOrderItems(): array
{
$ProductOrderItems = $this->getProductOrderItems();
$orderItemArray = [];
/** @var OrderItem $ProductOrderItem */
foreach ($ProductOrderItems as $ProductOrderItem) {
$productClassId = $ProductOrderItem->getProductClass()->getId();
if (array_key_exists($productClassId, $orderItemArray)) {
// 同じ規格の商品がある場合は個数をまとめる
$OrderItem = $orderItemArray[$productClassId];
$quantity = bcadd($OrderItem->getQuantity(), $ProductOrderItem->getQuantity());
$OrderItem->setQuantity($quantity);
} else {
// 新規規格の商品は新しく追加する
$OrderItem = new OrderItem();
$OrderItem->copyProperties($ProductOrderItem, ['id']);
$orderItemArray[$productClassId] = $OrderItem;
}
}
return array_values($orderItemArray);
}
/**
* 合計金額を計算
*
* @deprecated
*/
public function getTotalPrice(): string
{
@trigger_error('The '.__METHOD__.' method is deprecated.', E_USER_DEPRECATED);
return $this->getPaymentTotal();
}
#[ORM\Column(name: 'id', type: Types::INTEGER, options: ['unsigned' => true])]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private ?int $id = null;
#[ORM\Column(name: 'pre_order_id', type: Types::STRING, length: 255, nullable: true)]
private ?string $pre_order_id = null;
#[ORM\Column(name: 'order_no', type: Types::STRING, length: 255, nullable: true)]
private ?string $order_no = null;
#[ORM\Column(name: 'message', type: Types::STRING, length: 4000, nullable: true)]
private ?string $message = null;
#[ORM\Column(name: 'name01', type: Types::STRING, length: 255)]
private ?string $name01 = null;
#[ORM\Column(name: 'name02', type: Types::STRING, length: 255)]
private ?string $name02 = null;
#[ORM\Column(name: 'kana01', type: Types::STRING, length: 255, nullable: true)]
private ?string $kana01 = null;
#[ORM\Column(name: 'kana02', type: Types::STRING, length: 255, nullable: true)]
private ?string $kana02 = null;
#[ORM\Column(name: 'company_name', type: Types::STRING, length: 255, nullable: true)]
private ?string $company_name = null;
#[ORM\Column(name: 'email', type: Types::STRING, length: 255, nullable: true)]
private ?string $email = null;
#[ORM\Column(name: 'phone_number', type: Types::STRING, length: 14, nullable: true)]
private ?string $phone_number = null;
#[ORM\Column(name: 'postal_code', type: Types::STRING, length: 8, nullable: true)]
private ?string $postal_code = null;
#[ORM\Column(name: 'addr01', type: Types::STRING, length: 255, nullable: true)]
private ?string $addr01 = null;
#[ORM\Column(name: 'addr02', type: Types::STRING, length: 255, nullable: true)]
private ?string $addr02 = null;
/**
* @var \DateTime|null
*/
#[ORM\Column(name: 'birth', type: Types::DATETIMETZ_MUTABLE, nullable: true)]
private $birth;
#[ORM\Column(name: 'subtotal', type: Types::DECIMAL, precision: 12, scale: 2, options: ['unsigned' => true, 'default' => 0])]
private ?string $subtotal = '0';
#[ORM\Column(name: 'discount', type: Types::DECIMAL, precision: 12, scale: 2, options: ['unsigned' => true, 'default' => 0])]
private ?string $discount = '0';
#[ORM\Column(name: 'delivery_fee_total', type: Types::DECIMAL, precision: 12, scale: 2, options: ['unsigned' => true, 'default' => 0])]
private ?string $delivery_fee_total = '0';
#[ORM\Column(name: 'charge', type: Types::DECIMAL, precision: 12, scale: 2, options: ['unsigned' => true, 'default' => 0])]
private ?string $charge = '0';
/**
* @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
*/
#[ORM\Column(name: 'tax', type: Types::DECIMAL, precision: 12, scale: 2, options: ['unsigned' => true, 'default' => 0])]
private ?string $tax = '0';
#[ORM\Column(name: 'total', type: Types::DECIMAL, precision: 12, scale: 2, options: ['unsigned' => true, 'default' => 0])]
private ?string $total = '0';
#[ORM\Column(name: 'payment_total', type: Types::DECIMAL, precision: 12, scale: 2, options: ['unsigned' => true, 'default' => 0])]
private ?string $payment_total = '0';
#[ORM\Column(name: 'payment_method', type: Types::STRING, length: 255, nullable: true)]
private ?string $payment_method = null;
#[ORM\Column(name: 'note', type: Types::STRING, length: 4000, nullable: true)]
private ?string $note = null;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'create_date', type: Types::DATETIMETZ_MUTABLE)]
private $create_date;
/**
* @var \DateTime
*/
#[ORM\Column(name: 'update_date', type: Types::DATETIMETZ_MUTABLE)]
private $update_date;
/**
* @var \DateTime|null
*/
#[ORM\Column(name: 'order_date', type: Types::DATETIMETZ_MUTABLE, nullable: true)]
private $order_date;
/**
* @var \DateTime|null
*/
#[ORM\Column(name: 'payment_date', type: Types::DATETIMETZ_MUTABLE, nullable: true)]
private $payment_date;
#[ORM\Column(name: 'currency_code', type: Types::STRING, nullable: true)]
private ?string $currency_code = null;
/**
* 注文完了画面に表示するメッセージ
*
* プラグインから注文完了時にメッセージを表示したい場合, このフィールドにセットすることで, 注文完了画面で表示されます。
* 複数のプラグインから利用されるため, appendCompleteMesssage()で追加してください.
* 表示する際にHTMLは利用可能です。
*/
#[ORM\Column(name: 'complete_message', type: Types::TEXT, nullable: true)]
private ?string $complete_message = null;
/**
* 注文完了メールに表示するメッセージ
*
* プラグインから注文完了メールにメッセージを表示したい場合, このフィールドにセットすることで, 注文完了メールで表示されます。
* 複数のプラグインから利用されるため, appendCompleteMailMesssage()で追加してください.
*/
#[ORM\Column(name: 'complete_mail_message', type: Types::TEXT, nullable: true)]
private ?string $complete_mail_message = null;
/**
* エージェントコマース (ACP/UCP) 経由の注文のプロトコル種別マスタへの参照.
*
* 通常購入では null。エージェント経由の注文でのみ ACP / UCP がセットされる。
*/
#[ORM\ManyToOne(targetEntity: AgentProtocol::class)]
#[ORM\JoinColumn(name: 'agent_protocol_id', referencedColumnName: 'id')]
private ?AgentProtocol $AgentProtocol = null;
/**
* エージェントコマース経由の注文を発行したエージェントの識別子.
*
* 通常購入では null。
*/
#[ORM\Column(name: 'agent_id', type: Types::STRING, length: 255, nullable: true)]
private ?string $agent_id = null;
/**
* @var Collection<int, OrderItem>
*/
#[ORM\OneToMany(targetEntity: OrderItem::class, mappedBy: 'Order', cascade: ['persist', 'remove'])]
private $OrderItems;
/**
* @var Collection<int, Shipping>
*/
#[ORM\OneToMany(targetEntity: Shipping::class, mappedBy: 'Order', cascade: ['persist', 'remove'])]
private $Shippings;
/**
* @var Collection<int, MailHistory>
*/
#[ORM\OneToMany(targetEntity: MailHistory::class, mappedBy: 'Order', cascade: ['remove'])]
#[ORM\OrderBy(['send_date' => 'DESC'])]
private $MailHistories;
#[ORM\ManyToOne(targetEntity: Customer::class, inversedBy: 'Orders')]
#[ORM\JoinColumn(name: 'customer_id', referencedColumnName: 'id')]
private ?Customer $Customer = null;
#[ORM\ManyToOne(targetEntity: Country::class)]
#[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id')]
private ?Country $Country = null;
#[ORM\ManyToOne(targetEntity: Pref::class)]
#[ORM\JoinColumn(name: 'pref_id', referencedColumnName: 'id')]
private ?Pref $Pref = null;
#[ORM\ManyToOne(targetEntity: Sex::class)]
#[ORM\JoinColumn(name: 'sex_id', referencedColumnName: 'id')]
private ?Sex $Sex = null;
#[ORM\ManyToOne(targetEntity: Job::class)]
#[ORM\JoinColumn(name: 'job_id', referencedColumnName: 'id')]
private ?Job $Job = null;
#[ORM\ManyToOne(targetEntity: Payment::class)]
#[ORM\JoinColumn(name: 'payment_id', referencedColumnName: 'id')]
private ?Payment $Payment = null;
#[ORM\ManyToOne(targetEntity: DeviceType::class)]
#[ORM\JoinColumn(name: 'device_type_id', referencedColumnName: 'id')]
private ?DeviceType $DeviceType = null;
/**
* OrderStatusより先にプロパティを定義しておかないとセットされなくなる
*/
#[ORM\ManyToOne(targetEntity: CustomerOrderStatus::class)]
#[ORM\JoinColumn(name: 'order_status_id', referencedColumnName: 'id')]
private ?CustomerOrderStatus $CustomerOrderStatus = null;
/**
* OrderStatusより先にプロパティを定義しておかないとセットされなくなる
*/
#[ORM\ManyToOne(targetEntity: OrderStatusColor::class)]
#[ORM\JoinColumn(name: 'order_status_id', referencedColumnName: 'id')]
private ?OrderStatusColor $OrderStatusColor = null;
#[ORM\ManyToOne(targetEntity: OrderStatus::class)]
#[ORM\JoinColumn(name: 'order_status_id', referencedColumnName: 'id')]
private ?OrderStatus $OrderStatus = null;
/**
* Constructor
*/
public function __construct(?OrderStatus $OrderStatus = null)
{
$this->setDiscount('0')
->setSubtotal('0')
->setTotal('0')
->setPaymentTotal('0')
->setCharge('0')
->setTax('0')
->setDeliveryFeeTotal('0');
$this->OrderItems = new ArrayCollection();
$this->Shippings = new ArrayCollection();
$this->MailHistories = new ArrayCollection();
if ($OrderStatus !== null) {
$this->setOrderStatus($OrderStatus);
}
}
/**
* Clone
*/
public function __clone()
{
$OrderItems = new ArrayCollection();
foreach ($this->OrderItems as $OrderItem) {
$OrderItems->add(clone $OrderItem);
}
$this->OrderItems = $OrderItems;
// // ShippingとOrderItemが循環参照するため, 手動でヒモ付を変更する.
// $Shippings = new ArrayCollection();
// foreach ($this->Shippings as $Shipping) {
// $CloneShipping = clone $Shipping;
// foreach ($OriginOrderItems as $OrderItem) {
// //$CloneShipping->removeOrderItem($OrderItem);
// }
// foreach ($this->OrderItems as $OrderItem) {
// if ($OrderItem->getShipping() && $OrderItem->getShipping()->getId() == $Shipping->getId()) {
// $OrderItem->setShipping($CloneShipping);
// }
// $CloneShipping->addOrderItem($OrderItem);
// }
// $Shippings->add($CloneShipping);
// }
// $this->Shippings = $Shippings;
}
/**
* Get id.
*/
public function getId(): ?int
{
return $this->id;
}
/**
* Set preOrderId.
*/
public function setPreOrderId(?string $preOrderId = null): Order
{
$this->pre_order_id = $preOrderId;
return $this;
}
/**
* Get preOrderId.
*/
public function getPreOrderId(): ?string
{
return $this->pre_order_id;
}
/**
* Set orderNo
*/
public function setOrderNo(?string $orderNo = null): Order
{
$this->order_no = $orderNo;
return $this;
}
/**
* Get orderNo
*/
public function getOrderNo(): ?string
{
return $this->order_no;
}
/**
* Set message.
*/
public function setMessage(?string $message = null): Order
{
$this->message = $message;
return $this;
}
/**
* Get message.
*/
public function getMessage(): ?string
{
return $this->message;
}
/**
* Set name01.
*/
public function setName01(?string $name01 = null): Order
{
$this->name01 = $name01;
return $this;
}
/**
* Get name01.
*/
public function getName01(): ?string
{
return $this->name01;
}
/**
* Set name02.
*/
public function setName02(?string $name02 = null): Order
{
$this->name02 = $name02;
return $this;
}
/**
* Get name02.
*/
public function getName02(): ?string
{
return $this->name02;
}
/**
* Set kana01.
*/
public function setKana01(?string $kana01 = null): Order
{
$this->kana01 = $kana01;
return $this;
}
/**
* Get kana01.
*/
public function getKana01(): ?string
{
return $this->kana01;
}
/**
* Set kana02.
*/
public function setKana02(?string $kana02 = null): Order
{
$this->kana02 = $kana02;
return $this;
}
/**
* Get kana02.
*/
public function getKana02(): ?string
{
return $this->kana02;
}
/**
* Set companyName.
*/
public function setCompanyName(?string $companyName = null): Order
{
$this->company_name = $companyName;
return $this;
}
/**
* Get companyName.
*/
public function getCompanyName(): ?string
{
return $this->company_name;
}
/**
* Set email.
*/
public function setEmail(?string $email = null): Order
{
$this->email = $email;
return $this;
}
/**
* Get email.
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* Set phone_number.
*/
public function setPhoneNumber(?string $phone_number = null): Order
{
$this->phone_number = $phone_number;
return $this;
}
/**
* Get phone_number.
*/
public function getPhoneNumber(): ?string
{
return $this->phone_number;
}
/**
* Set postal_code.
*/
public function setPostalCode(?string $postal_code = null): Order
{
$this->postal_code = $postal_code;
return $this;
}
/**
* Get postal_code.
*/
public function getPostalCode(): ?string
{
return $this->postal_code;
}
/**
* Set addr01.
*/
public function setAddr01(?string $addr01 = null): Order
{
$this->addr01 = $addr01;
return $this;
}
/**
* Get addr01.
*/
public function getAddr01(): ?string
{
return $this->addr01;
}
/**
* Set addr02.
*/
public function setAddr02(?string $addr02 = null): Order
{
$this->addr02 = $addr02;
return $this;
}
/**
* Get addr02.
*/
public function getAddr02(): ?string
{
return $this->addr02;
}
/**
* Set birth.
*/
public function setBirth(?\DateTime $birth = null): Order
{
$this->birth = $birth;
return $this;
}
/**
* Get birth.
*/
public function getBirth(): ?\DateTime
{
return $this->birth;
}
/**
* Set subtotal.
*/
public function setSubtotal(string $subtotal): Order
{
$this->subtotal = $subtotal;
return $this;
}
/**
* Get subtotal.
*/
public function getSubtotal(): string
{
return $this->subtotal;
}
/**
* Set discount.
*
* @param string $discount
*/
#[\Override]
public function setDiscount($discount): static
{
$this->discount = $discount;
return $this;
}
/**
* Get discount.
*
* @deprecated 4.0.3 から値引きは課税値引きと 非課税・不課税の値引きの2種に分かれる. 課税値引きについてはgetTaxableDiscountを利用してください.
*/
public function getDiscount(): string
{
return $this->discount;
}
/**
* Set deliveryFeeTotal.
*
* @param string $deliveryFeeTotal
*
* @return $this
*/
#[\Override]
public function setDeliveryFeeTotal($deliveryFeeTotal): static
{
$this->delivery_fee_total = $deliveryFeeTotal;
return $this;
}
/**
* Get deliveryFeeTotal.
*/
#[\Override]
public function getDeliveryFeeTotal(): string
{
return $this->delivery_fee_total;
}
/**
* Set charge.
*
* @param string $charge
*
* @return $this
*/
#[\Override]
public function setCharge($charge): static
{
$this->charge = $charge;
return $this;
}
/**
* Get charge.
*/
public function getCharge(): string
{
return $this->charge;
}
/**
* Set tax.
*
* @param string $tax
*
* @return $this
*
* @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
*/
#[\Override]
public function setTax($tax): static
{
$this->tax = $tax;
return $this;
}
/**
* Get tax.
*
* @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
*/
public function getTax(): string
{
return $this->tax;
}
/**
* Set total.
*
* @param string $total
*/
#[\Override]
public function setTotal($total): static
{
$this->total = $total;
return $this;
}