Completed
Push — dev/4269 ( 0f73fd )
by Kiyotaka
04:20
created

OrderItem::setProduct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
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\ORM\Mapping as ORM;
17
use Eccube\Entity\Master\OrderItemType;
18
use Eccube\Entity\Master\RoundingType;
19
use Eccube\Entity\Master\TaxDisplayType;
20
use Eccube\Entity\Master\TaxType;
21
22
if (!class_exists('\Eccube\Entity\OrderItem')) {
23
    /**
24
     * OrderItem
25
     *
26
     * @ORM\Table(name="dtb_order_item")
27
     * @ORM\InheritanceType("SINGLE_TABLE")
28
     * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
29
     * @ORM\HasLifecycleCallbacks()
30
     * @ORM\Entity(repositoryClass="Eccube\Repository\OrderItemRepository")
31
     */
32
    class OrderItem extends \Eccube\Entity\AbstractEntity implements ItemInterface
33
    {
34
        use PointRateTrait;
35
36
        /**
37
         * Get price IncTax
38
         *
39
         * @return string
40
         */
41
        public function getPriceIncTax()
42
        {
43
            // 税表示区分が税込の場合は, priceに税込金額が入っている.
44
            if ($this->TaxDisplayType && $this->TaxDisplayType->getId() == TaxDisplayType::INCLUDED) {
45
                return $this->price;
46
            }
47
48
            return $this->price + $this->tax;
49
        }
50
51
        /**
52
         * @return integer
53
         */
54
        public function getTotalPrice()
55
        {
56
            return $this->getPriceIncTax() * $this->getQuantity();
57
        }
58
59
        /**
60
         * @return integer
61
         */
62
        public function getOrderItemTypeId()
63
        {
64
            if (is_object($this->getOrderItemType())) {
65
                return $this->getOrderItemType()->getId();
66
            }
67
68
            return null;
69
        }
70
71
        /**
72
         * 商品明細かどうか.
73
         *
74
         * @return boolean 商品明細の場合 true
75
         */
76
        public function isProduct()
77
        {
78
            return $this->getOrderItemTypeId() === OrderItemType::PRODUCT;
79
        }
80
81
        /**
82
         * 送料明細かどうか.
83
         *
84
         * @return boolean 送料明細の場合 true
85
         */
86
        public function isDeliveryFee()
87
        {
88
            return $this->getOrderItemTypeId() === OrderItemType::DELIVERY_FEE;
89
        }
90
91
        /**
92
         * 手数料明細かどうか.
93
         *
94
         * @return boolean 手数料明細の場合 true
95
         */
96
        public function isCharge()
97
        {
98
            return $this->getOrderItemTypeId() === OrderItemType::CHARGE;
99
        }
100
101
        /**
102
         * 値引き明細かどうか.
103
         *
104
         * @return boolean 値引き明細の場合 true
105
         */
106
        public function isDiscount()
107
        {
108
            return $this->getOrderItemTypeId() === OrderItemType::DISCOUNT;
109
        }
110
111
        /**
112
         * 税額明細かどうか.
113
         *
114
         * @return boolean 税額明細の場合 true
115
         */
116
        public function isTax()
117
        {
118
            return $this->getOrderItemTypeId() === OrderItemType::TAX;
119
        }
120
121
        /**
122
         * ポイント明細かどうか.
123
         *
124
         * @return boolean ポイント明細の場合 true
125
         */
126
        public function isPoint()
127
        {
128
            return $this->getOrderItemTypeId() === OrderItemType::POINT;
129
        }
130
131
        /**
132
         * @var integer
133
         *
134
         * @ORM\Column(name="id", type="integer", options={"unsigned":true})
135
         * @ORM\Id
136
         * @ORM\GeneratedValue(strategy="IDENTITY")
137
         */
138
        private $id;
139
140
        /**
141
         * @var string
142
         *
143
         * @ORM\Column(name="product_name", type="string", length=255)
144
         */
145
        private $product_name;
146
147
        /**
148
         * @var string|null
149
         *
150
         * @ORM\Column(name="product_code", type="string", length=255, nullable=true)
151
         */
152
        private $product_code;
153
154
        /**
155
         * @var string|null
156
         *
157
         * @ORM\Column(name="class_name1", type="string", length=255, nullable=true)
158
         */
159
        private $class_name1;
160
161
        /**
162
         * @var string|null
163
         *
164
         * @ORM\Column(name="class_name2", type="string", length=255, nullable=true)
165
         */
166
        private $class_name2;
167
168
        /**
169
         * @var string|null
170
         *
171
         * @ORM\Column(name="class_category_name1", type="string", length=255, nullable=true)
172
         */
173
        private $class_category_name1;
174
175
        /**
176
         * @var string|null
177
         *
178
         * @ORM\Column(name="class_category_name2", type="string", length=255, nullable=true)
179
         */
180
        private $class_category_name2;
181
182
        /**
183
         * @var string
184
         *
185
         * @ORM\Column(name="price", type="decimal", precision=12, scale=2, options={"default":0})
186
         */
187
        private $price = 0;
188
189
        /**
190
         * @var string
191
         *
192
         * @ORM\Column(name="quantity", type="decimal", precision=10, scale=0, options={"default":0})
193
         */
194
        private $quantity = 0;
195
196
        /**
197
         * @var string
198
         *
199
         * @ORM\Column(name="tax", type="decimal", precision=10, scale=0, options={"default":0})
200
         */
201
        private $tax = 0;
202
203
        /**
204
         * @var string
205
         *
206
         * @ORM\Column(name="tax_rate", type="decimal", precision=10, scale=0, options={"unsigned":true,"default":0})
207
         */
208
        private $tax_rate = 0;
209
210
        /**
211
         * @var string
212
         *
213
         * @ORM\Column(name="tax_adjust", type="decimal", precision=10, scale=0, options={"unsigned":true,"default":0})
214
         */
215
        private $tax_adjust = 0;
216
217
        /**
218
         * @var int|null
219
         * @deprecated 税率設定は受注作成時に決定するため廃止予定
220
         *
221
         * @ORM\Column(name="tax_rule_id", type="smallint", nullable=true, options={"unsigned":true})
222
         */
223
        private $tax_rule_id;
224
225
        /**
226
         * @var string|null
227
         *
228
         * @ORM\Column(name="currency_code", type="string", nullable=true)
229
         */
230
        private $currency_code;
231
232
        /**
233
         * @var string|null
234
         *
235
         * @ORM\Column(name="processor_name", type="string", nullable=true)
236
         */
237
        private $processor_name;
238
239
        /**
240
         * @var \Eccube\Entity\Order
241
         *
242
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Order", inversedBy="OrderItems")
243
         * @ORM\JoinColumns({
244
         *   @ORM\JoinColumn(name="order_id", referencedColumnName="id")
245
         * })
246
         */
247
        private $Order;
248
249
        /**
250
         * @var \Eccube\Entity\Product
251
         *
252
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Product")
253
         * @ORM\JoinColumns({
254
         *   @ORM\JoinColumn(name="product_id", referencedColumnName="id")
255
         * })
256
         */
257
        private $Product;
258
259
        /**
260
         * @var \Eccube\Entity\ProductClass
261
         *
262
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\ProductClass")
263
         * @ORM\JoinColumns({
264
         *   @ORM\JoinColumn(name="product_class_id", referencedColumnName="id")
265
         * })
266
         */
267
        private $ProductClass;
268
269
        /**
270
         * @var \Eccube\Entity\Shipping
271
         *
272
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Shipping", inversedBy="OrderItems")
273
         * @ORM\JoinColumns({
274
         *   @ORM\JoinColumn(name="shipping_id", referencedColumnName="id")
275
         * })
276
         */
277
        private $Shipping;
278
279
        /**
280
         * @var \Eccube\Entity\Master\RoundingType
281
         *
282
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\RoundingType")
283
         * @ORM\JoinColumns({
284
         *   @ORM\JoinColumn(name="rounding_type_id", referencedColumnName="id")
285
         * })
286
         */
287
        private $RoundingType;
288
289
        /**
290
         * @var \Eccube\Entity\Master\TaxType
291
         *
292
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxType")
293
         * @ORM\JoinColumns({
294
         *   @ORM\JoinColumn(name="tax_type_id", referencedColumnName="id")
295
         * })
296
         */
297
        private $TaxType;
298
299
        /**
300
         * @var \Eccube\Entity\Master\TaxDisplayType
301
         *
302
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxDisplayType")
303
         * @ORM\JoinColumns({
304
         *   @ORM\JoinColumn(name="tax_display_type_id", referencedColumnName="id")
305
         * })
306
         */
307
        private $TaxDisplayType;
308
309
        /**
310
         * @var \Eccube\Entity\Master\OrderItemType
311
         *
312
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderItemType")
313
         * @ORM\JoinColumns({
314
         *   @ORM\JoinColumn(name="order_item_type_id", referencedColumnName="id")
315
         * })
316
         */
317
        private $OrderItemType;
318
319
        /**
320
         * Get id.
321
         *
322
         * @return int
323
         */
324
        public function getId()
325
        {
326
            return $this->id;
327
        }
328
329
        /**
330
         * Set productName.
331
         *
332
         * @param string $productName
333
         *
334
         * @return OrderItem
335
         */
336
        public function setProductName($productName)
337
        {
338
            $this->product_name = $productName;
339
340
            return $this;
341
        }
342
343
        /**
344
         * Get productName.
345
         *
346
         * @return string
347
         */
348
        public function getProductName()
349
        {
350
            return $this->product_name;
351
        }
352
353
        /**
354
         * Set productCode.
355
         *
356
         * @param string|null $productCode
357
         *
358
         * @return OrderItem
359
         */
360
        public function setProductCode($productCode = null)
361
        {
362
            $this->product_code = $productCode;
363
364
            return $this;
365
        }
366
367
        /**
368
         * Get productCode.
369
         *
370
         * @return string|null
371
         */
372
        public function getProductCode()
373
        {
374
            return $this->product_code;
375
        }
376
377
        /**
378
         * Set className1.
379
         *
380
         * @param string|null $className1
381
         *
382
         * @return OrderItem
383
         */
384
        public function setClassName1($className1 = null)
385
        {
386
            $this->class_name1 = $className1;
387
388
            return $this;
389
        }
390
391
        /**
392
         * Get className1.
393
         *
394
         * @return string|null
395
         */
396
        public function getClassName1()
397
        {
398
            return $this->class_name1;
399
        }
400
401
        /**
402
         * Set className2.
403
         *
404
         * @param string|null $className2
405
         *
406
         * @return OrderItem
407
         */
408
        public function setClassName2($className2 = null)
409
        {
410
            $this->class_name2 = $className2;
411
412
            return $this;
413
        }
414
415
        /**
416
         * Get className2.
417
         *
418
         * @return string|null
419
         */
420
        public function getClassName2()
421
        {
422
            return $this->class_name2;
423
        }
424
425
        /**
426
         * Set classCategoryName1.
427
         *
428
         * @param string|null $classCategoryName1
429
         *
430
         * @return OrderItem
431
         */
432
        public function setClassCategoryName1($classCategoryName1 = null)
433
        {
434
            $this->class_category_name1 = $classCategoryName1;
435
436
            return $this;
437
        }
438
439
        /**
440
         * Get classCategoryName1.
441
         *
442
         * @return string|null
443
         */
444
        public function getClassCategoryName1()
445
        {
446
            return $this->class_category_name1;
447
        }
448
449
        /**
450
         * Set classCategoryName2.
451
         *
452
         * @param string|null $classCategoryName2
453
         *
454
         * @return OrderItem
455
         */
456
        public function setClassCategoryName2($classCategoryName2 = null)
457
        {
458
            $this->class_category_name2 = $classCategoryName2;
459
460
            return $this;
461
        }
462
463
        /**
464
         * Get classCategoryName2.
465
         *
466
         * @return string|null
467
         */
468
        public function getClassCategoryName2()
469
        {
470
            return $this->class_category_name2;
471
        }
472
473
        /**
474
         * Set price.
475
         *
476
         * @param string $price
477
         *
478
         * @return OrderItem
479
         */
480
        public function setPrice($price)
481
        {
482
            $this->price = $price;
483
484
            return $this;
485
        }
486
487
        /**
488
         * Get price.
489
         *
490
         * @return string
491
         */
492
        public function getPrice()
493
        {
494
            return $this->price;
495
        }
496
497
        /**
498
         * Set quantity.
499
         *
500
         * @param string $quantity
501
         *
502
         * @return OrderItem
503
         */
504
        public function setQuantity($quantity)
505
        {
506
            $this->quantity = $quantity;
507
508
            return $this;
509
        }
510
511
        /**
512
         * Get quantity.
513
         *
514
         * @return string
515
         */
516
        public function getQuantity()
517
        {
518
            return $this->quantity;
519
        }
520
521
        /**
522
         * @return string
523
         */
524
        public function getTax()
525
        {
526
            return $this->tax;
527
        }
528
529
        /**
530
         * @param string $tax
531
         *
532
         * @return $this
533
         */
534
        public function setTax($tax)
535
        {
536
            $this->tax = $tax;
537
538
            return $this;
539
        }
540
541
        /**
542
         * Set taxRate.
543
         *
544
         * @param string $taxRate
545
         *
546
         * @return OrderItem
547
         */
548
        public function setTaxRate($taxRate)
549
        {
550
            $this->tax_rate = $taxRate;
551
552
            return $this;
553
        }
554
555
        /**
556
         * Get taxRate.
557
         *
558
         * @return string
559
         */
560
        public function getTaxRate()
561
        {
562
            return $this->tax_rate;
563
        }
564
565
        /**
566
         * Set taxAdjust.
567
         *
568
         * @param string $tax_adjust
569
         *
570
         * @return OrderItem
571
         */
572
        public function setTaxAdjust($tax_adjust)
573
        {
574
            $this->tax_adjust = $tax_adjust;
575
576
            return $this;
577
        }
578
579
        /**
580
         * Get taxAdjust.
581
         *
582
         * @return string
583
         */
584
        public function getTaxAdjust()
585
        {
586
            return $this->tax_adjust;
587
        }
588
589
        /**
590
         * Set taxRuleId.
591
         * @deprecated 税率設定は受注作成時に決定するため廃止予定
592
         *
593
         * @param int|null $taxRuleId
594
         *
595
         * @return OrderItem
596
         */
597
        public function setTaxRuleId($taxRuleId = null)
598
        {
599
            $this->tax_rule_id = $taxRuleId;
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\OrderItem::$tax_rule_id 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...
600
601
            return $this;
602
        }
603
604
        /**
605
         * Get taxRuleId.
606
         * @deprecated 税率設定は受注作成時に決定するため廃止予定
607
         *
608
         * @return int|null
609
         */
610
        public function getTaxRuleId()
611
        {
612
            return $this->tax_rule_id;
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\OrderItem::$tax_rule_id 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...
613
        }
614
615
        /**
616
         * Get currencyCode.
617
         *
618
         * @return string
619
         */
620
        public function getCurrencyCode()
621
        {
622
            return $this->currency_code;
623
        }
624
625
        /**
626
         * Set currencyCode.
627
         *
628
         * @param string|null $currencyCode
629
         *
630
         * @return OrderItem
631
         */
632
        public function setCurrencyCode($currencyCode = null)
633
        {
634
            $this->currency_code = $currencyCode;
635
636
            return $this;
637
        }
638
639
        /**
640
         * Get processorName.
641
         *
642
         * @return string
643
         */
644
        public function getProcessorName()
645
        {
646
            return $this->processor_name;
647
        }
648
649
        /**
650
         * Set processorName.
651
         *
652
         * @param string|null $processorName
653
         *
654
         * @return $this
655
         */
656
        public function setProcessorName($processorName = null)
657
        {
658
            $this->processor_name = $processorName;
659
660
            return $this;
661
        }
662
663
        /**
664
         * Set order.
665
         *
666
         * @param \Eccube\Entity\Order|null $order
667
         *
668
         * @return OrderItem
669
         */
670
        public function setOrder(\Eccube\Entity\Order $order = null)
671
        {
672
            $this->Order = $order;
673
674
            return $this;
675
        }
676
677
        /**
678
         * Get order.
679
         *
680
         * @return \Eccube\Entity\Order|null
681
         */
682
        public function getOrder()
683
        {
684
            return $this->Order;
685
        }
686
687
        public function getOrderId()
688
        {
689
            if (is_object($this->getOrder())) {
690
                return $this->getOrder()->getId();
691
            }
692
693
            return null;
694
        }
695
696
        /**
697
         * Set product.
698
         *
699
         * @param \Eccube\Entity\Product|null $product
700
         *
701
         * @return OrderItem
702
         */
703
        public function setProduct(\Eccube\Entity\Product $product = null)
704
        {
705
            $this->Product = $product;
706
707
            return $this;
708
        }
709
710
        /**
711
         * Get product.
712
         *
713
         * @return \Eccube\Entity\Product|null
714
         */
715
        public function getProduct()
716
        {
717
            return $this->Product;
718
        }
719
720
        /**
721
         * Set productClass.
722
         *
723
         * @param \Eccube\Entity\ProductClass|null $productClass
724
         *
725
         * @return OrderItem
726
         */
727
        public function setProductClass(\Eccube\Entity\ProductClass $productClass = null)
728
        {
729
            $this->ProductClass = $productClass;
730
731
            return $this;
732
        }
733
734
        /**
735
         * Get productClass.
736
         *
737
         * @return \Eccube\Entity\ProductClass|null
738
         */
739
        public function getProductClass()
740
        {
741
            return $this->ProductClass;
742
        }
743
744
        /**
745
         * Set shipping.
746
         *
747
         * @param \Eccube\Entity\Shipping|null $shipping
748
         *
749
         * @return OrderItem
750
         */
751
        public function setShipping(\Eccube\Entity\Shipping $shipping = null)
752
        {
753
            $this->Shipping = $shipping;
754
755
            return $this;
756
        }
757
758
        /**
759
         * Get shipping.
760
         *
761
         * @return \Eccube\Entity\Shipping|null
762
         */
763
        public function getShipping()
764
        {
765
            return $this->Shipping;
766
        }
767
768
        /**
769
         * @return RoundingType
770
         */
771
        public function getRoundingType()
772
        {
773
            return $this->RoundingType;
774
        }
775
776
        /**
777
         * @param RoundingType $RoundingType
778
         */
779
        public function setRoundingType(RoundingType $RoundingType = null)
780
        {
781
            $this->RoundingType = $RoundingType;
782
783
            return $this;
784
        }
785
786
        /**
787
         * Set taxType
788
         *
789
         * @param \Eccube\Entity\Master\TaxType $taxType
790
         *
791
         * @return OrderItem
792
         */
793
        public function setTaxType(\Eccube\Entity\Master\TaxType $taxType = null)
794
        {
795
            $this->TaxType = $taxType;
796
797
            return $this;
798
        }
799
800
        /**
801
         * Get taxType
802
         *
803
         * @return \Eccube\Entity\Master\TaxType
804
         */
805
        public function getTaxType()
806
        {
807
            return $this->TaxType;
808
        }
809
810
        /**
811
         * Set taxDisplayType
812
         *
813
         * @param \Eccube\Entity\Master\TaxDisplayType $taxDisplayType
814
         *
815
         * @return OrderItem
816
         */
817
        public function setTaxDisplayType(\Eccube\Entity\Master\TaxDisplayType $taxDisplayType = null)
818
        {
819
            $this->TaxDisplayType = $taxDisplayType;
820
821
            return $this;
822
        }
823
824
        /**
825
         * Get taxDisplayType
826
         *
827
         * @return \Eccube\Entity\Master\TaxDisplayType
828
         */
829
        public function getTaxDisplayType()
830
        {
831
            return $this->TaxDisplayType;
832
        }
833
834
        /**
835
         * Set orderItemType
836
         *
837
         * @param \Eccube\Entity\Master\OrderItemType $orderItemType
838
         *
839
         * @return OrderItem
840
         */
841
        public function setOrderItemType(\Eccube\Entity\Master\OrderItemType $orderItemType = null)
842
        {
843
            $this->OrderItemType = $orderItemType;
844
845
            return $this;
846
        }
847
848
        /**
849
         * Get orderItemType
850
         *
851
         * @return \Eccube\Entity\Master\OrderItemType
852
         */
853
        public function getOrderItemType()
854
        {
855
            return $this->OrderItemType;
856
        }
857
    }
858
}
859