|
|
@@ -2,7 +2,10 @@ |
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Repository; |
|
|
|
|
|
|
|
use Doctrine\ORM\EntityManager; |
|
|
|
use Lc\ShopBundle\Context\DefaultRepositoryInterface; |
|
|
|
use Lc\ShopBundle\Context\MerchantUtilsInterface; |
|
|
|
use Lc\ShopBundle\Context\OrderUtilsInterface; |
|
|
|
use Lc\ShopBundle\Context\ReductionCartInterface; |
|
|
|
|
|
|
|
/** |
|
|
@@ -13,6 +16,14 @@ use Lc\ShopBundle\Context\ReductionCartInterface; |
|
|
|
*/ |
|
|
|
class ReductionCartRepository extends BaseRepository implements DefaultRepositoryInterface |
|
|
|
{ |
|
|
|
protected $orderUtils ; |
|
|
|
|
|
|
|
public function __construct(EntityManager $entityManager, MerchantUtilsInterface $merchantUtils, OrderUtilsInterface $orderUtils) |
|
|
|
{ |
|
|
|
parent::__construct($entityManager, $merchantUtils); |
|
|
|
$this->orderUtils = $orderUtils ; |
|
|
|
} |
|
|
|
|
|
|
|
public function getInterfaceClass() |
|
|
|
{ |
|
|
|
return ReductionCartInterface::class; |
|
|
@@ -49,8 +60,20 @@ class ReductionCartRepository extends BaseRepository implements DefaultRepositor |
|
|
|
$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)) { |
|
|
|
$reductionCartsArray[] = $reductionCart ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $reductionCartsArray ; |
|
|
|
} |
|
|
|
} |