Procházet zdrojové kódy

Modèles CreditHistory / UserMerchant

feature/export_comptable
Guillaume před 4 roky
rodič
revize
cade87997d
5 změnil soubory, kde provedl 152 přidání a 61 odebrání
  1. +8
    -0
      ShopBundle/Context/UserMerchantInterface.php
  2. +7
    -60
      ShopBundle/Model/CreditHistory.php
  3. +5
    -1
      ShopBundle/Model/User.php
  4. +110
    -0
      ShopBundle/Model/UserMerchant.php
  5. +22
    -0
      ShopBundle/Repository/UserMerchantRepository.php

+ 8
- 0
ShopBundle/Context/UserMerchantInterface.php Zobrazit soubor

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

namespace Lc\ShopBundle\Context;

interface UserMerchantInterface
{

}

+ 7
- 60
ShopBundle/Model/CreditHistory.php Zobrazit soubor

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

namespace Lc\ShopBundle\Model;

use App\Entity\OrderShop;
use App\Entity\UserMerchant;
use Doctrine\ORM\Mapping as ORM;

/**
@@ -10,28 +10,11 @@ use Doctrine\ORM\Mapping as ORM;
*/
abstract class CreditHistory extends AbstractEntity
{
/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="creditHistories")
* @ORM\JoinColumn(nullable=false)
*/
protected $user;

/**
* @ORM\Column(type="float")
*/
protected $amount;

/**
* @ORM\Column(type="string", length=31)
*/
protected $type;

/**
* @ORM\Column(type="string", length=31)
*/
@@ -43,34 +26,10 @@ abstract class CreditHistory extends AbstractEntity
protected $comment;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="creditHistories")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserLerchantInterface", inversedBy="creditHistories")
* @ORM\JoinColumn(nullable=false)
*/
protected $orderShop;

public function getMerchant(): ?Merchant
{
return $this->merchant;
}

public function setMerchant(?Merchant $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getUser(): ?User
{
return $this->user;
}

public function setUser(?User $user): self
{
$this->user = $user;

return $this;
}
protected $userMerchant;

public function getAmount(): ?float
{
@@ -84,18 +43,6 @@ abstract class CreditHistory extends AbstractEntity
return $this;
}

public function getType(): ?string
{
return $this->type;
}

public function setType(string $type): self
{
$this->type = $type;

return $this;
}

public function getMeanPayment(): ?string
{
return $this->meanPayment;
@@ -120,14 +67,14 @@ abstract class CreditHistory extends AbstractEntity
return $this;
}

public function getOrderShop(): ?OrderShop
public function getUserMerchant(): ?UserMerchant
{
return $this->orderShop;
return $this->userMerchant;
}

public function setOrderShop(?OrderShop $orderShop): self
public function setUserMerchant(?UserMerchant $userMerchant): self
{
$this->orderShop = $orderShop;
$this->userMerchant = $userMerchant;

return $this;
}

+ 5
- 1
ShopBundle/Model/User.php Zobrazit soubor

@@ -82,6 +82,10 @@ abstract class User extends UserModelFOS
*/
protected $userPointSales;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\UserMerchantInterface", mappedBy="user", orphanRemoval=true)
*/
protected $userMerchants;

public function __construct()
{
@@ -93,9 +97,9 @@ abstract class User extends UserModelFOS
$this->newsletters = new ArrayCollection();
$this->favoriteProductFamilies = new ArrayCollection();
$this->userPointSales = new ArrayCollection();
$this->userMerchants = new ArrayCollection();
}


public function getSummary()
{
return strtoupper($this->getLastname()).' '.$this->getFirstname(). ' ('.$this->getEmail().')';

+ 110
- 0
ShopBundle/Model/UserMerchant.php Zobrazit soubor

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

namespace Lc\ShopBundle\Model;

use App\Entity\CreditHistory;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\CreditHistoryInterface;

/**
* @ORM\MappedSuperclass()
*
*/
abstract class UserMerchant
{
/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="userMerchants")
* @ORM\JoinColumn(nullable=false)
*/
protected $user;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\Column(type="float")
*/
protected $credit ;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="userMerchant", orphanRemoval=true)
*/
protected $creditHistories;

public function __construct()
{
$this->creditHistories = new ArrayCollection();
}

public function getUser(): ?User
{
return $this->user;
}

public function setUser(?User $user): self
{
$this->user = $user;

return $this;
}

public function getMerchant(): ?Hub
{
return $this->merchant;
}

public function setMerchant(?Hub $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getCredit(): ?float
{
return $this->credit;
}

public function setCredit(float $credit): self
{
$this->credit = $credit;

return $this;
}

/**
* @return Collection|CreditHistory[]
*/
public function getCreditHistories(): Collection
{
return $this->creditHistories;
}

public function addCreditHistory(CreditHistoryInterface $creditHistory): self
{
if (!$this->creditHistories->contains($creditHistory)) {
$this->creditHistories[] = $creditHistory;
$creditHistory->setUserMerchant($this);
}

return $this;
}

public function removeCreditHistory(CreditHistoryInterface $creditHistory): self
{
if ($this->creditHistories->contains($creditHistory)) {
$this->creditHistories->removeElement($creditHistory);
// set the owning side to null (unless already changed)
if ($creditHistory->getUserMerchant() === $this) {
$creditHistory->setUserMerchant(null);
}
}

return $this;
}
}

+ 22
- 0
ShopBundle/Repository/UserMerchantRepository.php Zobrazit soubor

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

namespace Lc\ShopBundle\Repository;

use App\Entity\UserMerchant;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Repository\BaseRepository;

/**
* @method UserMerchant|null find($id, $lockMode = null, $lockVersion = null)
* @method UserMerchant|null findOneBy(array $criteria, array $orderBy = null)
* @method UserMerchant[] findAll()
* @method UserMerchant[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class UserMerchantRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return UserMerchant::class;
}
}


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