Failed Conditions
Push — sf/last-boss ( 53d963...58156b )
by Kiyotaka
09:54 queued 04:25
created

OrderItem::setClassCategoryName1()   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) 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\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 int|null
212
         *
213
         * @ORM\Column(name="tax_rule_id", type="smallint", nullable=true, options={"unsigned":true})
214
         */
215
        private $tax_rule_id;
216
217
        /**
218
         * @var string|null
219
         *
220
         * @ORM\Column(name="currency_code", type="string", nullable=true)
221
         */
222
        private $currency_code;
223
224
        /**
225
         * @var string|null
226
         *
227
         * @ORM\Column(name="processor_name", type="string", nullable=true)
228
         */
229
        private $processor_name;
230
231
        /**
232
         * @var \Eccube\Entity\Order
233
         *
234
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Order", inversedBy="OrderItems")
235
         * @ORM\JoinColumns({
236
         *   @ORM\JoinColumn(name="order_id", referencedColumnName="id")
237
         * })
238
         */
239
        private $Order;
240
241
        /**
242
         * @var \Eccube\Entity\Product
243
         *
244
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Product")
245
         * @ORM\JoinColumns({
246
         *   @ORM\JoinColumn(name="product_id", referencedColumnName="id")
247
         * })
248
         */
249
        private $Product;
250
251
        /**
252
         * @var \Eccube\Entity\ProductClass
253
         *
254
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\ProductClass")
255
         * @ORM\JoinColumns({
256
         *   @ORM\JoinColumn(name="product_class_id", referencedColumnName="id")
257
         * })
258
         */
259
        private $ProductClass;
260
261
        /**
262
         * @var \Eccube\Entity\Shipping
263
         *
264
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Shipping", inversedBy="OrderItems")
265
         * @ORM\JoinColumns({
266
         *   @ORM\JoinColumn(name="shipping_id", referencedColumnName="id")
267
         * })
268
         */
269
        private $Shipping;
270
271
        /**
272
         * @var \Eccube\Entity\Master\RoundingType
273
         *
274
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\RoundingType")
275
         * @ORM\JoinColumns({
276
         *   @ORM\JoinColumn(name="rounding_type_id", referencedColumnName="id")
277
         * })
278
         */
279
        private $RoundingType;
280
281
        /**
282
         * @var \Eccube\Entity\Master\TaxType
283
         *
284
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxType")
285
         * @ORM\JoinColumns({
286
         *   @ORM\JoinColumn(name="tax_type_id", referencedColumnName="id")
287
         * })
288
         */
289
        private $TaxType;
290
291
        /**
292
         * @var \Eccube\Entity\Master\TaxDisplayType
293
         *
294
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxDisplayType")
295
         * @ORM\JoinColumns({
296
         *   @ORM\JoinColumn(name="tax_display_type_id", referencedColumnName="id")
297
         * })
298
         */
299
        private $TaxDisplayType;
300
301
        /**
302
         * @var \Eccube\Entity\Master\OrderItemType
303
         *
304
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderItemType")
305
         * @ORM\JoinColumns({
306
         *   @ORM\JoinColumn(name="order_item_type_id", referencedColumnName="id")
307
         * })
308
         */
309
        private $OrderItemType;
310
311
        /**
312
         * Get id.
313
         *
314
         * @return int
315
         */
316
        public function getId()
317
        {
318
            return $this->id;
319
        }
320
321
        /**
322
         * Set productName.
323
         *
324
         * @param string $productName
325
         *
326
         * @return OrderItem
327
         */
328
        public function setProductName($productName)
329
        {
330
            $this->product_name = $productName;
331
332
            return $this;
333
        }
334
335
        /**
336
         * Get productName.
337
         *
338
         * @return string
339
         */
340
        public function getProductName()
341
        {
342
            return $this->product_name;
343
        }
344
345
        /**
346
         * Set productCode.
347
         *
348
         * @param string|null $productCode
349
         *
350
         * @return OrderItem
351
         */
352
        public function setProductCode($productCode = null)
353
        {
354
            $this->product_code = $productCode;
355
356
            return $this;
357
        }
358
359
        /**
360
         * Get productCode.
361
         *
362
         * @return string|null
363
         */
364
        public function getProductCode()
365
        {
366
            return $this->product_code;
367
        }
368
369
        /**
370
         * Set className1.
371
         *
372
         * @param string|null $className1
373
         *
374
         * @return OrderItem
375
         */
376
        public function setClassName1($className1 = null)
377
        {
378
            $this->class_name1 = $className1;
379
380
            return $this;
381
        }
382
383
        /**
384
         * Get className1.
385
         *
386
         * @return string|null
387
         */
388
        public function getClassName1()
389
        {
390
            return $this->class_name1;
391
        }
