Procházet zdrojové kódy

CreditUtils

feature/export_comptable
Guillaume před 4 roky
rodič
revize
95e632726c
1 změnil soubory, kde provedl 74 přidání a 0 odebrání
  1. +74
    -0
      ShopBundle/Services/CreditUtils.php

+ 74
- 0
ShopBundle/Services/CreditUtils.php Zobrazit soubor

@@ -0,0 +1,74 @@
<?php

namespace Lc\ShopBundle\Services ;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Context\UserMerchantInterface;

class CreditUtils
{
protected $em ;
protected $merchantUtils ;
protected $userMerchantRepository ;

public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils)
{
$this->em = $em ;
$this->merchantUtils = $merchantUtils ;
$this->userMerchantRepository = $this->em->getRepository($this->em->getClassMetadata(UserMerchantInterface::class)->getName()) ;
}

public function getUserMerchant(UserInterface $user, MerchantInterface $merchant = null)
{
$merchant = $this->getMerchant($merchant) ;
$userMerchant = $this->userMerchantRepository->findOneBy([
'user' => $user,
'merchant' => $merchant
]) ;
return $userMerchant ;
}

public function createUserMerchant(UserInterface $user, MerchantInterface $merchant = null)
{
$merchant = $this->getMerchant($merchant) ;
$classUserMerchant = $this->em->getClassMetadata(UserMerchantInterface::class)->getName();
$userMerchant = new $classUserMerchant ;
$userMerchant->setUser($user) ;
$userMerchant->setMerchant($merchant) ;
$userMerchant->setCredit(0) ;
$userMerchant->setCreditActive(true) ;
return $userMerchant ;
}

public function createCreditHistory($user, $amount, $meanPayment, $comment = null, $merchant = null)
{
$merchant = $this->getMerchant($merchant) ;
}

public function addCredit($user, $amount, $merchant = null)
{
$merchant = $this->getMerchant($merchant) ;
}
public function removeCredit($user, $amount, $merchant = null)
{
$merchant = $this->getMerchant($merchant) ;
}

public function setCredit($user, $amount, $merchant = null)
{

}

public function getMerchant($merchant)
{
if(!$merchant) {
$merchant = $this->merchantUtils->getMerchantCurrent() ;
}

return $merchant ;
}
}

Načítá se…
Zrušit
Uložit