Code Duplication    Length = 30-30 lines in 2 locations

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

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