Code Duplication    Length = 30-30 lines in 2 locations

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

@@ 395-424 (lines=30) @@
392
        return $orderArray;
393
    }
394
395
    protected function getSalesByMonth($em, $dateTime, array $excludes)
396
    {
397
        // concat... for pgsql
398
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
399
        $dql = 'SELECT
400
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) AS order_month,
401
                  SUM(o.payment_total) AS order_amount,
402
                  COUNT(o) AS order_count
403
                FROM
404
                  Eccube\Entity\Order o
405
                WHERE
406
                    o.OrderStatus NOT IN (:excludes)
407
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) = SUBSTRING(:targetDate, 1, 7)
408
                GROUP BY
409
                  order_month';
410
411
        $q = $em
412
            ->createQuery($dql)
413
            ->setParameter(':excludes', $excludes)
414
            ->setParameter(':targetDate', $dateTime);
415
416
        $result = array();
417
        try {
418
            $result = $q->getSingleResult();
419
        } catch (NoResultException $e) {
420
            // 結果がない場合は空の配列を返す.
421
        }
422
        return $result;
423
    }
424
425
    protected function getSalesByDay($em, $dateTime, array $excludes)
426
    {
427
        // concat... for pgsql
@@ 425-454 (lines=30) @@
422
        return $result;
423
    }
424
425
    protected function getSalesByDay($em, $dateTime, array $excludes)
426
    {
427
        // concat... for pgsql
428
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
429
        $dql = 'SELECT
430
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) AS order_day,
431
                  SUM(o.payment_total) AS order_amount,
432
                  COUNT(o) AS order_count
433
                FROM
434
                  Eccube\Entity\Order o
435
                WHERE
436
                    o.OrderStatus NOT IN (:excludes)
437
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) = SUBSTRING(:targetDate, 1, 10)
438
                GROUP BY
439
                  order_day';
440
441
        $q = $em
442
            ->createQuery($dql)
443
            ->setParameter(':excludes', $excludes)
444
            ->setParameter(':targetDate', $dateTime);
445
446
        $result = array();
447
        try {
448
            $result = $q->getSingleResult();
449
        } catch (NoResultException $e) {
450
            // 結果がない場合は空の配列を返す.
451
        }
452
        return $result;
453
    }
454
455
    protected function countNonStockProducts($em)
456
    {
457
        /** @var $qb \Doctrine\ORM\QueryBuilder */