392
393
        /**
394
         * Set className2.
395
         *
396
         * @param string|null $className2
397
         *
398
         * @return OrderItem
399
         */
400
        public function setClassName2($className2 = null)
401
        {
402
            $this->class_name2 = $className2;
403
404
            return $this;
405
        }
406
407
        /**
408
         * Get className2.
409
         *
410
         * @return string|null
411
         */
412
        public function getClassName2()
413
        {
414
            return $this->class_name2;
415
        }
416
417
        /**
418
         * Set classCategoryName1.
419
         *
420
         * @param string|null $classCategoryName1
421
         *
422
         * @return OrderItem
423
         */
424
        public function setClassCategoryName1($classCategoryName1 = null)
425
        {
426
            $this->class_category_name1 = $classCategoryName1;
427
428
            return $this;
429
        }
430
431
        /**
432
         * Get classCategoryName1.
433
         *
434
         * @return string|null
435
         */
436
        public function getClassCategoryName1()
437
        {
438
            return $this->class_category_name1;
439
        }
440
441
        /**
442
         * Set classCategoryName2.
443
         *
444
         * @param string|null $classCategoryName2
445
         *
446
         * @return OrderItem
447
         */
448
        public function setClassCategoryName2($classCategoryName2 = null)
449
        {
450
            $this->class_category_name2 = $classCategoryName2;
451
452
            return $this;
453
        }
454
455
        /**
456
         * Get classCategoryName2.
457
         *
458
         * @return string|null
459
         */
460
        public function getClassCategoryName2()
461
        {
462
            return $this->class_category_name2;
463
        }
464
465
        /**
466
         * Set price.
467
         *
468
         * @param string $price
469
         *
470
         * @return OrderItem
471
         */
472
        public function setPrice($price)
473
        {
474
            $this->price = $price;
475
476
            return $this;
477
        }
478
479
        /**
480
         * Get price.
481
         *
482
         * @return string
483
         */
484
        public function getPrice()
485
        {
486
            return $this->price;
487
        }
488
489
        /**
490
         * Set quantity.
491
         *
492
         * @param string $quantity
493
         *
494
         * @return OrderItem
495
         */
496
        public function setQuantity($quantity)
497
        {
498
            $this->quantity = $quantity;
499
500
            return $this;
501
        }
502
503
        /**
504
         * Get quantity.
505
         *
506
         * @return string
507
         */
508
        public function getQuantity()
509
        {
510
            return $this->quantity;
511
        }
512
513
        /**
514
         * @return string
515
         */
516
        public function getTax()
517
        {
518
            return $this->tax;
519
        }
520
521
        /**
522
         * @param string $tax
523
         *
524
         * @return $this
525
         */
526
        public function setTax($tax)
527
        {
528
            $this->tax = $tax;
529
530
            return $this;
531
        }
532
533
        /**
534
         * Set taxRate.
535
         *
536
         * @param string $taxRate
537
         *
538
         * @return OrderItem
539
         */
540
        public function setTaxRate($taxRate)
541
        {
542
            $this->tax_rate = $taxRate;
543
544
            return $this;
545
        }
546
547
        /**
548
         * Get taxRate.
549
         *
550
         * @return string
551
         */
552
        public function getTaxRate()
553
        {
554
            return $this->tax_rate;
555
        }
556
557
        /**
558
         * Set taxRuleId.
559
         *
560
         * @param int|null $taxRuleId
561
         *
562
         * @return OrderItem
563
         */
564
        public function setTaxRuleId($taxRuleId = null)
565
        {
566
            $this->tax_rule_id = $taxRuleId;
567
568
            return $this;
569
        }
570
571
        /**
572
         * Get taxRuleId.
573
         *
574
         * @return int|null
575
         */
576
        public function getTaxRuleId()
577
        {
578
            return $this->tax_rule_id;
579
        }
580
581
        /**
582
         * Get currencyCode.
583
         *
584
         * @return string
585
         */
586
        public function getCurrencyCode()
587
        {
588
            return $this->currency_code;
589
        }
590
591
        /**
592
         * Set currencyCode.
593
         *
594
         * @param string|null $currencyCode
595
         *
596
         * @return OrderItem
597
         */
598
        public function setCurrencyCode($currencyCode = null)
599
        {
600
            $this->currency_code = $currencyCode;
601
602
            return $this;
603
        }
604
605
        /**
606
         * Get processorName.
607
         *
608
         * @return string
609
         */
610
        public function getProcessorName()
611
        {
612
            return $this->processor_name;
613
        }
614
615
        /**
616
         * Set processorName.
617
         *
618
         * @param string|null $processorName
619
         *
620
         * @return $this
621
         */
622
        public function setProcessorName($processorName = null)
623
        {
624
            $this->processor_name = $processorName;
625
626
            return $this;
627
        }
