|
|
@@ -22,10 +22,12 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt |
|
|
|
|
|
|
|
//TODO : AJOUTER un champ valid ds orderSTATUS |
|
|
|
protected $statusAliasAsValid = array('paid-online', 'paid-by-credit', 'waiting-delivery', 'waiting-delivery-with-payment', 'delivered-without-payment', 'done'); |
|
|
|
protected $statusAliasAsCard = array('cart', 'wainting-payment-online', 'wainting-payment-credit', 'wainting-payment-on-delivery', 'error-payment-online'); |
|
|
|
|
|
|
|
|
|
|
|
public function getValidOrderWithReductionCredit($reductionCredit, $user){ |
|
|
|
$query = $this->findValidOrderQuery(); |
|
|
|
public function findValidOrderWithReductionCredit($reductionCredit, $user){ |
|
|
|
$query = $this->findByMerchantQuery(); |
|
|
|
$query = $this->filterOrderValid($query); |
|
|
|
$query->andWhere('e.user = :user'); |
|
|
|
$query->leftJoin('e.orderReductionCredits', 'orc'); |
|
|
|
$query->andWhere('orc.reductionCredit = :reductionCredit'); |
|
|
@@ -35,8 +37,8 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function findValidOrderQuery(){ |
|
|
|
$query = $this->findByMerchantQuery(); |
|
|
|
public function filterOrderValid($query){ |
|
|
|
|
|
|
|
$query->leftJoin('e.orderStatus', 'os'); |
|
|
|
$query->andWhere('os.alias IN (:alias)'); |
|
|
|
$query->setParameter('alias', $this->statusAliasAsValid); |
|
|
@@ -44,6 +46,15 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt |
|
|
|
return $query; |
|
|
|
} |
|
|
|
|
|
|
|
public function filterOrderCart($query) |
|
|
|
{ |
|
|
|
$query->leftJoin('e.orderStatus', 'os'); |
|
|
|
$query->andWhere('os.alias IN (:alias)'); |
|
|
|
$query->setParameter('alias', $this->statusAliasAsCard); |
|
|
|
|
|
|
|
return $query; |
|
|
|
} |
|
|
|
|
|
|
|
public function findCartCurrent($params) |
|
|
|
{ |
|
|
|
$query = $this->findByMerchantQuery() ; |
|
|
@@ -56,7 +67,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt |
|
|
|
$query->andWhere('e.visitor = :visitor')->setParameter('visitor', $params['visitor']) ; |
|
|
|
} |
|
|
|
|
|
|
|
$this->filterOrderCart($query, true) ; |
|
|
|
$this->filterOrderCart($query, true); |
|
|
|
|
|
|
|
$query->leftJoin('e.orderReductionCarts', 'orderReductionCarts') |
|
|
|
->addSelect('orderReductionCarts'); |
|
|
@@ -66,7 +77,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt |
|
|
|
if($results) { |
|
|
|
return $results[0] ; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null ; |
|
|
|
} |
|
|
|
|
|
|
@@ -118,13 +129,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt |
|
|
|
return $query->getQuery()->getResult() ; |
|
|
|
} |
|
|
|
|
|
|
|
public function filterOrderCart($query, $isCart = false) |
|
|
|
{ |
|
|
|
$operator = $isCart ? '=' : '!=' ; |
|
|
|
return $query->leftJoin('e.orderStatus', 'orderStatus') |
|
|
|
->andWhere('orderStatus.alias '.$operator.' :orderStatus') |
|
|
|
->setParameter('orderStatus', 'cart'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//getValidOrders() |
|
|
|
} |