Code Duplication    Length = 30-30 lines in 2 locations

src/Eccube/Controller/Admin/AdminController.php 2 locations

@@ 429-458 (lines=30) @@
426
     * @return array|mixed
427
     * @throws \Doctrine\ORM\NonUniqueResultException
428
     */
429
    private function getSalesByDay($dateTime)
430
    {
431
        // concat... for pgsql
432
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
433
        $dql = 'SELECT
434
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) AS order_day,
435
                  SUM(o.payment_total) AS order_amount,
436
                  COUNT(o) AS order_count
437
                FROM
438
                  Eccube\Entity\Order o
439
                WHERE
440
                    o.OrderStatus NOT IN (:excludes)
441
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) = SUBSTRING(:targetDate, 1, 10)
442
                GROUP BY
443
                  order_day';
444
445
        $q = $this->entityManager
446
            ->createQuery($dql)
447
            ->setParameter(':excludes', $this->excludes)
448
            ->setParameter(':targetDate', $dateTime);
449
450
        $result = [];
451
        try {
452
            $result = $q->getSingleResult();
453
        } catch (NoResultException $e) {
454
            // 結果がない場合は空の配列を返す.
455
        }
456
457
        return $result;
458
    }
459
460
    /**
461
     * @param $dateTime
@@ 465-494 (lines=30) @@
462
     * @return array|mixed
463
     * @throws \Doctrine\ORM\NonUniqueResultException
464
     */
465
    private function getSalesByMonth($dateTime)
466
    {
467
        // concat... for pgsql
468
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
469
        $dql = 'SELECT
470
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) AS order_month,
471
                  SUM(o.payment_total) AS order_amount,
472
                  COUNT(o) AS order_count
473
                FROM
474
                  Eccube\Entity\Order o
475
                WHERE
476
                    o.OrderStatus NOT IN (:excludes)
477
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) = SUBSTRING(:targetDate, 1, 7)
478
                GROUP BY
479
                  order_month';
480
481
        $q = $this->entityManager
482
            ->createQuery($dql)
483
            ->setParameter(':excludes', $this->excludes)
484
            ->setParameter(':targetDate', $dateTime);
485
486
        $result = [];
487
        try {
488
            $result = $q->getSingleResult();
489
        } catch (NoResultException $e) {
490
            // 結果がない場合は空の配列を返す.
491
        }
492
493
        return $result;
494
    }
495
496
    /**
497
     * 在庫切れ商品数を取得