浏览代码

ReductionCredit

feature/export_comptable
Guillaume 4 年前
父节点
当前提交
0e473144ee
共有 4 个文件被更改,包括 25 次插入6 次删除
  1. +1
    -1
      ShopBundle/Form/Backend/Order/OrderReductionCreditType.php
  2. +6
    -4
      ShopBundle/Repository/ReductionCreditRepository.php
  3. +17
    -0
      ShopBundle/Services/OrderUtils.php
  4. +1
    -1
      ShopBundle/Services/OrderUtilsReductionTrait.php

+ 1
- 1
ShopBundle/Form/Backend/Order/OrderReductionCreditType.php 查看文件

@@ -42,7 +42,7 @@ class OrderReductionCreditType extends AbstractType
$builder
->add('reductionCredit', EntityType::class, array(
'class' => $reductionCreditClass->getName(),
'choices' => $reductionCreditRepo->getReductionCreditByUser($entity->getUser()),
'choices' => $reductionCreditRepo->findReductionCreditsByUser($entity->getUser()),
//'choices' => $this->orderUtils->getReductionCreditsAvailable($entity),

'required' => true,

+ 6
- 4
ShopBundle/Repository/ReductionCreditRepository.php 查看文件

@@ -2,7 +2,9 @@

namespace Lc\ShopBundle\Repository;

use Doctrine\ORM\EntityManager;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;

/**
@@ -13,19 +15,19 @@ use Lc\ShopBundle\Context\ReductionCreditInterface;
*/
class ReductionCreditRepository extends BaseRepository implements DefaultRepositoryInterface
{

public function getInterfaceClass()
{
return ReductionCreditInterface::class;
}

public function getReductionCreditByUser($user){

public function findReductionCreditsByUser($user)
{
$query = $this->findByMerchantQuery() ;
$query->andWhere('e.status = 1');
$query->andWhere(':user MEMBER OF e.users');
$query->setParameter('user', $user);
return $query->getQuery()->getResult() ;

}


}

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

@@ -34,6 +34,7 @@ class OrderUtils
protected $userUtils;
protected $merchantUtils;
protected $orderShopRepo;
protected $reductionCreditRepo ;
protected $priceUtils;
protected $productFamilyUtils;
protected $documentUtils;
@@ -48,6 +49,7 @@ class OrderUtils
$this->userUtils = $userUtils;
$this->merchantUtils = $merchantUtils;
$this->orderShopRepo = $this->em->getRepository($this->em->getClassMetadata(OrderShopInterface::class)->getName());
$this->reductionCreditRepo = $this->em->getRepository($this->em->getClassMetadata(ReductionCreditInterface::class)->getName());
$this->priceUtils = $priceUtils;
$this->productFamilyUtils = $productFamilyUtils;
$this->documentUtils = $documentUtils;
@@ -456,4 +458,19 @@ class OrderUtils
public function isCartAllowToBeOrder($order){
return true;
}

public function getReductionCreditsAvailableByUser($user)
{
$reductionCredits = $this->reductionCreditRepo->findReductionCreditsByUser($user) ;

$reductionCreditsArray = [] ;
foreach($reductionCredits as $reductionCredit) {
if(!$this->orderShopRepo->countValidOrderWithReductionCredit($reductionCredit, $user)) {
$reductionCreditsArray[] = $reductionCredit ;
}
}

return $reductionCreditsArray ;
}

}

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

@@ -77,7 +77,7 @@ trait OrderUtilsReductionTrait
return $orderReductionCart;
}

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

if ($this->orderShopRepo->countValidOrderWithReductionCredit($reductionCredit, $orderShop->getUser()) > 0) {

正在加载...
取消
保存