| @@ 276-294 (lines=19) @@ | ||
| 273 | * |
|
| 274 | * @return int |
|
| 275 | */ |
|
| 276 | public function getCustomersCountWhatMakeCarts(AclHelper $aclHelper, \DateTime $from, \DateTime $to) |
|
| 277 | { |
|
| 278 | $qb = $this->createQueryBuilder('c'); |
|
| 279 | ||
| 280 | try { |
|
| 281 | $qb |
|
| 282 | ->select('COUNT(DISTINCT c.customer) + SUM(CASE WHEN c.isGuest = true THEN 1 ELSE 0 END)') |
|
| 283 | ->andWhere($qb->expr()->between('c.createdAt', ':from', ':to')) |
|
| 284 | ->setParameters([ |
|
| 285 | 'from' => $from, |
|
| 286 | 'to' => $to |
|
| 287 | ]); |
|
| 288 | $this->applyActiveChannelLimitation($qb); |
|
| 289 | ||
| 290 | return (int) $aclHelper->apply($qb)->getSingleScalarResult(); |
|
| 291 | } catch (NoResultException $ex) { |
|
| 292 | return 0; |
|
| 293 | } |
|
| 294 | } |
|
| 295 | } |
|
| 296 | ||
| @@ 276-294 (lines=19) @@ | ||
| 273 | * |
|
| 274 | * @return int |
|
| 275 | */ |
|
| 276 | public function getUniqueBuyersCount(AclHelper $aclHelper, DateTime $from, DateTime $to) |
|
| 277 | { |
|
| 278 | $qb = $this->createQueryBuilder('o'); |
|
| 279 | ||
| 280 | try { |
|
| 281 | $qb |
|
| 282 | ->select('COUNT(DISTINCT o.customer) + SUM(CASE WHEN o.isGuest = true THEN 1 ELSE 0 END)') |
|
| 283 | ->andWhere($qb->expr()->between('o.createdAt', ':from', ':to')) |
|
| 284 | ->setParameters([ |
|
| 285 | 'from' => $from, |
|
| 286 | 'to' => $to |
|
| 287 | ]); |
|
| 288 | $this->applyActiveChannelLimitation($qb); |
|
| 289 | ||
| 290 | return (int) $aclHelper->apply($qb)->getSingleScalarResult(); |
|
| 291 | } catch (NoResultException $ex) { |
|
| 292 | return 0; |
|
| 293 | } |
|
| 294 | } |
|
| 295 | } |
|
| 296 | ||