Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
144:19 queued 116:23
created

OrderItem::getClassCategoryName1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Entity;
15
16
use Doctrine\ORM\Mapping as ORM;
17
use Eccube\Entity\Master\OrderItemType;
18
use Eccube\Entity\Master\RoundingType;
19
use Eccube\Entity\Master\TaxDisplayType;
20
use Eccube\Entity\Master\TaxType;
21
22
/**
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 273
    public function getPriceIncTax()
41
    {
42
        // 税表示区分が税込の場合は, priceに税込金額が入っている.
43 273
        if ($this->TaxDisplayType && $this->TaxDisplayType->getId() == TaxDisplayType::INCLUDED) {
44 219
            return $this->price;
45
        }
46
47 273
        return $this->price + $this->tax;
48
    }
49
50
    /**
51
     * @return integer
52
     */
53 67
    public function getTotalPrice()
54
    {
55 67
        return $this->getPriceIncTax() * $this->getQuantity();
56
    }
57
58
    /**
59
     * @return integer
60
     */
61 280
    public function getOrderItemTypeId()
62
    {
63 280
        if (is_object($this->getOrderItemType())) {
64 239
            return $this->getOrderItemType()->getId();
65
        }
66
67 58
        return null;
68
    }
69
70
    /**
71
     * 商品明細かどうか.
72
     *
73
     * @return boolean 商品明細の場合 true
74
     */
75 279
    public function isProduct()
76
    {
77 279
        return $this->getOrderItemTypeId() === OrderItemType::PRODUCT;
78
    }
79
80
    /**
81
     * 送料明細かどうか.
82
     *
83
     * @return boolean 送料明細の場合 true
84
     */
85 268
    public function isDeliveryFee()
86
    {
87 268
        return $this->getOrderItemTypeId() === OrderItemType::DELIVERY_FEE;
88
    }
89
90
    /**
91
     * 手数料明細かどうか.
92
     *
93
     * @return boolean 手数料明細の場合 true
94
     */
95 262
    public function isCharge()
96
    {
97 262
        return $this->getOrderItemTypeId() === OrderItemType::CHARGE;
98
    }
99
100
    /**
101
     * 値引き明細かどうか.
102
     *
103
     * @return boolean 値引き明細の場合 true
104
     */
105 262
    public function isDiscount()
106
    {
107 262
        return $this->getOrderItemTypeId() === OrderItemType::DISCOUNT;
108
    }
109
110
    /**
111
     * 税額明細かどうか.
112
     *
113
     * @return boolean 税額明細の場合 true
114
     */
115 20
    public function isTax()
116
    {
117 20
        return $this->getOrderItemTypeId() === OrderItemType::TAX;
118
    }
119
120
    /**
121
     * ポイント明細かどうか.
122
     *
123
     * @return boolean ポイント明細の場合 true
124
     */
125 263
    public function isPoint()
126
    {
127 263
        return $this->getOrderItemTypeId() === OrderItemType::POINT;
128
    }
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 int|null
211
     *
212
     * @ORM\Column(name="tax_rule_id", type="smallint", nullable=true, options={"unsigned":true})
213
     */
214
    private $tax_rule_id;
215
216
    /**
217
     * @var string|null
218
     *
219
     * @ORM\Column(name="currency_code", type="string", nullable=true)
220
     */
221
    private $currency_code;
222
223
    /**
224
     * @var \Eccube\Entity\Order
225
     *
226
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Order", inversedBy="OrderItems")
227
     * @ORM\JoinColumns({
228
     *   @ORM\JoinColumn(name="order_id", referencedColumnName="id")
229
     * })
230
     */
231
    private $Order;
232
233
    /**
234
     * @var \Eccube\Entity\Product
235
     *
236
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Product")
237
     * @ORM\JoinColumns({
238
     *   @ORM\JoinColumn(name="product_id", referencedColumnName="id")
239
     * })
240
     */
241
    private $Product;
242
243
    /**
244
     * @var \Eccube\Entity\ProductClass
245
     *
246
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\ProductClass")
247
     * @ORM\JoinColumns({
248
     *   @ORM\JoinColumn(name="product_class_id", referencedColumnName="id")
249
     * })
250
     */
251
    private $ProductClass;
