Browse Source

[Global] Bon cadeau

feature/module_traiteur_v1
Fab 4 years ago
parent
commit
c93829eb66
2 changed files with 7 additions and 4 deletions
  1. +6
    -3
      ShopBundle/Repository/OrderShopRepository.php
  2. +1
    -1
      ShopBundle/Services/Order/OrderUtilsReductionTrait.php

+ 6
- 3
ShopBundle/Repository/OrderShopRepository.php View File

@@ -24,16 +24,19 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
return OrderShopInterface::class;
}

public function countValidOrderWithReductionCredit($reductionCredit, $user)
public function countValidOrderWithReductionCredit($reductionCredit, $user=null)
{
$query = $this->findByMerchantQuery();
$query = $this->filterOrderValid($query);
$query->select('count(e.id)');
$query->andWhere('e.user = :user');
if($user) {
$query->andWhere('e.user = :user');
$query->setParameter('user', $user);
}
$query->innerJoin('e.orderReductionCredits', 'orc');
$query->andWhere('orc.reductionCredit = :reductionCredit');
$query->setParameter('reductionCredit', $reductionCredit);
$query->setParameter('user', $user);
return $query->getQuery()->getSingleScalarResult();
}


+ 1
- 1
ShopBundle/Services/Order/OrderUtilsReductionTrait.php View File

@@ -164,7 +164,7 @@ trait OrderUtilsReductionTrait

$reductionGiftsArray = [] ;
foreach($reductionGifts as $reductionGift) {
if(!$this->orderShopRepo->countValidOrderWithReductionCredit($reductionGift, $user)) {
if(!$this->orderShopRepo->countValidOrderWithReductionCredit($reductionGift)) {
$reductionGiftsArray[] = $reductionGift ;
}
}

Loading…
Cancel
Save