Browse Source

OrderShopRepository : ajout param isWaitingDelivery

feature/export_comptable
Guillaume 4 years ago
parent
commit
77891e29ca
2 changed files with 20 additions and 7 deletions
  1. +5
    -0
      ShopBundle/Model/OrderStatus.php
  2. +15
    -7
      ShopBundle/Repository/OrderShopRepository.php

+ 5
- 0
ShopBundle/Model/OrderStatus.php View File

self::ALIAS_DONE self::ALIAS_DONE
] ; ] ;


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

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

+ 15
- 7
ShopBundle/Repository/OrderShopRepository.php View File



public function filterOrderValid(?QueryBuilder $query): QueryBuilder 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) public function filterOrderCart($query)
{ {
return $this->_filterOrderStatus($query, OrderStatus::$statusAliasAsCart) ;
}

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

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


public function findCartCurrent($params) public function findCartCurrent($params)
$query = $this->filterOrderValid($query); $query = $this->filterOrderValid($query);
} }


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

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

Loading…
Cancel
Save