252
253
    /**
254
     * @var \Eccube\Entity\Shipping
255
     *
256
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Shipping", inversedBy="OrderItems")
257
     * @ORM\JoinColumns({
258
     *   @ORM\JoinColumn(name="shipping_id", referencedColumnName="id")
259
     * })
260
     */
261
    private $Shipping;
262
263
    /**
264
     * @var \Eccube\Entity\Master\RoundingType
265
     *
266
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\RoundingType")
267
     * @ORM\JoinColumns({
268
     *   @ORM\JoinColumn(name="rounding_type_id", referencedColumnName="id")
269
     * })
270
     */
271
    private $RoundingType;
272
273
    /**
274
     * @var \Eccube\Entity\Master\TaxType
275
     *
276
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxType")
277
     * @ORM\JoinColumns({
278
     *   @ORM\JoinColumn(name="tax_type_id", referencedColumnName="id")
279
     * })
280
     */
281
    private $TaxType;
282
283
    /**
284
     * @var \Eccube\Entity\Master\TaxDisplayType
285
     *
286
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\TaxDisplayType")
287
     * @ORM\JoinColumns({
288
     *   @ORM\JoinColumn(name="tax_display_type_id", referencedColumnName="id")
289
     * })
290
     */
291
    private $TaxDisplayType;
292
293
    /**
294
     * @var \Eccube\Entity\Master\OrderItemType
295
     *
296
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderItemType")
297
     * @ORM\JoinColumns({
298
     *   @ORM\JoinColumn(name="order_item_type_id", referencedColumnName="id")
299
     * })
300
     */
301
    private $OrderItemType;
302
303
    /**
304
     * Get id.
305
     *
306
     * @return int
307
     */
308 46
    public function getId()
309
    {
310 46
        return $this->id;
311
    }
312
313
    /**
314
     * Set productName.
315
     *
316
     * @param string $productName
317
     *
318
     * @return OrderItem
319
     */
320 233
    public function setProductName($productName)
321
    {
322 233
        $this->product_name = $productName;
323
324 233
        return $this;
325
    }
326
327
    /**
328
     * Get productName.
329
     *
330
     * @return string
331
     */
332 79
    public function getProductName()
333
    {
334 79
        return $this->product_name;
335
    }
336
337
    /**
338
     * Set productCode.
339
     *
340
     * @param string|null $productCode
341
     *
342
     * @return OrderItem
343
     */
344 215
    public function setProductCode($productCode = null)
345
    {
346 215
        $this->product_code = $productCode;
347
348 215
        return $this;
349
    }
350
351
    /**
352
     * Get productCode.
353
     *
354
     * @return string|null
355
     */
356 37
    public function getProductCode()
357
    {
358 37
        return $this->product_code;
359
    }
360
361
    /**
362
     * Set className1.
363
     *
364
     * @param string|null $className1
365
     *
366
     * @return OrderItem
367
     */
368 215
    public function setClassName1($className1 = null)
369
    {
370 215
        $this->class_name1 = $className1;
371
372 215
        return $this;
373
    }
374
375
    /**
376
     * Get className1.
377
     *
378
     * @return string|null
379
     */
380 19
    public function getClassName1()
381
    {
382 19
        return $this->class_name1;
383
    }
384
385
    /**
386
     * Set className2.
387
     *
388
     * @param string|null $className2
389
     *
390
     * @return OrderItem
391
     */
392 152
    public function setClassName2($className2 = null)
393
    {
394 152
        $this->class_name2 = $className2;
395
396 152
        return $this;
397
    }
398
399
    /**
400
     * Get className2.
401
     *
402
     * @return string|null
403
     */
404 19
    public function getClassName2()
405
    {
406 19
        return $this->class_name2;
407
    }
408
409
    /**
410
     * Set classCategoryName1.
411
     *
412
     * @param string|null $classCategoryName1
413
     *
414
     * @return OrderItem
415
     */
416 215
    public function setClassCategoryName1($classCategoryName1 = null)
417
    {
418 215
        $this->class_category_name1 = $classCategoryName1;
419
420 215
        return $this;
421
    }
422
423
    /**
424
     * Get classCategoryName1.
425
     *
426
     * @return string|null
427
     */
428 23
    public function getClassCategoryName1()
