@@ 454-483 (lines=30) @@ | ||
451 | * |
|
452 | * @throws \Doctrine\ORM\NonUniqueResultException |
|
453 | */ |
|
454 | protected function getSalesByDay($dateTime) |
|
455 | { |
|
456 | // concat... for pgsql |
|
457 | // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3 |
|
458 | $dql = 'SELECT |
|
459 | SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) AS order_day, |
|
460 | SUM(o.payment_total) AS order_amount, |
|
461 | COUNT(o) AS order_count |
|
462 | FROM |
|
463 | Eccube\Entity\Order o |
|
464 | WHERE |
|
465 | o.OrderStatus NOT IN (:excludes) |
|
466 | AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) = SUBSTRING(:targetDate, 1, 10) |
|
467 | GROUP BY |
|
468 | order_day'; |
|
469 | ||
470 | $q = $this->entityManager |
|
471 | ->createQuery($dql) |
|
472 | ->setParameter(':excludes', $this->excludes) |
|
473 | ->setParameter(':targetDate', $dateTime); |
|
474 | ||
475 | $result = []; |
|
476 | try { |
|
477 | $result = $q->getSingleResult(); |
|
478 | } catch (NoResultException $e) { |
|
479 | // 結果がない場合は空の配列を返す. |
|
480 | } |
|
481 | ||
482 | return $result; |
|
483 | } |
|
484 | ||
485 | /** |
|
486 | * @param $dateTime |
|
@@ 492-521 (lines=30) @@ | ||
489 | * |
|
490 | * @throws \Doctrine\ORM\NonUniqueResultException |
|
491 | */ |
|
492 | protected function getSalesByMonth($dateTime) |
|
493 | { |
|
494 | // concat... for pgsql |
|
495 | // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3 |
|
496 | $dql = 'SELECT |
|
497 | SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) AS order_month, |
|
498 | SUM(o.payment_total) AS order_amount, |
|
499 | COUNT(o) AS order_count |
|
500 | FROM |
|
501 | Eccube\Entity\Order o |
|
502 | WHERE |
|
503 | o.OrderStatus NOT IN (:excludes) |
|
504 | AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) = SUBSTRING(:targetDate, 1, 7) |
|
505 | GROUP BY |
|
506 | order_month'; |
|
507 | ||
508 | $q = $this->entityManager |
|
509 | ->createQuery($dql) |
|
510 | ->setParameter(':excludes', $this->excludes) |
|
511 | ->setParameter(':targetDate', $dateTime); |
|
512 | ||
513 | $result = []; |
|
514 | try { |
|
515 | $result = $q->getSingleResult(); |
|
516 | } catch (NoResultException $e) { |
|
517 | // 結果がない場合は空の配列を返す. |
|
518 | } |
|
519 | ||
520 | return $result; |
|
521 | } |
|
522 | ||
523 | /** |
|
524 | * 在庫切れ商品数を取得 |