Code Duplication    Length = 30-30 lines in 2 locations

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

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