Failed Conditions
Push — experimental/sf ( 37b3aa...cc45c1 )
by chihiro
921:05 queued 894:01
created

OrderRepository::getExistsOrdersByCustomer()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 1
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
ccs 12
cts 12
cp 1
crap 3
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Repository;
15
16
use Doctrine\ORM\QueryBuilder;
17
use Eccube\Doctrine\Query\Queries;
18
use Eccube\Entity\Order;
19
use Eccube\Entity\Master\OrderStatus;
20
use Eccube\Util\StringUtil;
21
use Symfony\Bridge\Doctrine\RegistryInterface;
22
23
/**
24
 * OrderRepository
25
 *
26
 * This class was generated by the Doctrine ORM. Add your own custom
27
 * repository methods below.
28
 */
29
class OrderRepository extends AbstractRepository
30
{
31
    /**
32
     * @var Queries
33
     */
34
    protected $queries;
35
36
    /**
37
     * OrderRepository constructor.
38
     *
39
     * @param RegistryInterface $registry
40
     * @param Queries $queries
0 ignored issues
show
introduced by
Expected 11 spaces after parameter type; 1 found
Loading history...
41
     */
42 765
    public function __construct(RegistryInterface $registry, Queries $queries)
43
    {
44 765
        parent::__construct($registry, Order::class);
45 765
        $this->queries = $queries;
46
    }
47
48
    /**
49
     * @param int $orderId
0 ignored issues
show
introduced by
Expected 9 spaces after parameter type; 1 found
Loading history...
50
     * @param OrderStatus $Status
51
     */
52 6
    public function changeStatus($orderId, \Eccube\Entity\Master\OrderStatus $Status)
53
    {
54
        $Order = $this
55 6
            ->find($orderId)
56 6
            ->setOrderStatus($Status)
57
        ;
58
59 6
        switch ($Status->getId()) {
60 6
            case '6': // 入金済へ
61 3
                $Order->setPaymentDate(new \DateTime());
62 3
                break;
63
        }
64
65 6
        $em = $this->getEntityManager();
66 6
        $em->persist($Order);
67 6
        $em->flush();
68
    }
69
70
    /**
71
     * @param array $searchData
72
     *
73
     * @return QueryBuilder
74
     */
75 17
    public function getQueryBuilderBySearchData($searchData)
76
    {
77 17
        $qb = $this->createQueryBuilder('o');
78
79 17
        $joinedCustomer = false;
80
81
        // order_id_start
82 17 View Code Duplication
        if (isset($searchData['order_id_start']) && StringUtil::isNotBlank($searchData['order_id_start'])) {
83
            $qb
84 1
                ->andWhere('o.id >= :order_id_start')
85 1
                ->setParameter('order_id_start', $searchData['order_id_start']);
86
        }
87
88
        // order_id_end
89 17 View Code Duplication
        if (isset($searchData['order_id_end']) && StringUtil::isNotBlank($searchData['order_id_end'])) {
90
            $qb
91 1
                ->andWhere('o.id <= :order_id_end')
92 1
                ->setParameter('order_id_end', $searchData['order_id_end']);
93
        }
94
95
        // status
96 17
        if (!empty($searchData['status']) && $searchData['status']) {
97
            $qb
98 1
                ->andWhere('o.OrderStatus = :status')
99 1
                ->setParameter('status', $searchData['status']);
100
        }
101
102
        // name
103 17 View Code Duplication
        if (isset($searchData['name']) && StringUtil::isNotBlank($searchData['name'])) {
104
            $qb
105 1
                ->andWhere('CONCAT(o.name01, o.name02) LIKE :name')
106 1
                ->setParameter('name', '%'.$searchData['name'].'%');
107
        }
108
109
        // kana
110 17 View Code Duplication
        if (isset($searchData['kana']) && StringUtil::isNotBlank($searchData['kana'])) {
111
            $qb
112 1
                ->andWhere('CONCAT(o.kana01, o.kana02) LIKE :kana')
113 1
                ->setParameter('kana', '%'.$searchData['kana'].'%');
114
        }
115
116
        // email
117 17 View Code Duplication
        if (isset($searchData['email']) && StringUtil::isNotBlank($searchData['email'])) {
118
            $qb
119 1
                ->andWhere('o.email = :email')
120 1
                ->setParameter('email', $searchData['email']);
121
        }
122
123
        // tel
124 17 View Code Duplication
        if (isset($searchData['phone_number']) && StringUtil::isNotBlank($searchData['phone_number'])) {
125
            $qb
126 1
                ->andWhere('o.phone_number = :phone_number')
127 1
                ->setParameter('phone_number', $searchData['phone_number']);
128
        }
129
130
        // birth
131 17 View Code Duplication
        if (!empty($searchData['birth_start']) && $searchData['birth_start']) {
132 1
            if (!$joinedCustomer) {
133 1
                $qb->leftJoin('o.Customer', 'c');
134 1
                $joinedCustomer = true;
135
            }
136
137 1
            $date = $searchData['birth_start'];
138
            $qb
139 1
                ->andWhere('c.birth >= :birth_start')
140 1
                ->setParameter('birth_start', $date);
141
        }
142 17 View Code Duplication
        if (!empty($searchData['birth_end']) && $searchData['birth_end']) {
143 1
            if (!$joinedCustomer) {
144 1
                $qb->leftJoin('o.Customer', 'c');
145 1
                $joinedCustomer = true;
146
            }
147
148 1
            $date = clone $searchData['birth_end'];
149
            $date = $date
150 1
                ->modify('+1 days');
151
            $qb
152 1
                ->andWhere('c.birth < :birth_end')
153 1
                ->setParameter('birth_end', $date);
154
        }
155
156
        // sex
157 17
        if (!empty($searchData['sex']) && count($searchData['sex']) > 0) {
158 1
            if (!$joinedCustomer) {
159 1
                $qb->leftJoin('o.Customer', 'c');
160 1
                $joinedCustomer = true;
0 ignored issues
show
Unused Code introduced by
$joinedCustomer is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
161
            }
162
163 1
            $sexs = [];
164 1
            foreach ($searchData['sex'] as $sex) {
165 1
                $sexs[] = $sex->getId();
166
            }
167
168
            $qb
169 1
                ->andWhere($qb->expr()->in('c.Sex', ':sexs'))
170 1
                ->setParameter('sexs', $sexs);
171
        }
172
173
        // payment
174 17 View Code Duplication
        if (!empty($searchData['payment']) && count($searchData['payment'])) {
175
            $payments = [];
176
            foreach ($searchData['payment'] as $payment) {
177
                $payments[] = $payment->getId();
178
            }
179
            $qb
180
                ->leftJoin('o.Payment', 'p')
181
                ->andWhere($qb->expr()->in('p.id', ':payments'))
182
                ->setParameter('payments', $payments);
183
        }
184
185
        // oreder_date
186 17 View Code Duplication
        if (!empty($searchData['order_date_start']) && $searchData['order_date_start']) {
187 1
            $date = $searchData['order_date_start'];
188
            $qb
189 1
                ->andWhere('o.create_date >= :order_date_start')
190 1
                ->setParameter('order_date_start', $date);
191
        }
192 17 View Code Duplication
        if (!empty($searchData['order_date_end']) && $searchData['order_date_end']) {
193 1
            $date = clone $searchData['order_date_end'];
194
            $date = $date
195 1
                ->modify('+1 days');
196
            $qb
197 1
                ->andWhere('o.create_date < :order_date_end')
198 1
                ->setParameter('order_date_end', $date);
199
        }
200
201
        // create_date
202 17 View Code Duplication
        if (!empty($searchData['update_date_start']) && $searchData['update_date_start']) {
203 1
            $date = $searchData['update_date_start'];
204
            $qb
205 1
                ->andWhere('o.update_date >= :update_date_start')
206 1
                ->setParameter('update_date_start', $date);
207
        }
208 17 View Code Duplication
        if (!empty($searchData['update_date_end']) && $searchData['update_date_end']) {
209 1
            $date = clone $searchData['update_date_end'];
210
            $date = $date
211 1
                ->modify('+1 days');
212
            $qb
213 1
                ->andWhere('o.update_date < :update_date_end')
214 1
                ->setParameter('update_date_end', $date);
215
        }
216
217
        // payment_total
218 17 View Code Duplication
        if (isset($searchData['payment_total_start']) && StringUtil::isNotBlank($searchData['payment_total_start'])) {
219
            $qb
220 1
                ->andWhere('o.payment_total >= :payment_total_start')
221 1
                ->setParameter('payment_total_start', $searchData['payment_total_start']);
222
        }
223 17 View Code Duplication
        if (isset($searchData['payment_total_end']) && StringUtil::isNotBlank($searchData['payment_total_end'])) {
224
            $qb
225 1
                ->andWhere('o.payment_total <= :payment_total_end')
226 1
                ->setParameter('payment_total_end', $searchData['payment_total_end']);
227
        }
228
229
        // buy_product_name
230 17 View Code Duplication
        if (isset($searchData['buy_product_name']) && StringUtil::isNotBlank($searchData['buy_product_name'])) {
231
            $qb
232 1
                ->leftJoin('o.OrderItems', 'oi')
233 1
                ->andWhere('oi.product_name LIKE :buy_product_name')
234 1
                ->setParameter('buy_product_name', '%'.$searchData['buy_product_name'].'%');
235
        }
236
237
        // Order By
238 17
        $qb->addOrderBy('o.update_date', 'DESC');
239
240 17
        return $this->queries->customize(QueryKey::ORDER_SEARCH, $qb, $searchData);
241
    }
242
243
    /**
244
     * @param  array        $searchData
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 8 found
Loading history...
245
     *
246
     * @return QueryBuilder
247
     */
248 32
    public function getQueryBuilderBySearchDataForAdmin($searchData)
249
    {
250 32
        $qb = $this->createQueryBuilder('o')
251 32
            ->select('o, s')
252 32
            ->innerJoin('o.Shippings', 's');
253
254
        // order_id_start
255 32 View Code Duplication
        if (isset($searchData['order_id']) && StringUtil::isNotBlank($searchData['order_id'])) {
256
            $qb
257
                ->andWhere('o.id = :order_id')
258
                ->setParameter('order_id', $searchData['order_id']);
259
        }
260
261
        // order_no
262 32 View Code Duplication
        if (isset($searchData['order_no']) && StringUtil::isNotBlank($searchData['order_no'])) {
263
            $qb
264 2
                ->andWhere('o.order_no = :order_no')
265 2
                ->setParameter('order_no', $searchData['order_no']);
266
        }
267
268
        // order_id_start
269 32 View Code Duplication
        if (isset($searchData['order_id_start']) && StringUtil::isNotBlank($searchData['order_id_start'])) {
270
            $qb
271 1
                ->andWhere('o.id >= :order_id_start')
272 1
                ->setParameter('order_id_start', $searchData['order_id_start']);
273
        }
274
        // multi
275 32 View Code Duplication
        if (isset($searchData['multi']) && StringUtil::isNotBlank($searchData['multi'])) {
276 5
            $multi = preg_match('/^\d{0,10}$/', $searchData['multi']) ? $searchData['multi'] : null;
277
            $qb
278 5
                ->andWhere('o.id = :multi OR o.name01 LIKE :likemulti OR o.name02 LIKE :likemulti OR '.
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
279
                           'o.kana01 LIKE :likemulti OR o.kana02 LIKE :likemulti OR o.company_name LIKE :likemulti OR '.
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
280 5
                           'o.order_no LIKE :likemulti')
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 16 spaces, but found 27.
Loading history...
281 5
                ->setParameter('multi', $multi)
282 5
                ->setParameter('likemulti', '%'.$searchData['multi'].'%');
283
        }
284
285
        // order_id_end
286 32 View Code Duplication
        if (isset($searchData['order_id_end']) && StringUtil::isNotBlank($searchData['order_id_end'])) {
287
            $qb
288 1
                ->andWhere('o.id <= :order_id_end')
289 1
                ->setParameter('order_id_end', $searchData['order_id_end']);
290
        }
291
292
        // status
293 32
        $filterStatus = false;
294 32 View Code Duplication
        if (!empty($searchData['status']) && count($searchData['status'])) {
295
            $qb
296 1
                ->andWhere($qb->expr()->in('o.OrderStatus', ':status'))
297 1
                ->setParameter('status', $searchData['status']);
298 1
            $filterStatus = true;
299
        }
300
301 32
        if (!$filterStatus) {
302
            // 購入処理中は検索対象から除外
303 31
            $OrderStatuses = $this->getEntityManager()
304 31
                ->getRepository('Eccube\Entity\Master\OrderStatus')
305 31
                ->findNotContainsBy(['id' => OrderStatus::PROCESSING]);
306 31
            $qb->andWhere($qb->expr()->in('o.OrderStatus', ':status'))
307 31
                ->setParameter('status', $OrderStatuses);
308
        }
309
310
        // company_name
311 32 View Code Duplication
        if (isset($searchData['company_name']) && StringUtil::isNotBlank($searchData['company_name'])) {
312
            $qb
313 1
                ->andWhere('o.company_name LIKE :company_name')
314 1
                ->setParameter('company_name', '%'.$searchData['company_name'].'%');
315
        }
316
317
        // name
318 32 View Code Duplication
        if (isset($searchData['name']) && StringUtil::isNotBlank($searchData['name'])) {
319
            $qb
320 1
                ->andWhere('CONCAT(o.name01, o.name02) LIKE :name')
321 1
                ->setParameter('name', '%'.$searchData['name'].'%');
322
        }
323
324
        // kana
325 32 View Code Duplication
        if (isset($searchData['kana']) && StringUtil::isNotBlank($searchData['kana'])) {
326
            $qb
327 1
                ->andWhere('CONCAT(o.kana01, o.kana02) LIKE :kana')
328 1
                ->setParameter('kana', '%'.$searchData['kana'].'%');
329
        }
330
331
        // email
332 32 View Code Duplication
        if (isset($searchData['email']) && StringUtil::isNotBlank($searchData['email'])) {
333
            $qb
334 3
                ->andWhere('o.email like :email')
335 3
                ->setParameter('email', '%'.$searchData['email'].'%');
336
        }
337
338
        // tel
339 32 View Code Duplication
        if (isset($searchData['phone_number']) && StringUtil::isNotBlank($searchData['phone_number'])) {
340 1
            $tel = preg_replace('/[^0-9]/ ', '', $searchData['phone_number']);
341
            $qb
342 1
                ->andWhere('o.phone_number LIKE :phone_number')
343 1
                ->setParameter('phone_number', '%'.$tel.'%');
344
        }
345
346
        // sex
347 32
        if (!empty($searchData['sex']) && count($searchData['sex']) > 0) {
348
            $qb
349 1
                ->andWhere($qb->expr()->in('o.Sex', ':sex'))
350 1
                ->setParameter('sex', $searchData['sex']->toArray());
351
        }
352
353
        // payment
354 32 View Code Duplication
        if (!empty($searchData['payment']) && count($searchData['payment'])) {
355
            $payments = [];
356
            foreach ($searchData['payment'] as $payment) {
357
                $payments[] = $payment->getId();
358
            }
359
            $qb
360
                ->leftJoin('o.Payment', 'p')
361
                ->andWhere($qb->expr()->in('p.id', ':payments'))
362
                ->setParameter('payments', $payments);
363
        }
364
365
        // oreder_date
366 32 View Code Duplication
        if (!empty($searchData['order_date_start']) && $searchData['order_date_start']) {
367 1
            $date = $searchData['order_date_start'];
368
            $qb
369 1
                ->andWhere('o.order_date >= :order_date_start')
370 1
                ->setParameter('order_date_start', $date);
371
        }
372 32 View Code Duplication
        if (!empty($searchData['order_date_end']) && $searchData['order_date_end']) {
373 1
            $date = clone $searchData['order_date_end'];
374
            $date = $date
375 1
                ->modify('+1 days');
376
            $qb
377 1
                ->andWhere('o.order_date < :order_date_end')
378 1
                ->setParameter('order_date_end', $date);
379
        }
380
381
        // payment_date
382 32 View Code Duplication
        if (!empty($searchData['payment_date_start']) && $searchData['payment_date_start']) {
383 1
            $date = $searchData['payment_date_start'];
384
            $qb
385 1
                ->andWhere('o.payment_date >= :payment_date_start')
386 1
                ->setParameter('payment_date_start', $date);
387
        }
388 32 View Code Duplication
        if (!empty($searchData['payment_date_end']) && $searchData['payment_date_end']) {
389 1
            $date = clone $searchData['payment_date_end'];
390
            $date = $date
391 1
                ->modify('+1 days');
392
            $qb
393 1
                ->andWhere('o.payment_date < :payment_date_end')
394 1
                ->setParameter('payment_date_end', $date);
395
        }
396
397
        // update_date
398 32 View Code Duplication
        if (!empty($searchData['update_date_start']) && $searchData['update_date_start']) {
399 1
            $date = $searchData['update_date_start'];
400
            $qb
401 1
                ->andWhere('o.update_date >= :update_date_start')
402 1
                ->setParameter('update_date_start', $date);
403
        }
404 32 View Code Duplication
        if (!empty($searchData['update_date_end']) && $searchData['update_date_end']) {
405 1
            $date = clone $searchData['update_date_end'];
406
            $date = $date
407 1
                ->modify('+1 days');
408
            $qb
409 1
                ->andWhere('o.update_date < :update_date_end')
410 1
                ->setParameter('update_date_end', $date);
411
        }
412
413
        // payment_total
414 32 View Code Duplication
        if (isset($searchData['payment_total_start']) && StringUtil::isNotBlank($searchData['payment_total_start'])) {
415
            $qb
416 1
                ->andWhere('o.payment_total >= :payment_total_start')
417 1
                ->setParameter('payment_total_start', $searchData['payment_total_start']);
418
        }
419 32 View Code Duplication
        if (isset($searchData['payment_total_end']) && StringUtil::isNotBlank($searchData['payment_total_end'])) {
420
            $qb
421 1
                ->andWhere('o.payment_total <= :payment_total_end')
422 1
                ->setParameter('payment_total_end', $searchData['payment_total_end']);
423
        }
424
425
        // buy_product_name
426 32 View Code Duplication
        if (isset($searchData['buy_product_name']) && StringUtil::isNotBlank($searchData['buy_product_name'])) {
427
            $qb
428 1
                ->leftJoin('o.OrderItems', 'oi')
429 1
                ->andWhere('oi.product_name LIKE :buy_product_name')
430 1
                ->setParameter('buy_product_name', '%'.$searchData['buy_product_name'].'%');
431
        }
432
433
        // 発送メール送信済かどうか.
434 32
        if (isset($searchData['shipping_mail_send']) && $searchData['shipping_mail_send']) {
435
            $qb
436
                ->andWhere('s.mail_send_date IS NOT NULL');
437
        }
438
439
        // 送り状番号.
440 32
        if (!empty($searchData['tracking_number'])) {
441
            $qb
442 1
                ->andWhere('s.tracking_number = :tracking_number')
443 1
                ->setParameter('tracking_number', $searchData['tracking_number']);
444
        }
445
446
        // お届け予定日(Shipping.delivery_date)
447 32 View Code Duplication
        if (!empty($searchData['shipping_delivery_date_start']) && $searchData['shipping_delivery_date_start']) {
448
            $date = $searchData['shipping_delivery_date_start'];
449
            $qb
450
                ->andWhere('s.shipping_delivery_date >= :shipping_delivery_date_start')
451
                ->setParameter('shipping_delivery_date_start', $date);
452
        }
453 32 View Code Duplication
        if (!empty($searchData['shipping_delivery_date_end']) && $searchData['shipping_delivery_date_end']) {
454
            $date = clone $searchData['shipping_delivery_date_end'];
455
            $date = $date
456
                ->modify('+1 days');
457
            $qb
458
                ->andWhere('s.shipping_delivery_date < :shipping_delivery_date_end')
459
                ->setParameter('shipping_delivery_date_end', $date);
460
        }
461
462
        // Order By
463 32
        $qb->orderBy('o.update_date', 'DESC');
464 32
        $qb->addorderBy('o.id', 'DESC');
465
466 32
        return $this->queries->customize(QueryKey::ORDER_SEARCH_ADMIN, $qb, $searchData);
467
    }
468
469
    /**
470
     * @param  \Eccube\Entity\Customer $Customer
471
     *
472
     * @return QueryBuilder
473
     */
474 2 View Code Duplication
    public function getQueryBuilderByCustomer(\Eccube\Entity\Customer $Customer)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
475
    {
476 2
        $qb = $this->createQueryBuilder('o')
477 2
            ->where('o.Customer = :Customer')
478 2
            ->setParameter('Customer', $Customer);
479
480
        // Order By
481 2
        $qb->addOrderBy('o.id', 'DESC');
482
483 2
        return $this->queries->customize(QueryKey::ORDER_SEARCH_BY_CUSTOMER, $qb, ['customer' => $Customer]);
484
    }
485
486
    /**
487
     * 会員の合計購入金額を取得、回数を取得
488
     *
489
     * @param  \Eccube\Entity\Customer $Customer
490
     * @param  array $OrderStatuses
0 ignored issues
show
introduced by
Expected 19 spaces after parameter type; 1 found
Loading history...
491
     *
492
     * @return array
493
     */
494 1
    public function getCustomerCount(\Eccube\Entity\Customer $Customer, array $OrderStatuses)
495
    {
496 1
        $result = $this->createQueryBuilder('o')
497 1
            ->select('COUNT(o.id) AS buy_times, SUM(o.total)  AS buy_total')
498 1
            ->where('o.Customer = :Customer')
499 1
            ->andWhere('o.OrderStatus in (:OrderStatuses)')
500 1
            ->setParameter('Customer', $Customer)
501 1
            ->setParameter('OrderStatuses', $OrderStatuses)
502 1
            ->groupBy('o.Customer')
503 1
            ->getQuery()
504 1
            ->getResult();
505
506 1
        return $result;
507
    }
508
509
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
510
     * 会員が保持する最新の購入処理中の Order を取得する.
511
     *
512
     * @param Customer
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
513
     *
514
     * @return Order
515
     */
516 2
    public function getExistsOrdersByCustomer(\Eccube\Entity\Customer $Customer)
517
    {
518 2
        $qb = $this->createQueryBuilder('o');
519
        $Order = $qb
520 2
            ->select('o')
521 2
            ->where('o.Customer = :Customer')
522 2
            ->setParameter('Customer', $Customer)
523 2
            ->orderBy('o.id', 'DESC')
524 2
            ->getQuery()
525 2
            ->setMaxResults(1)
526 2
            ->getOneOrNullResult();
527
528 2
        if ($Order && $Order->getOrderStatus()->getId() == OrderStatus::PROCESSING) {
529 1
            return $Order;
530
        }
531
532 1
        return null;
533
    }
534
535
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$OrderStatusOrId" missing
Loading history...
536
     * ステータスごとの受注件数を取得する.
537
     *
538
     * @param $OrderStatusOrId
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
539
     *
540
     * @return int
541
     *
542
     * @throws \Doctrine\ORM\NoResultException
543
     * @throws \Doctrine\ORM\NonUniqueResultException
544
     */
545 16
    public function countByOrderStatus($OrderStatusOrId)
546
    {
547 16
        return (int) $this->createQueryBuilder('o')
548 16
            ->select('COALESCE(COUNT(o.id), 0)')
549 16
            ->where('o.OrderStatus = :OrderStatus')
550 16
            ->setParameter('OrderStatus', $OrderStatusOrId)
551 16
            ->getQuery()
552 16
            ->getSingleScalarResult();
553
    }
554
}
555