|
|
|
|
|
|
|
|
return $query; |
|
|
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) |
|
|
public function findCartCurrent($params) |
|
|
{ |
|
|
{ |
|
|
$query = $this->findByMerchantQuery() ; |
|
|
$query = $this->findByMerchantQuery() ; |
|
|
|
|
|
|
|
|
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ; |
|
|
$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('e.deliveryAvailabilityZone', 'deliveryAvailabilityZone') ; |
|
|
$query->leftJoin('deliveryAvailabilityZone.deliverySlot', 'deliverySlotZone') ; |
|
|
$query->leftJoin('deliveryAvailabilityZone.deliverySlot', 'deliverySlotZone') ; |
|
|
$query->addOrderBy('deliverySlotZone.day', 'ASC') ; |
|
|
|
|
|
$query->addOrderBy('deliverySlotZone.timeStart', 'ASC') ; |
|
|
|
|
|
|
|
|
|
|
|
$query->leftJoin('e.deliveryAvailabilityPointSale', 'deliveryAvailabilityPointSale') ; |
|
|
$query->leftJoin('e.deliveryAvailabilityPointSale', 'deliveryAvailabilityPointSale') ; |
|
|
$query->leftJoin('deliveryAvailabilityPointSale.deliverySlot', 'deliverySlotPointSale') ; |
|
|
$query->leftJoin('deliveryAvailabilityPointSale.deliverySlot', 'deliverySlotPointSale') ; |
|
|
$query->addOrderBy('deliverySlotPointSale.day', 'ASC') ; |
|
|
|
|
|
$query->addOrderBy('deliverySlotPointSale.timeStart', 'ASC') ; |
|
|
|
|
|
|
|
|
|
|
|
if(isset($params['count']) && $params['count']) { |
|
|
if(isset($params['count']) && $params['count']) { |
|
|
return $query->getQuery()->getSingleScalarResult(); |
|
|
return $query->getQuery()->getSingleScalarResult(); |
|
|
|
|
|
|
|
|
$query->andWhere('e.weekNumber = :weekNumber'); |
|
|
$query->andWhere('e.weekNumber = :weekNumber'); |
|
|
$query->setParameter('weekNumber', $weekNumber); |
|
|
$query->setParameter('weekNumber', $weekNumber); |
|
|
$query->orderBy('e.validationDate','DESC'); |
|
|
$query->orderBy('e.validationDate','DESC'); |
|
|
|
|
|
$query->setMaxResults(1); |
|
|
|
|
|
|
|
|
return $query->getQuery()->getOneOrNullResult(); |
|
|
return $query->getQuery()->getOneOrNullResult(); |
|
|
|
|
|
|