429
    {
430 23
        return $this->class_category_name1;
431
    }
432
433
    /**
434
     * Set classCategoryName2.
435
     *
436
     * @param string|null $classCategoryName2
437
     *
438
     * @return OrderItem
439
     */
440 153
    public function setClassCategoryName2($classCategoryName2 = null)
441
    {
442 153
        $this->class_category_name2 = $classCategoryName2;
443
444 153
        return $this;
445
    }
446
447
    /**
448
     * Get classCategoryName2.
449
     *
450
     * @return string|null
451
     */
452 23
    public function getClassCategoryName2()
453
    {
454 23
        return $this->class_category_name2;
455
    }
456
457
    /**
458
     * Set price.
459
     *
460
     * @param string $price
461
     *
462
     * @return OrderItem
463
     */
464 282
    public function setPrice($price)
465
    {
466 282
        $this->price = $price;
467
468 282
        return $this;
469
    }
470
471
    /**
472
     * Get price.
473
     *
474
     * @return string
475
     */
476 233
    public function getPrice()
477
    {
478 233
        return $this->price;
479
    }
480
481
    /**
482
     * Set quantity.
483
     *
484
     * @param string $quantity
485
     *
486
     * @return OrderItem
487
     */
488 292
    public function setQuantity($quantity)
489
    {
490 292
        $this->quantity = $quantity;
491
492 292
        return $this;
493
    }
494
495
    /**
496
     * Get quantity.
497
     *
498
     * @return string
499
     */
500 289
    public function getQuantity()
501
    {
502 289
        return $this->quantity;
503
    }
504
505
    /**
506
     * @return string
507
     */
508 262
    public function getTax()
509
    {
510 262
        return $this->tax;
511
    }
512
513
    /**
514
     * @param string $tax
515
     *
516
     * @return $this
517
     */
518 222
    public function setTax($tax)
519
    {
520 222
        $this->tax = $tax;
521
522 222
        return $this;
523
    }
524
525
    /**
526
     * Set taxRate.
527
     *
528
     * @param string $taxRate
529
     *
530
     * @return OrderItem
531
     */
532 222
    public function setTaxRate($taxRate)
533
    {
534 222
        $this->tax_rate = $taxRate;
535
536 222
        return $this;
537
    }
538
539
    /**
540
     * Get taxRate.
541
     *
542
     * @return string
543
     */
544 4
    public function getTaxRate()
545
    {
546 4
        return $this->tax_rate;
547
    }
548
549
    /**
550
     * Set taxRuleId.
551
     *
552
     * @param int|null $taxRuleId
553
     *
554
     * @return OrderItem
555
     */
556 222
    public function setTaxRuleId($taxRuleId = null)
557
    {
558 222
        $this->tax_rule_id = $taxRuleId;
559
560 222
        return $this;
561
    }
562
563
    /**
564
     * Get taxRuleId.
565
     *
566
     * @return int|null
567
     */
568 205
    public function getTaxRuleId()
569
    {
570 205
        return $this->tax_rule_id;
571
    }
572
573
    /**
574
     * Get currencyCode.
575
     *
576
     * @return string
577
     */
578
    public function getCurrencyCode()
579
    {
580
        return $this->currency_code;
581
    }
582
583
    /**
584
     * Set currencyCode.
585
     *
586
     * @param string|null $currencyCode
587
     *
588
     * @return OrderItem
589
     */
590 205
    public function setCurrencyCode($currencyCode = null)
591
    {
592 205
        $this->currency_code = $currencyCode;
593
594 205
        return $this;
595
    }
596
597
    /**
598
     * Set order.
599
     *
600
     * @param \Eccube\Entity\Order|null $order
601
     *
602
     * @return OrderItem
603
     */
604 222
    public function setOrder(\Eccube\Entity\Order $order = null)
605
    {
606 222
        $this->Order = $order;
607
608 222
        return $this;
609
    }
610
611
    /**
612
     * Get order.
613
     *
614
     * @return \Eccube\Entity\Order|null
615
     */
616 30
    public function getOrder()
617
    {
618 30
        return $this->Order;
619
    }
620
621 4
    public function getOrderId()
622
    {
623 4
        if (is_object($this->getOrder())) {
624 4
            return $this->getOrder()->getId();
625
        }
626
627
        return null;
628
    }
