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

return OrderShopInterface::class; return OrderShopInterface::class;
} }


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



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



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

Loading…
Cancel
Save