Parcourir la source

OrderShopRepository : ajout param isWaitingDelivery

feature/export_comptable
Guillaume il y a 4 ans
Parent
révision
77891e29ca
2 fichiers modifiés avec 20 ajouts et 7 suppressions
  1. +5
    -0
      ShopBundle/Model/OrderStatus.php
  2. +15
    -7
      ShopBundle/Repository/OrderShopRepository.php

+ 5
- 0
ShopBundle/Model/OrderStatus.php Voir le fichier

@@ -37,6 +37,11 @@ abstract class OrderStatus
self::ALIAS_DONE
] ;

static $statusAliasWaitingDelivery = [
self::ALIAS_WAITING_DELIVERY,
self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
];

static $statusAliasAsCart = [
self::ALIAS_CART,
self::ALIAS_WAITING_PAYMENT_ONLINE,

+ 15
- 7
ShopBundle/Repository/OrderShopRepository.php Voir le fichier

@@ -65,20 +65,24 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt

public function filterOrderValid(?QueryBuilder $query): QueryBuilder
{
$query->leftJoin('e.orderStatus', 'os');
$query->andWhere('os.alias IN (:alias)');
$query->setParameter('alias', OrderStatus::$statusAliasAsValid);
return $this->_filterOrderStatus($query, OrderStatus::$statusAliasAsValid) ;
}

return $query;
public function filterOrderWaitingDelivery($query)
{
return $this->_filterOrderStatus($query, OrderStatus::$statusAliasWaitingDelivery) ;
}

public function filterOrderCart($query)
{
return $this->_filterOrderStatus($query, OrderStatus::$statusAliasAsCart) ;
}

private function _filterOrderStatus($query, $statusArray) {
$query->leftJoin('e.orderStatus', 'os');
$query->andWhere('os.alias IN (:alias)');
$query->setParameter('alias', OrderStatus::$statusAliasAsCart);

return $query;
$query->setParameter('alias',$statusArray);
return $query ;
}

public function findCartCurrent($params)
@@ -139,6 +143,10 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query = $this->filterOrderValid($query);
}

if (isset($params['isWaitingDelivery'])) {
$query = $this->filterOrderWaitingDelivery($query);
}

if (isset($params['orderStatus'])) {
$query->leftJoin('e.orderStatus', 'os');
$query->andWhere('os.alias LIKE :alias');

Chargement…
Annuler
Enregistrer