$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
public function getOneLatestByType(string $documentType) | |||||
public function getOneLatestByType(string $documentType, $query = null) | |||||
{ | { | ||||
// @TODO : à écrire | // @TODO : à écrire | ||||
} | } | ||||
// findLastInvoice | // findLastInvoice | ||||
public function getOneLastInvoice() | |||||
public function getOneLastInvoice($query = null) | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query | $query | ||||
->filterByMerchant($this->merchant) | |||||
->filterBySection($this->section) | |||||
->orderBy('.createdAt', 'DESC'); | ->orderBy('.createdAt', 'DESC'); | ||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
public function getByBuyerAddress(Address $buyerAddress) | |||||
public function getByBuyerAddress(Address $buyerAddress, $query = null) | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query | |||||
->filterByBuyerAddress($buyerAddress); | |||||
$query = $this->createQuery($query); | |||||
$query->filterByBuyerAddress($buyerAddress); | |||||
return $query->find(); | return $query->find(); | ||||
} | } | ||||
} | } | ||||
// getOrderShopsOfWeek | // getOrderShopsOfWeek | ||||
public function getByCurrentCycle($params = []) | |||||
public function getByCurrentCycle($params = [], $query = null) | |||||
{ | { | ||||
$orderShops = $this->getBy( | $orderShops = $this->getBy( | ||||
array_merge( | array_merge( | ||||
'isValid' => true, | 'isValid' => true, | ||||
], | ], | ||||
$params | $params | ||||
) | |||||
), | |||||
$query | |||||
); | ); | ||||
return $orderShops; | return $orderShops; | ||||
} | } | ||||
// getOrderShopsOfWeekByUser | // getOrderShopsOfWeekByUser | ||||
public function getByCurrentCycleAndUser(UserInterface $user, array $params = []) | |||||
public function getByCurrentCycleAndUser(UserInterface $user, array $params = [], $query = null) | |||||
{ | { | ||||
return $this->getByCurrentCycle( | return $this->getByCurrentCycle( | ||||
array_merge( | array_merge( | ||||
'excludeComplementaryOrderShops' => true | 'excludeComplementaryOrderShops' => true | ||||
], | ], | ||||
$params | $params | ||||
) | |||||
), | |||||
$query | |||||
); | ); | ||||
} | } | ||||
//public $countOrderShopsOfWeek = null; | //public $countOrderShopsOfWeek = null; | ||||
public function countByCurrentCycle(bool $excludeComplementaryOrderShops = true) | |||||
public function countByCurrentCycle(bool $excludeComplementaryOrderShops = true, $query = null) | |||||
{ | { | ||||
return $this->getByCurrentCycle( | return $this->getByCurrentCycle( | ||||
[ | [ | ||||
'count' => true, | 'count' => true, | ||||
'excludeComplementaryOrderShops' => $excludeComplementaryOrderShops | 'excludeComplementaryOrderShops' => $excludeComplementaryOrderShops | ||||
] | |||||
], | |||||
$query | |||||
); | ); | ||||
// @TODO : optimisation à remettre en place | // @TODO : optimisation à remettre en place | ||||
} | } | ||||
// getNextWeekId | // getNextWeekId | ||||
public function getNextCycleId(int $cycleNumber): int | |||||
public function getNextCycleId(int $cycleNumber, $query = null): int | |||||
{ | { | ||||
$lastOrder = $this->getOneLastValidOfCycle($cycleNumber); | |||||
$lastOrder = $this->getOneLastValidOfCycle($cycleNumber, $query); | |||||
if ($lastOrder) { | if ($lastOrder) { | ||||
return intval($lastOrder->getCycleId() + 1); | return intval($lastOrder->getCycleId() + 1); | ||||
} else { | } else { | ||||
} | } | ||||
} | } | ||||
public function getNextIdValidOrder(): int | |||||
public function getNextIdValidOrder($query = null): int | |||||
{ | { | ||||
$lastOrder = $this->getOneLastValid(); | |||||
$lastOrder = $this->getOneLastValid($query); | |||||
if ($lastOrder) { | if ($lastOrder) { | ||||
return intval($lastOrder->getIdValidOrder() + 1); | return intval($lastOrder->getIdValidOrder() + 1); | ||||
} | } | ||||
// countValidOrderShopByUserAllMerchant | // countValidOrderShopByUserAllMerchant | ||||
public function countValidByUserAllMerchant($user): int | |||||
public function countValidByUserAllMerchant($user, $query = null): int | |||||
{ | { | ||||
return $this->countBy( | return $this->countBy( | ||||
[ | [ | ||||
'user' => $user, | 'user' => $user, | ||||
'isValid' => true, | 'isValid' => true, | ||||
// @TODO : à tester | |||||
// @TODO : à tester | |||||
'isMerchantOnline' => true, | 'isMerchantOnline' => true, | ||||
'excludeComplementaryOrderShops' => true | 'excludeComplementaryOrderShops' => true | ||||
] | |||||
], | |||||
$query | |||||
); | ); | ||||
} | } | ||||
public function countValidByUser(UserInterface $user): int | |||||
public function countValidByUser(UserInterface $user, $query = null): int | |||||
{ | { | ||||
return $this->countBy( | return $this->countBy( | ||||
[ | [ | ||||
'isValid' => true, | 'isValid' => true, | ||||
'section' => $this->section, | 'section' => $this->section, | ||||
'excludeComplementaryOrderShops' => true | 'excludeComplementaryOrderShops' => true | ||||
] | |||||
], | |||||
$query | |||||
); | ); | ||||
} | } | ||||
public function countValidByCurrentCycle(): int | |||||
public function countValidByCurrentCycle($query = null): int | |||||
{ | { | ||||
return $this->countBy( | return $this->countBy( | ||||
[ | [ | ||||
'isValid' => true, | 'isValid' => true, | ||||
'section' => $this->section, | 'section' => $this->section, | ||||
'excludeComplementaryOrderShops' => true | 'excludeComplementaryOrderShops' => true | ||||
] | |||||
], | |||||
$query | |||||
); | ); | ||||
} | } | ||||
// countValidOrderWithReductionCredit | // countValidOrderWithReductionCredit | ||||
public function countValidWithReductionCredit( | public function countValidWithReductionCredit( | ||||
ReductionCreditInterface $reductionCredit, | ReductionCreditInterface $reductionCredit, | ||||
UserInterface $user = null | |||||
UserInterface $user = null, | |||||
$query = null | |||||
): int { | ): int { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
if ($user) { | if ($user) { | ||||
$query->filterByUser($user); | $query->filterByUser($user); | ||||
} | } | ||||
$query | $query | ||||
->selectCount() | ->selectCount() | ||||
->filterByReductionCredit($reductionCredit) | ->filterByReductionCredit($reductionCredit) | ||||
// countValidOrderWithReductionCart | // countValidOrderWithReductionCart | ||||
public function countValidWithReductionCart( | public function countValidWithReductionCart( | ||||
ReductionCartInterface $reductionCart | |||||
ReductionCartInterface $reductionCart, | |||||
$query = null | |||||
): int { | ): int { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query | $query | ||||
->selectCount() | ->selectCount() | ||||
->filterByReductionCart($reductionCart) | ->filterByReductionCart($reductionCart) | ||||
// countValidOrderWithReductionCartPerUser | // countValidOrderWithReductionCartPerUser | ||||
public function countValidWithReductionCartByUser( | public function countValidWithReductionCartByUser( | ||||
ReductionCartInterface $reductionCart, | ReductionCartInterface $reductionCart, | ||||
UserInterface $user | |||||
UserInterface $user, | |||||
$query = null | |||||
): int { | ): int { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query | $query | ||||
->selectCount() | ->selectCount() | ||||
} | } | ||||
// findCartCurrent | // findCartCurrent | ||||
public function getCartCurrent(array $params): ?OrderShopInterface | |||||
public function getCartCurrent(array $params, $query = null): ?OrderShopInterface | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
if (isset($params['user'])) { | if (isset($params['user'])) { | ||||
$query | |||||
->filterByUser($params['user']); | |||||
$query->filterByUser($params['user']); | |||||
} | } | ||||
if (isset($params['visitor'])) { | if (isset($params['visitor'])) { | ||||
$query | |||||
->filterByVisitor($params['visitor']); | |||||
$query->filterByVisitor($params['visitor']); | |||||
} | } | ||||
$query | $query | ||||
->filterBySection($this->section); | ->filterBySection($this->section); | ||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
// findLastOrderValidOfWeek | // findLastOrderValidOfWeek | ||||
public function getOneLastValidByCycle(int $cycleNumber): ?OrderShopInterface | |||||
public function getOneLastValidByCycle(int $cycleNumber, $query = null): ?OrderShopInterface | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query | $query | ||||
->filterByCycleNumber($cycleNumber) | ->filterByCycleNumber($cycleNumber) | ||||
} | } | ||||
//findLastOrderValid | //findLastOrderValid | ||||
public function getOneLastValid(): ?OrderShopInterface | |||||
public function getOneLastValid($query = null): ?OrderShopInterface | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query | $query | ||||
->filterByStatus(OrderStatusModel::$statusAliasAsValid) | ->filterByStatus(OrderStatusModel::$statusAliasAsValid) | ||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
public function countBy(array $params = []) | |||||
public function countBy(array $params = [], $query = null) | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query->selectCount(); | |||||
$query = $this->applyGetByFilters($query); | |||||
$query | |||||
->selectCount() | |||||
->applyGetByFilters($query); | |||||
return $query->count(); | return $query->count(); | ||||
} | } | ||||
public function getBy(array $params = []): array | |||||
public function getBy(array $params = [], $query = null): array | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query = $this->applyGetByFilters($query); | |||||
$this->applyGetByFilters($query); | |||||
$orderShops = $query->find(); | $orderShops = $query->find(); | ||||
return $query; | return $query; | ||||
} | } | ||||
public function isReductionGiftUsed(ReductionCreditInterface $reductionGift) | |||||
public function isReductionGiftUsed(ReductionCreditInterface $reductionGift, $query = null) | |||||
{ | { | ||||
if ($this->countValidWithReductionCredit($reductionGift)) { | |||||
if ($this->countValidWithReductionCredit($reductionGift, null, $query)) { | |||||
return true; | return true; | ||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
public function isReductionCreditUsed(ReductionCreditInterface $reductionCredit, UserInterface $user = null) | |||||
public function isReductionCreditUsed(ReductionCreditInterface $reductionCredit, UserInterface $user = null, $query = null) | |||||
{ | { | ||||
if ($this->countValidWithReductionCredit($reductionCredit, $user)) { | |||||
if ($this->countValidWithReductionCredit($reductionCredit, $user, $query)) { | |||||
return true; | return true; | ||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
public function isReductionCreditAddedToOrder( | |||||
OrderShopInterface $orderShop, | |||||
ReductionCreditInterface $reductionCredit | |||||
) { | |||||
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | |||||
if ($orderReductionCredit->getReductionCredit() == $reductionCredit) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
/* | |||||
public function getCartCurrent(SectionInterface $section, UserInterface $user = null, VisitorInterface $visitor = null) | |||||
{ | |||||
$paramsSearchOrderShop = []; | |||||
$user = $this->security->getUser(); | |||||
$visitor = $this->userUtils->getVisitorCurrent(); | |||||
$orderShop = null; | |||||
$orderShopUser = null; | |||||
$orderShopVisitor = null; | |||||
if ($user) { | |||||
$orderShopUser = $this->orderShopRepo->findCartCurrent( | |||||
[ | |||||
'user' => $user | |||||
] | |||||
); | |||||
} | |||||
if ($visitor) { | |||||
$orderShopVisitor = $this->orderShopRepo->findCartCurrent( | |||||
[ | |||||
'visitor' => $visitor | |||||
] | |||||
); | |||||
} | |||||
if ($orderShopUser || $orderShopVisitor) { | |||||
// merge | |||||
if ($orderShopUser && $orderShopVisitor && $orderShopUser != $orderShopVisitor | |||||
&& $orderShopVisitor->getOrderProducts() && count($orderShopVisitor->getOrderProducts()) | |||||
&& $orderShopUser->getOrderStatus()->getAlias() == OrderStatus::ALIAS_CART) { | |||||
$orderShop = $this->mergeOrderShops($orderShopUser, $orderShopVisitor); | |||||
$this->utils->addFlash( | |||||
'success', | |||||
"Votre panier visiteur vient d'être fusionné avec votre panier client." | |||||
); | |||||
} else { | |||||
$orderShop = ($orderShopUser) ? $orderShopUser : $orderShopVisitor; | |||||
} | |||||
// set user | |||||
if ($orderShop && $user && !$orderShop->getUser()) { | |||||
$orderShop->setUser($user); | |||||
$orderShop->setVisitor(null); | |||||
$this->em->persist($orderShop); | |||||
$this->em->flush(); | |||||
} | |||||
} | |||||
return $orderShop; | |||||
}*/ | |||||
} | } |
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
} | } |
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | ||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver; | |||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | ||||
class ReductionCartStore extends AbstractStore | class ReductionCartStore extends AbstractStore | ||||
{ | { | ||||
protected ReductionCartRepositoryQuery $query; | protected ReductionCartRepositoryQuery $query; | ||||
protected ReductionCartSolver $reductionCartSolver; | |||||
protected OrderShopStore $orderShopStore; | protected OrderShopStore $orderShopStore; | ||||
protected PriceSolver $priceSolver; | protected PriceSolver $priceSolver; | ||||
protected FlashBagInterface $flashBag; | protected FlashBagInterface $flashBag; | ||||
public function __construct( | public function __construct( | ||||
ReductionCartRepositoryQuery $query, | ReductionCartRepositoryQuery $query, | ||||
ReductionCartSolver $reductionCartSolver, | |||||
OrderShopStore $orderShopStore, | OrderShopStore $orderShopStore, | ||||
PriceSolver $priceSolver, | PriceSolver $priceSolver, | ||||
FlashBagInterface $flashBag | |||||
FlashBagInterface $flashBag, | |||||
) { | ) { | ||||
$this->query = $query; | $this->query = $query; | ||||
$this->reductionCartSolver = $reductionCartSolver; | |||||
$this->orderShopStore = $orderShopStore; | $this->orderShopStore = $orderShopStore; | ||||
$this->priceSolver = $priceSolver; | $this->priceSolver = $priceSolver; | ||||
$this->flashBag = $flashBag; | $this->flashBag = $flashBag; | ||||
} | } | ||||
// getReductionCartByCode | // getReductionCartByCode | ||||
public function getByCode(string $code) | |||||
public function getByCode(string $code, $query = null) | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query->filterByCode($code); | $query->filterByCode($code); | ||||
$reductionCarts = $query->find(); | $reductionCarts = $query->find(); | ||||
} | } | ||||
// findAllAvailableForUser / getReductionCartsAvailableByUser | // findAllAvailableForUser / getReductionCartsAvailableByUser | ||||
public function getAvailableByUser(UserInterface $user) | |||||
public function getAvailableByUser(UserInterface $user, $query = null) | |||||
{ | { | ||||
$reductionCarts = $this->query->find(); | |||||
$query = $this->createQuery($query); | |||||
$reductionCarts = $query->find(); | |||||
$reductionCartsArray = []; | $reductionCartsArray = []; | ||||
foreach ($reductionCarts as $reductionCart) { | foreach ($reductionCarts as $reductionCart) { | ||||
if ($reductionCart->matchWithUser($user) | |||||
&& $reductionCart->matchWithGroupUser($user) | |||||
if ($this->reductionCartSolver->matchWithUser($user) | |||||
&& $this->reductionCartSolver->matchWithGroupUser($user) | |||||
&& $this->getRemainingQuantityByUser($reductionCart, $user) | && $this->getRemainingQuantityByUser($reductionCart, $user) | ||||
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) { | && ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) { | ||||
$reductionCartsArray[] = $reductionCart; | $reductionCartsArray[] = $reductionCart; | ||||
return $reductionCartsArray; | return $reductionCartsArray; | ||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Repository\Reduction; | namespace Lc\CaracoleBundle\Repository\Reduction; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
class ReductionCatalogStore extends AbstractStore | class ReductionCatalogStore extends AbstractStore | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
public function getByProductFamily($productFamily){ | |||||
$query = $this->query->create(); | |||||
$query->filterProductFamily($productFamily); | |||||
$query->filterIsOnline(); | |||||
return $query->findOne(); | |||||
public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null) | |||||
{ | |||||
$query = $this->createQuery($query); | |||||
$query | |||||
->filterProductFamily($productFamily) | |||||
->filterIsOnline(); | |||||
return $query->findOne(); | |||||
} | } | ||||
} | } |
} | } | ||||
// findReductionCreditsByUser | // findReductionCreditsByUser | ||||
public function getByTypeAndUser(string $type = ReductionCreditModel::TYPE_CREDIT, UserInterface $user) | |||||
public function getByTypeAndUser(string $type, UserInterface $user, $query = null) | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query | $query | ||||
->filterByType($type) | ->filterByType($type) |
public function get($params = [], $query = null) | public function get($params = [], $query = null) | ||||
{ | { | ||||
if (is_null($query)) { | |||||
$query = $this->query->create(); | |||||
} | |||||
$query = $this->createQuery($query); | |||||
if ($this->merchant) { | if ($this->merchant) { | ||||
$query->filterByMerchant($this->merchant); | $query->filterByMerchant($this->merchant); | ||||
public function getByUser(UserInterface $user, $query = null): array | public function getByUser(UserInterface $user, $query = null): array | ||||
{ | { | ||||
if (is_null($query)) { | |||||
$query = $this->query->create(); | |||||
} | |||||
$query = $this->createQuery($query); | |||||
if ($this->merchant) { | if ($this->merchant) { | ||||
$query->filterByMerchant($this->merchant); | $query->filterByMerchant($this->merchant); | ||||
int $entityId = null, | int $entityId = null, | ||||
$query = null | $query = null | ||||
): array { | ): array { | ||||
if (is_null($query)) { | |||||
$query = $this->query->create(); | |||||
} | |||||
$query = $this->createQuery($query); | |||||
if ($this->merchant) { | if ($this->merchant) { | ||||
$query->filterByMerchant($this->merchant); | $query->filterByMerchant($this->merchant); |
} | } | ||||
// getSection | // getSection | ||||
public function getOneByDevAlias(string $devAlias): ?SectionInterface | |||||
public function getOneByDevAlias(string $devAlias, $query = null): ?SectionInterface | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query | $query | ||||
->filterByMerchant($this->merchant) | ->filterByMerchant($this->merchant) | ||||
return $section; | return $section; | ||||
} | } | ||||
public function countOpenDays(SectionInterface $section): int | |||||
public function countOpenDays(SectionInterface $section, $query = null): int | |||||
{ | { | ||||
// @TODO : à implémenter avec le nouveau système d'ouverture des commandes | // @TODO : à implémenter avec le nouveau système d'ouverture des commandes | ||||
} | } |
public function getLatests(int $maxResults = 0, $query = null): array | public function getLatests(int $maxResults = 0, $query = null): array | ||||
{ | { | ||||
if (is_null($query)) { | |||||
$query = $this->query->create(); | |||||
} | |||||
$query = $this->createQuery($query); | |||||
if ($this->section) { | |||||
$query->filterBySection($this->section); | |||||
} | |||||
$query->filterBySection($this->section); | |||||
return parent::getLatests($maxResults, $query); | return parent::getLatests($maxResults, $query); | ||||
} | } |
} | } | ||||
// findPage | // findPage | ||||
public function getOneByDevAlias(string $devAlias): ?PageInterface | |||||
public function getOneByDevAlias(string $devAlias, $query = null): ?PageInterface | |||||
{ | { | ||||
$query = $this->query->create(); | |||||
$query = $this->createQuery($query); | |||||
$query | $query | ||||
->filterIsOnline() | |||||
->filterByDevAlias($devAlias) | |||||
->filterBySection($this->section); | |||||
->filterIsOnline() | |||||
->filterByDevAlias($devAlias) | |||||
->filterBySection($this->section); | |||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } | ||||
// public function findPage($devAlias, $devAliasMerchant = false) | |||||
// { | |||||
// $merchant = false; | |||||
// | |||||
// if ($devAliasMerchant) { | |||||
// $merchant = $this->merchantUtils->getMerchantByDevAlias($devAliasMerchant); | |||||
// } | |||||
// | |||||
// if ($devAliasMerchant && $merchant) { | |||||
// $query = $this->createQueryBuilder('e') | |||||
// ->where('e.merchant = :merchant') | |||||
// ->setParameter('merchant', $merchant->getId()); | |||||
// } else { | |||||
// $query = $this->findByMerchantQuery(); | |||||
// } | |||||
// | |||||
// return $query->andWhere('e.status = 1') | |||||
// ->andWhere('e.devAlias = :devAlias') | |||||
// ->setParameter('devAlias', $devAlias) | |||||
// ->getQuery() | |||||
// ->getOneOrNullResult(); | |||||
// } | |||||
} | } |
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | |||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
class OrderShopSolver | class OrderShopSolver | ||||
return $orderShop; | return $orderShop; | ||||
} | } | ||||
public function isReductionCreditAddedToOrder( | |||||
OrderShopInterface $orderShop, | |||||
ReductionCreditInterface $reductionCredit | |||||
) { | |||||
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | |||||
if ($orderReductionCredit->getReductionCredit() == $reductionCredit) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
} | } |