629
630
    /**
631
     * Set product.
632
     *
633
     * @param \Eccube\Entity\Product|null $product
634
     *
635
     * @return OrderItem
636
     */
637 215
    public function setProduct(\Eccube\Entity\Product $product = null)
638
    {
639 215
        $this->Product = $product;
640
641 215
        return $this;
642
    }
643
644
    /**
645
     * Get product.
646
     *
647
     * @return \Eccube\Entity\Product|null
648
     */
649 205
    public function getProduct()
650
    {
651 205
        return $this->Product;
652
    }
653
654
    /**
655
     * Set productClass.
656
     *
657
     * @param \Eccube\Entity\ProductClass|null $productClass
658
     *
659
     * @return OrderItem
660
     */
661 280
    public function setProductClass(\Eccube\Entity\ProductClass $productClass = null)
662
    {
663 280
        $this->ProductClass = $productClass;
664
665 280
        return $this;
666
    }
667
668
    /**
669
     * Get productClass.
670
     *
671
     * @return \Eccube\Entity\ProductClass|null
672
     */
673 225
    public function getProductClass()
674
    {
675 225
        return $this->ProductClass;
676
    }
677
678
    /**
679
     * Set shipping.
680
     *
681
     * @param \Eccube\Entity\Shipping|null $shipping
682
     *
683
     * @return OrderItem
684
     */
685 216
    public function setShipping(\Eccube\Entity\Shipping $shipping = null)
686
    {
687 216
        $this->Shipping = $shipping;
688
689 216
        return $this;
690
    }
691
692
    /**
693
     * Get shipping.
694
     *
695
     * @return \Eccube\Entity\Shipping|null
696
     */
697 64
    public function getShipping()
698
    {
699 64
        return $this->Shipping;
700
    }
701
702
    /**
703
     * @return RoundingType
704
     */
705
    public function getRoundingType()
706
    {
707
        return $this->RoundingType;
708
    }
709
710
    /**
711
     * @param RoundingType $RoundingType
712
     */
713 222
    public function setRoundingType(RoundingType $RoundingType = null)
714
    {
715 222
        $this->RoundingType = $RoundingType;
716
717 222
        return $this;
718
    }
719
720
    /**
721
     * Set taxType
722
     *
723
     * @param \Eccube\Entity\Master\TaxType $taxType
724
     *
725
     * @return OrderItem
726
     */
727 222
    public function setTaxType(\Eccube\Entity\Master\TaxType $taxType = null)
728
    {
729 222
        $this->TaxType = $taxType;
730
731 222
        return $this;
732
    }
733
734
    /**
735
     * Get taxType
736
     *
737
     * @return \Eccube\Entity\Master\TaxType
738
     */
739 205
    public function getTaxType()
740
    {
741 205
        return $this->TaxType;
742
    }
743
744
    /**
745
     * Set taxDisplayType
746
     *
747
     * @param \Eccube\Entity\Master\TaxDisplayType $taxDisplayType
748
     *
749
     * @return OrderItem
750
     */
751 222
    public function setTaxDisplayType(\Eccube\Entity\Master\TaxDisplayType $taxDisplayType = null)
752
    {
753 222
        $this->TaxDisplayType = $taxDisplayType;
754
755 222
        return $this;
756
    }
757
758
    /**
759
     * Get taxDisplayType
760
     *
761
     * @return \Eccube\Entity\Master\TaxDisplayType
762
     */
763 205
    public function getTaxDisplayType()
764
    {
765 205
        return $this->TaxDisplayType;
766
    }
767
768
    /**
769
     * Set orderItemType
770
     *
771
     * @param \Eccube\Entity\Master\OrderItemType $orderItemType
772
     *
773
     * @return OrderItem
774
     */
775 253
    public function setOrderItemType(\Eccube\Entity\Master\OrderItemType $orderItemType = null)
776
    {
777 253
        $this->OrderItemType = $orderItemType;
778
779 253
        return $this;
780
    }
781
782
    /**
783
     * Get orderItemType
784
     *
785
     * @return \Eccube\Entity\Master\OrderItemType
786
     */
787 291
    public function getOrderItemType()
788
    {
789 291
        return $this->OrderItemType;
790
    }
791
}
792