|
|
|
|
|
|
|
|
use Lc\ShopBundle\Model\OrderReductionCart; |
|
|
use Lc\ShopBundle\Model\OrderReductionCart; |
|
|
use Lc\ShopBundle\Model\ProductFamily; |
|
|
use Lc\ShopBundle\Model\ProductFamily; |
|
|
use Lc\ShopBundle\Services\UserUtils; |
|
|
use Lc\ShopBundle\Services\UserUtils; |
|
|
|
|
|
use Lc\ShopBundle\Services\UtilsManager; |
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
use Symfony\Component\Routing\Generator\UrlGenerator; |
|
|
use Symfony\Component\Routing\Generator\UrlGenerator; |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
protected $orderUtils ; |
|
|
protected $orderUtils ; |
|
|
protected $userUtils ; |
|
|
protected $userUtils ; |
|
|
|
|
|
protected $priceUtils ; |
|
|
protected $router ; |
|
|
protected $router ; |
|
|
protected $productFamilyRepository ; |
|
|
protected $productFamilyRepository ; |
|
|
protected $orderProductRepository ; |
|
|
protected $orderProductRepository ; |
|
|
|
|
|
|
|
|
protected $orderProducts = [] ; |
|
|
protected $orderProducts = [] ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils, OrderUtilsInterface $orderUtils, |
|
|
|
|
|
UserUtils $userUtils, UrlGeneratorInterface $router) |
|
|
|
|
|
|
|
|
public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils, |
|
|
|
|
|
UrlGeneratorInterface $router, UtilsManager $utilsManager) |
|
|
{ |
|
|
{ |
|
|
parent::__construct($em, $security, $merchantUtils); |
|
|
parent::__construct($em, $security, $merchantUtils); |
|
|
$this->orderUtils = $orderUtils ; |
|
|
|
|
|
$this->userUtils = $userUtils ; |
|
|
|
|
|
|
|
|
$this->orderUtils = $utilsManager->getOrderUtils() ; |
|
|
|
|
|
$this->userUtils = $utilsManager->getUserUtils() ; |
|
|
|
|
|
$this->priceUtils = $utilsManager->getPriceUtils() ; |
|
|
$this->router = $router ; |
|
|
$this->router = $router ; |
|
|
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ; |
|
|
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ; |
|
|
$this->orderProductRepository = $this->em->getRepository($this->em->getClassMetaData(OrderProductInterface::class)->getName()) ; |
|
|
$this->orderProductRepository = $this->em->getRepository($this->em->getClassMetaData(OrderProductInterface::class)->getName()) ; |
|
|
|
|
|
|
|
|
&& $this->orderUtils->isReductionCreditAllowAddToOrder($orderShop, $reductionCredit) |
|
|
&& $this->orderUtils->isReductionCreditAllowAddToOrder($orderShop, $reductionCredit) |
|
|
&& !$this->orderUtils->isReductionCreditAddedToOrder($orderShop, $reductionCredit)) { |
|
|
&& !$this->orderUtils->isReductionCreditAddedToOrder($orderShop, $reductionCredit)) { |
|
|
|
|
|
|
|
|
$this->orderUtils->createOrderReductionCredit($orderShop, $reductionCredit) ; |
|
|
|
|
|
$this->addFlash('success', 'Votre avoir a bien été ajouté à votre panier.') ; |
|
|
|
|
|
|
|
|
$return = $this->orderUtils->createOrderReductionCredit($orderShop, $reductionCredit) ; |
|
|
|
|
|
|
|
|
|
|
|
if($return) { |
|
|
|
|
|
$this->addFlash('success', 'Votre avoir a bien été ajouté à votre panier.') ; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
$this->addFlash('error', 'Vous ne pouvez pas effectuer cette action. Le montant de la commande est insuffisant.') ; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
$this->addFlash('error', "Impossible d'effectuer cette action"); |
|
|
$this->addFlash('error', "Impossible d'effectuer cette action"); |