Pārlūkot izejas kodu

OrderShopRepository : filterIsOffCircuit

feature/export_comptable
Guillaume pirms 4 gadiem
vecāks
revīzija
2831edf050
1 mainītis faili ar 35 papildinājumiem un 5 dzēšanām
  1. +35
    -5
      ShopBundle/Repository/OrderShopRepository.php

+ 35
- 5
ShopBundle/Repository/OrderShopRepository.php Parādīt failu

@@ -81,6 +81,18 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
return $query;
}

public function filterIsOffCircuit($query, $isOffCircuit)
{
if($isOffCircuit) {
$query->andWhere('e.isOffCircuit = 1') ;
}
else {
$query->andWhere('e.isOffCircuit IS NULL OR e.isOffCircuit = 0') ;
}

return $query ;
}

public function findCartCurrent($params)
{
$query = $this->findByMerchantQuery() ;
@@ -139,17 +151,34 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ;
}

$query->orderBy('e.id', 'DESC') ;
if(isset($params['isOffCircuit'])) {
$query = $this->filterIsOffCircuit($query, true) ;
}

if(isset($params['isCircuit'])) {
$query = $this->filterIsOffCircuit($query, false) ;
$query->leftJoin('e.deliveryPointSale', 'pointSale') ;
$query->andWhere('e.deliveryPointSale IS NULL OR pointSale.isDepository = 0') ;
}

if(isset($params['isDepository'])) {
$query = $this->filterIsOffCircuit($query, false) ;
$query->innerJoin('e.deliveryPointSale', 'pointSale') ;
$query->andWhere('pointSale.isDepository = 1') ;
}

if(isset($params['orderBy'])) {
$query->orderBy('e.'.$params['orderBy'], isset($params['orderByDirection']) ? $params['orderByDirection'] : 'DESC') ;
}
else {
$query->orderBy('e.id', 'DESC') ;
}

$query->leftJoin('e.deliveryAvailabilityZone', 'deliveryAvailabilityZone') ;
$query->leftJoin('deliveryAvailabilityZone.deliverySlot', 'deliverySlotZone') ;
$query->addOrderBy('deliverySlotZone.day', 'ASC') ;
$query->addOrderBy('deliverySlotZone.timeStart', 'ASC') ;

$query->leftJoin('e.deliveryAvailabilityPointSale', 'deliveryAvailabilityPointSale') ;
$query->leftJoin('deliveryAvailabilityPointSale.deliverySlot', 'deliverySlotPointSale') ;
$query->addOrderBy('deliverySlotPointSale.day', 'ASC') ;
$query->addOrderBy('deliverySlotPointSale.timeStart', 'ASC') ;

if(isset($params['count']) && $params['count']) {
return $query->getQuery()->getSingleScalarResult();
@@ -165,6 +194,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query->andWhere('e.weekNumber = :weekNumber');
$query->setParameter('weekNumber', $weekNumber);
$query->orderBy('e.validationDate','DESC');
$query->setMaxResults(1);

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


Notiek ielāde…
Atcelt
Saglabāt