orderUtils = $orderUtils ; } public function getInterfaceClass() { return ReductionCartInterface::class; } public function findByCode($code) { $query = $this->findByMerchantQuery() ; $query->andWhere('e.codes LIKE :code')->setParameter('code', '%'.$code.'%') ; return $query->getQuery()->getResult() ; } public function getValuesOfFieldType(){ $query = $this->findByMerchantQuery() ; $query->select('DISTINCT e.type'); $query->andWhere('e.status = 1'); return $query->getQuery()->getResult() ; } public function getValuesOfFieldCode(){ $query = $this->findByMerchantQuery() ; $query->select('DISTINCT e.codes'); $query->andWhere('e.status = 1'); return $query->getQuery()->getResult() ; } public function getOnlineReductionCart() { $query = $this->findByMerchantQuery() ; $query->andWhere('e.status = 1'); return $query->getQuery()->getResult(); } public function findAllAvailableForUser($user) { $reductionCarts = $this->findAll() ; $reductionCartsArray = [] ; foreach($reductionCarts as $reductionCart) { if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user) && $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user) && $this->orderUtils->getReductionCartRemainingQuantityPerUser($reductionCart, $user) && ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) { $reductionCartsArray[] = $reductionCart ; } } return $reductionCartsArray ; } }