Переглянути джерело

Processus de commandes

feature/export_comptable
Fab 4 роки тому
джерело
коміт
b86888afe2
2 змінених файлів з 20 додано та 15 видалено
  1. +18
    -13
      ShopBundle/Repository/OrderShopRepository.php
  2. +2
    -2
      ShopBundle/Services/OrderUtils.php

+ 18
- 13
ShopBundle/Repository/OrderShopRepository.php Переглянути файл

@@ -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()
}

+ 2
- 2
ShopBundle/Services/OrderUtils.php Переглянути файл

@@ -344,7 +344,7 @@ class OrderUtils

public function isReductionCreditAllowToBeAddToOrder($orderShop, $reductionCredit){

if($this->orderShopRepo->getValidOrderWithReductionCredit($reductionCredit, $orderShop->getUser())>0){
if($this->orderShopRepo->findValidOrderWithReductionCredit($reductionCredit, $orderShop->getUser())>0){
return false;
}else{
return true;
@@ -432,4 +432,4 @@ class OrderUtils
return $orderProductsByProductFamily ;
}

}
}

Завантаження…
Відмінити
Зберегти