628
629
        /**
630
         * Set order.
631
         *
632
         * @param \Eccube\Entity\Order|null $order
633
         *
634
         * @return OrderItem
635
         */
636
        public function setOrder(\Eccube\Entity\Order $order = null)
637
        {
638
            $this->Order = $order;
639
640
            return $this;
641
        }
642
643
        /**
644
         * Get order.
645
         *
646
         * @return \Eccube\Entity\Order|null
647
         */
648
        public function getOrder()
649
        {
650
            return $this->Order;
651
        }
652
653
        public function getOrderId()
654
        {
655
            if (is_object($this->getOrder())) {
656
                return $this->getOrder()->getId();
657
            }
658
659
            return null;
660
        }
661
662
        /**
663
         * Set product.
664
         *
665
         * @param \Eccube\Entity\Product|null $product
666
         *
667
         * @return OrderItem
668
         */
669
        public function setProduct(\Eccube\Entity\Product $product = null)
670
        {
671
            $this->Product = $product;
672
673
            return $this;
674
        }
675
676
        /**
677
         * Get product.
678
         *
679
         * @return \Eccube\Entity\Product|null
680
         */
681
        public function getProduct()
682
        {
683
            return $this->Product;
684
        }
685
686
        /**
687
         * Set productClass.
688
         *
689
         * @param \Eccube\Entity\ProductClass|null $productClass
690
         *
691
         * @return OrderItem
692
         */
693
        public function setProductClass(\Eccube\Entity\ProductClass $productClass = null)
694
        {
695
            $this->ProductClass = $productClass;
696
697
            return $this;
698
        }
699
700
        /**
701
         * Get productClass.
702
         *
703
         * @return \Eccube\Entity\ProductClass|null
704
         */
705
        public function getProductClass()
706
        {
707
            return $this->ProductClass;
708
        }
709
710
        /**
711
         * Set shipping.
712
         *
713
         * @param \Eccube\Entity\Shipping|null $shipping
714
         *
715
         * @return OrderItem
716
         */
717
        public function setShipping(\Eccube\Entity\Shipping $shipping = null)
718
        {
719
            $this->Shipping = $shipping;
720
721
            return $this;
722
        }
723
724
        /**
725
         * Get shipping.
726
         *
727
         * @return \Eccube\Entity\Shipping|null
728
         */
729
        public function getShipping()
730
        {
731
            return $this->Shipping;
732
        }
733
734
        /**
735
         * @return RoundingType
736
         */
737
        public function getRoundingType()
738
        {
739
            return $this->RoundingType;
740
        }
741
742
        /**
743
         * @param RoundingType $RoundingType
744
         */
745
        public function setRoundingType(RoundingType $RoundingType = null)
746
        {
747
            $this->RoundingType = $RoundingType;
748
749
            return $this;
750
        }
751
752
        /**
753
         * Set taxType
754
         *
755
         * @param \Eccube\Entity\Master\TaxType $taxType
756
         *
757
         * @return OrderItem
758
         */
759
        public function setTaxType(\Eccube\Entity\Master\TaxType $taxType = null)
760
        {
761
            $this->TaxType = $taxType;
762
763
            return $this;
764
        }
765
766
        /**
767
         * Get taxType
768
         *
769
         * @return \Eccube\Entity\Master\TaxType
770
         */
771
        public function getTaxType()
772
        {
773
            return $this->TaxType;
774
        }
775
776
        /**
777
         * Set taxDisplayType
778
         *
779
         * @param \Eccube\Entity\Master\TaxDisplayType $taxDisplayType
780
         *
781
         * @return OrderItem
782
         */
783
        public function setTaxDisplayType(\Eccube\Entity\Master\TaxDisplayType $taxDisplayType = null)
784
        {
785
            $this->TaxDisplayType = $taxDisplayType;
786
787
            return $this;
788
        }
789
790
        /**
791
         * Get taxDisplayType
792
         *
793
         * @return \Eccube\Entity\Master\TaxDisplayType
794
         */
795
        public function getTaxDisplayType()
796
        {
797
            return $this->TaxDisplayType;
798
        }
799
800
        /**
801
         * Set orderItemType
802
         *
803
         * @param \Eccube\Entity\Master\OrderItemType $orderItemType
804
         *
805
         * @return OrderItem
806
         */
807
        public function setOrderItemType(\Eccube\Entity\Master\OrderItemType $orderItemType = null)
808
        {
809
            $this->OrderItemType = $orderItemType;
810
811
            return $this;
812
        }
813
814
        /**
815
         * Get orderItemType
816
         *
817
         * @return \Eccube\Entity\Master\OrderItemType
818
         */
819
        public function getOrderItemType()
820
        {
821
            return $this->OrderItemType;
822
        }
823
    }
824
}
825