浏览代码

Processus de commande

feature/export_comptable
Fab 4 年前
父节点
当前提交
d911e4a41f
共有 4 个文件被更改,包括 41 次插入4 次删除
  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 查看文件

@@ -11,6 +11,7 @@ use Lc\ShopBundle\Context\UserInterface;
*/
abstract class AbstractEntity
{
protected $errors;

/**
* @ORM\Column(type="datetime")
@@ -38,6 +39,19 @@ abstract class AbstractEntity
*/
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
{
return $this->createdAt;

+ 25
- 2
ShopBundle/Repository/OrderShopRepository.php 查看文件

@@ -25,7 +25,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
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->filterOrderValid($query);
$query->andWhere('e.user = :user');
@@ -33,7 +33,29 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query->andWhere('orc.reductionCredit = :reductionCredit');
$query->setParameter('reductionCredit', $reductionCredit);
$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();
}


@@ -59,6 +81,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
{
$query = $this->findByMerchantQuery() ;


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

+ 1
- 1
ShopBundle/Services/OrderUtils.php 查看文件

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

+ 1
- 1
ShopBundle/Services/OrderUtilsReductionTrait.php 查看文件

@@ -78,7 +78,7 @@ trait OrderUtilsReductionTrait

public function isReductionCreditAllowToBeAddToOrder($orderShop, $reductionCredit){

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

正在加载...
取消
保存