Przeglądaj źródła

OrderShopRepository : fonction de récupération du panier courant

feature/export_comptable
Guillaume 4 lat temu
rodzic
commit
f8c8197980
2 zmienionych plików z 21 dodań i 2 usunięć
  1. +18
    -0
      ShopBundle/Repository/OrderShopRepository.php
  2. +3
    -2
      ShopBundle/Services/OrderUtils.php

+ 18
- 0
ShopBundle/Repository/OrderShopRepository.php Wyświetl plik

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


public function findCurrent($params)
{
$query = $this->createQueryBuilder('e') ;

if(isset($params['user'])) {
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ;
}

if(isset($params['visitor'])) {
$query->andWhere('e.visitor = :visitor')->setParameter('visitor', $params['visitor']) ;
}

$query->leftJoin('e.orderStatusHistories', 'orderStatusHistories')
->andWhere('SIZE(e.orderStatusHistories) = 0') ;

return $query->getQuery()->getOneOrNullResult() ;
}

} }

+ 3
- 2
ShopBundle/Services/OrderUtils.php Wyświetl plik

use App\Entity\OrderShop; use App\Entity\OrderShop;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface; use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;


$this->security = $security; $this->security = $security;
$this->userUtils = $userUtils; $this->userUtils = $userUtils;
$this->merchantUtils = $merchantUtils; $this->merchantUtils = $merchantUtils;
$this->orderShopRepo = $this->em->getRepository(OrderShop::class);
$this->orderShopRepo = $this->em->getRepository($this->em->getClassMetadata(OrderShopInterface::class)->getName());
$this->priceUtils = $priceUtils ; $this->priceUtils = $priceUtils ;
$this->productFamilyUtils = $productFamilyUtils ; $this->productFamilyUtils = $productFamilyUtils ;
} }
$paramsSearchOrderShop['visitor'] = $visitor; $paramsSearchOrderShop['visitor'] = $visitor;
} }


$orderShop = $this->orderShopRepo->findOneBy($paramsSearchOrderShop);
$orderShop = $this->orderShopRepo->findCurrent($paramsSearchOrderShop);


if (!$orderShop) { if (!$orderShop) {
$orderShop = $this->createOrderShop([ $orderShop = $this->createOrderShop([

Ładowanie…
Anuluj
Zapisz