| @@ 205-228 (lines=24) @@ | ||
| 202 | * |
|
| 203 | * @return array |
|
| 204 | */ |
|
| 205 | public function getOrdersOverTime( |
|
| 206 | AclHelper $aclHelper, |
|
| 207 | DateHelper $dateHelper, |
|
| 208 | \DateTime $from, |
|
| 209 | \DateTime $to = null |
|
| 210 | ) { |
|
| 211 | $from = clone $from; |
|
| 212 | $to = clone $to; |
|
| 213 | ||
| 214 | $qb = $this->createQueryBuilder('o') |
|
| 215 | ->select('COUNT(o.id) AS cnt'); |
|
| 216 | ||
| 217 | $dateHelper->addDatePartsSelect($from, $to, $qb, 'o.createdAt'); |
|
| 218 | if ($to) { |
|
| 219 | $qb->andWhere($qb->expr()->between('o.createdAt', ':from', ':to')) |
|
| 220 | ->setParameter('to', $to); |
|
| 221 | } else { |
|
| 222 | $qb->andWhere('o.createdAt > :from'); |
|
| 223 | } |
|
| 224 | $qb->setParameter('from', $from); |
|
| 225 | $this->applyActiveChannelLimitation($qb); |
|
| 226 | ||
| 227 | return $aclHelper->apply($qb)->getResult(); |
|
| 228 | } |
|
| 229 | ||
| 230 | /** |
|
| 231 | * @param AclHelper $aclHelper |
|
| @@ 238-265 (lines=28) @@ | ||
| 235 | * |
|
| 236 | * @return array |
|
| 237 | */ |
|
| 238 | public function getRevenueOverTime( |
|
| 239 | AclHelper $aclHelper, |
|
| 240 | DateHelper $dateHelper, |
|
| 241 | \DateTime $from, |
|
| 242 | \DateTime $to = null |
|
| 243 | ) { |
|
| 244 | $from = clone $from; |
|
| 245 | $to = clone $to; |
|
| 246 | ||
| 247 | $qb = $this->createQueryBuilder('o') |
|
| 248 | ->select('SUM( |
|
| 249 | CASE WHEN o.subtotalAmount IS NOT NULL THEN o.subtotalAmount ELSE 0 END - |
|
| 250 | CASE WHEN o.discountAmount IS NOT NULL THEN ABS(o.discountAmount) ELSE 0 END |
|
| 251 | ) AS amount'); |
|
| 252 | ||
| 253 | $dateHelper->addDatePartsSelect($from, $to, $qb, 'o.createdAt'); |
|
| 254 | ||
| 255 | if ($to) { |
|
| 256 | $qb->andWhere($qb->expr()->between('o.createdAt', ':from', ':to')) |
|
| 257 | ->setParameter('to', $to); |
|
| 258 | } else { |
|
| 259 | $qb->andWhere('o.createdAt > :from'); |
|
| 260 | } |
|
| 261 | $qb->setParameter('from', $from); |
|
| 262 | $this->applyActiveChannelLimitation($qb); |
|
| 263 | ||
| 264 | return $aclHelper->apply($qb)->getResult(); |
|
| 265 | } |
|
| 266 | ||
| 267 | /** |
|
| 268 | * @param AclHelper $aclHelper |
|