Browse Source

Processus de commande

feature/export_comptable
Fab 4 years ago
parent
commit
d911e4a41f
4 changed files with 41 additions and 4 deletions
  1. +14
    -0
      ShopBundle/Model/AbstractEntity.php
  2. +25
    -2
      ShopBundle/Repository/OrderShopRepository.php
  3. +1
    -1
      ShopBundle/Services/OrderUtils.php
  4. +1
    -1
      ShopBundle/Services/OrderUtilsReductionTrait.php

+ 14
- 0
ShopBundle/Model/AbstractEntity.php View File

*/ */
abstract class AbstractEntity abstract class AbstractEntity
{ {
protected $errors;


/** /**
* @ORM\Column(type="datetime") * @ORM\Column(type="datetime")
*/ */
protected $updatedBy; protected $updatedBy;



public function addError($message, $domain = 'lcshop', $params){
$this->errors[] = array(
'message'=> $message,
'domain'=> $domain,
'params'=>$params
);
return $this->errors;
}
public function getErrors(){
return $this->errors;
}

public function getCreatedAt(): ?\DateTimeInterface public function getCreatedAt(): ?\DateTimeInterface
{ {
return $this->createdAt; return $this->createdAt;

+ 25
- 2
ShopBundle/Repository/OrderShopRepository.php View File

protected $statusAliasAsCart = array('cart', 'waiting-payment-online', 'waiting-payment-credit', 'waiting-payment-on-delivery', 'error-payment-online'); protected $statusAliasAsCart = array('cart', 'waiting-payment-online', 'waiting-payment-credit', 'waiting-payment-on-delivery', 'error-payment-online');




public function findValidOrderWithReductionCredit($reductionCredit, $user){
public function countValidOrderWithReductionCredit($reductionCredit, $user){
$query = $this->findByMerchantQuery(); $query = $this->findByMerchantQuery();
$query = $this->filterOrderValid($query); $query = $this->filterOrderValid($query);
$query->andWhere('e.user = :user'); $query->andWhere('e.user = :user');
$query->andWhere('orc.reductionCredit = :reductionCredit'); $query->andWhere('orc.reductionCredit = :reductionCredit');
$query->setParameter('reductionCredit', $reductionCredit); $query->setParameter('reductionCredit', $reductionCredit);
$query->setParameter('user', $user); $query->setParameter('user', $user);
return $query->getQuery()->getResult();
return $query->getQuery()->getScalarResult();
}


public function countValidOrderWithReductionCart($reductionCart){
$query = $this->findByMerchantQuery();
$query = $this->filterOrderValid($query);
$query->leftJoin('e.orderReductionCart', 'orc');
$query->andWhere('orc.reductionCart = :reductionCart');
$query->setParameter('reductionCart', $reductionCart);
return $query->getQuery()->getScalarResult();
}


public function countValidOrderWithReductionCartPerUser($reductionCart, $user){
$query = $this->findByMerchantQuery();
$query = $this->filterOrderValid($query);
$query->andWhere('e.user = :user');
$query->leftJoin('e.orderReductionCart', 'orc');
$query->andWhere('orc.reductionCart = :reductionCart');
$query->setParameter('reductionCart', $reductionCart);
$query->setParameter('user', $user);
return $query->getQuery()->getScalarResult();
} }




{ {
$query = $this->findByMerchantQuery() ; $query = $this->findByMerchantQuery() ;



if(isset($params['user'])) { if(isset($params['user'])) {
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ; $query->andWhere('e.user = :user')->setParameter('user', $params['user']) ;
} }

+ 1
- 1
ShopBundle/Services/OrderUtils.php View File

if ($this->getTotalOrderPayments($order) >= $this->priceUtils->getTotalWithTaxAndReduction($order)) { if ($this->getTotalOrderPayments($order) >= $this->priceUtils->getTotalWithTaxAndReduction($order)) {
return true; return true;
} else { } else {
$order->changeStatusError[] = 'field.error.orderStatus.noPayment';
$order->editError[] = 'field.error.orderStatus.noPayment';
return false; return false;
} }
} }

+ 1
- 1
ShopBundle/Services/OrderUtilsReductionTrait.php View File



public function isReductionCreditAllowToBeAddToOrder($orderShop, $reductionCredit){ public function isReductionCreditAllowToBeAddToOrder($orderShop, $reductionCredit){


if($this->orderShopRepo->findValidOrderWithReductionCredit($reductionCredit, $orderShop->getUser())>0){
if($this->orderShopRepo->countValidOrderWithReductionCredit($reductionCredit, $orderShop->getUser())>0){
return false; return false;
}else{ }else{
return true; return true;

Loading…
Cancel
Save