Failed Conditions
Push — 4.0 ( f3e983...d5d6e1 )
by Ryo
22s queued 10s
created

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