src/Entity/Retiros.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\DBAL\Types\Types;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\RetirosRepository;
  6. /**
  7.  * Retiros
  8.  *
  9.  * @ORM\Table(name="retiros")
  10.  * @ORM\Entity
  11.  */
  12. #[ORM\Entity(repositoryClassRetirosRepository::class)]
  13. class Retiros implements \Serializable 
  14. {
  15.     public const CREATED 0;
  16.     public const VALIDATED 1;
  17.     public const DENIED 2;
  18.     public const TYPE_NORMAL 1;
  19.     public const TYPE_ANTICPATED 2;
  20.      const REQUEST_STATUS = [
  21.         'created' => self::CREATED,
  22.         'validated' => self::VALIDATED,
  23.         'denied' => self::DENIED
  24.     ];
  25.     public const TRANSFERT_CRYPTO 1;
  26.     public const TRANSFERT_BANK 2;
  27.     /**
  28.      * @var int
  29.      *
  30.      * @ORM\Column(name="ID", type="integer", nullable=false)
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue(strategy="IDENTITY")
  33.      */
  34.     #[ORM\Id]
  35.     #[ORM\GeneratedValue]
  36.     #[ORM\Column(type'integer')]
  37.     private $id;
  38.     /**
  39.      * @var int|null
  40.      *
  41.      * @ORM\Column(name="user_id", type="integer", nullable=true)
  42.      */
  43.     #[ORM\Column(type'integer',nullable:true)]
  44.     private $userId;
  45.     /**
  46.      * @var string|null
  47.      *
  48.      * @ORM\Column(name="wallet", type="string", length=300, nullable=true)
  49.      */
  50.     #[ORM\Column(type'string',length:300,nullable:true)]
  51.     private $wallet;
  52.     /**
  53.      * @var \DateTime|null
  54.      *
  55.      * @ORM\Column(name="fecha", type="datetime", nullable=true)
  56.      */
  57.     #[ORM\Column(type'datetime',nullable:true)]
  58.     private $fecha;
  59.     /**
  60.      * @var float|null
  61.      *
  62.      * @ORM\Column(name="value", type="float", precision=10, scale=0, nullable=true)
  63.      */
  64.     //montant du retrait réel
  65.     #[ORM\Column(type'float',precision:10,scale:0,nullable:true)]
  66.     private $value;
  67.     //montant du retrait demandé
  68.     #[ORM\Column(type'float',precision:10,scale:0,nullable:true)]
  69.     private $montantDemande;
  70.     /**
  71.      * @var string|null
  72.      *
  73.      * @ORM\Column(name="hash", type="string", length=300, nullable=true)
  74.      */
  75.     #[ORM\Column(type'string',length:300,nullable:true)]
  76.     private $hash;
  77.     /**
  78.      * @var int|null
  79.      *
  80.      * @ORM\Column(name="state", type="integer", nullable=true)
  81.      */
  82.     #[ORM\Column(type'integer',nullable:true)]
  83.     private $state self::CREATED;
  84.     #[ORM\Column(type'string',length:300,nullable:true)]
  85.     private $note;
  86.     #[ORM\ManyToOne(targetEntityUsers::class)]
  87.     #[ORM\JoinColumnnullablefalse)]
  88.     private $user;
  89.     #[ORM\ManyToOne(targetEntityLicenciasUser::class)]
  90.     #[ORM\JoinColumnnullabletrue)]
  91.     private $pack;
  92.     #[ORM\Column(type'datetime',nullable:true)]
  93.     private $validationDate;
  94.     #[ORM\Column(type'integer',nullable:true,options: ['default' => self::TYPE_NORMAL ])]
  95.     private $type self::TYPE_NORMAL;
  96.     #[ORM\Column(type'float',precision:10,scale:0,nullable:true)]
  97.     private $fee;
  98.     #[ORM\Column(type'string',length:200,unique:false,nullable:true)]
  99.     private $document;
  100.     #[ORM\Column(type'float',precision:10,scale:0,nullable:true)]
  101.     private $amountWithCurrency;
  102.     #[ORM\Column(type'string',length:30,options: ['default' => "USDC"])]
  103.     private $currencyOfTransaction "USDC";
  104.     #[ORM\Column(type'boolean',nullable:trueoptions: ['default' => true])]
  105.     private $wasNotificationSentByMail true;
  106.     #[ORM\Column(type'integer',nullable:true,options: ['default' =>self::TRANSFERT_CRYPTO])]
  107.     private $transfertMode self::TRANSFERT_CRYPTO;
  108.     #[ORM\Column(type'string'length255nullable:true)]
  109.     private $iban
  110.     #[ORM\Column(type'string'length255nullable:true)]
  111.     private $swift
  112.     #[ORM\Column(type'string'length255nullable:true)]
  113.     private $banque;
  114.     #[ORM\Column(length255nullabletrue)]
  115.     private ?string $beneficiaire null
  116.     public function getId(): ?int
  117.     {
  118.         return $this->id;
  119.     }
  120.     public function getUserId(): ?int
  121.     {
  122.         return $this->userId;
  123.     }
  124.     public function setUserId(?int $userId): static
  125.     {
  126.         $this->userId $userId;
  127.         return $this;
  128.     }
  129.     public function getWallet(): ?string
  130.     {
  131.         return $this->wallet;
  132.     }
  133.     public function setWallet(?string $wallet): static
  134.     {
  135.         $this->wallet $wallet;
  136.         return $this;
  137.     }
  138.     public function getFecha(): ?\DateTimeInterface
  139.     {
  140.         return $this->fecha;
  141.     }
  142.     public function setFecha(?\DateTimeInterface $fecha): static
  143.     {
  144.         $this->fecha $fecha;
  145.         return $this;
  146.     }
  147.     public function getValue(): ?float
  148.     {
  149.         return $this->value;
  150.     }
  151.     public function setValue($value): static
  152.     {
  153.         UsefulEntity::IsPositif($value,"valeur réel");
  154.         $montantDemande=$this->montantDemande!=null?$this->montantDemande:0;
  155.         $this->value $value;
  156.         return $this;
  157.     }
  158.     public function getHash(): ?string
  159.     {
  160.         return $this->hash;
  161.     }
  162.     public function setHash(?string $hash): static
  163.     {
  164.         $this->hash $hash;
  165.         return $this;
  166.     }
  167.     public function getState(): ?int
  168.     {
  169.         return $this->state;
  170.     }
  171.     public function setState(?int $state): static
  172.     {
  173.         $this->state $state;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Get the value of user
  178.      */ 
  179.     public function getUser()
  180.     {
  181.         return $this->user;
  182.     }
  183.     /**
  184.      * Set the value of user
  185.      *
  186.      * @return  self
  187.      */ 
  188.     public function setUser($user)
  189.     {
  190.         $this->user $user;
  191.         return $this;
  192.     }
  193.     public function getStringState(){
  194.         switch ($this->getState()) {
  195.             case self::DENIED:
  196.                 return "Refusée";
  197.                 
  198.             case self::VALIDATED 
  199.                 return "Validée";
  200.             default :
  201.                 return "En cours";
  202.         }
  203.     }
  204.     public function getNote(): ?string
  205.     {
  206.         return $this->note;
  207.     }
  208.     public function setNote(?string $note): static
  209.     {
  210.         $this->note $note;
  211.         return $this;
  212.     }
  213.     public function getMontantDemande(): ?float
  214.     {
  215.         return $this->montantDemande;
  216.     }
  217.     public function setMontantDemande(?float $montantDemande): static
  218.     {
  219.         $this->montantDemande $montantDemande;
  220.         return $this;
  221.     }
  222.     public function modifyValeurReelIntoValeurDemande(){
  223.         $this->setValue($this->getMontantDemande());
  224.     }
  225.     /**
  226.      * Get the value of pack
  227.      */ 
  228.     public function getPack()
  229.     {
  230.         return $this->pack;
  231.     }
  232.     /**
  233.      * Set the value of pack
  234.      *
  235.      * @return  self
  236.      */ 
  237.     public function setPack($pack)
  238.     {
  239.         $this->pack $pack;
  240.         return $this;
  241.     }
  242.     public function serialize()
  243.     {
  244.         return serialize([
  245.             'wallet' => $this->getWallet(),
  246.             'hash' => $this->getHash(),
  247.             'montantDemande' => $this->getMontantDemande(),
  248.             'type' => $this->getType(),
  249.             'fee' => $this->getFee(),
  250.             'transfertMode' => $this->getTransfertMode(),
  251.             'currencyOfTransaction' => $this->getCurrencyOfTransaction(),
  252.             'amountWithCurrency' => $this->getAmountWithCurrency(),
  253.             'beneficiaire' => $this->getBeneficiaire(),
  254.             'iban' => $this->getIban(),
  255.             'swift' => $this->getSwift(),
  256.             'banque' => $this->getBanque(),
  257.         ]);
  258.     }
  259.     public function unserialize($serialized)
  260.     {
  261.         $data unserialize($serialized);
  262.         $this->setWallet($data['wallet']);
  263.         $this->setHash($data['hash']);
  264.         $this->setMontantDemande($data['montantDemande']);
  265.         $this->setType($data['type']);
  266.         $this->setFee($data['fee']);
  267.         $this->setTransfertMode($data['transfertMode']);
  268.         $this->setCurrencyOfTransaction($data['currencyOfTransaction']);
  269.         $this->setAmountWithCurrency($data['amountWithCurrency']);
  270.         $this->setBeneficiaire($data['beneficiaire']);
  271.         $this->setIban($data['iban']);
  272.         $this->setSwift($data['swift']);
  273.         $this->setBanque($data['banque']);
  274.     }
  275.     public function getValidationDate(): ?\DateTimeInterface
  276.     {
  277.         return $this->validationDate;
  278.     }
  279.     public function setValidationDate(?\DateTimeInterface $validationDate): static
  280.     {
  281.         $this->validationDate $validationDate;
  282.         return $this;
  283.     }
  284.     /**
  285.      * Get the value of type
  286.      */ 
  287.     public function getType()
  288.     {
  289.         return $this->type;
  290.     }
  291.     /**
  292.      * Set the value of type
  293.      *
  294.      * @return  self
  295.      */ 
  296.     public function setType($type)
  297.     {
  298.         $this->type $type;
  299.         return $this;
  300.     }
  301.     /**
  302.      * Get the value of fee
  303.      */ 
  304.     public function getFee()
  305.     {
  306.         return $this->fee;
  307.     }
  308.     /**
  309.      * Set the value of fee
  310.      *
  311.      * @return  self
  312.      */ 
  313.     public function setFee($fee)
  314.     {
  315.         $this->fee $fee;
  316.         return $this;
  317.     }
  318.     public function getStringType(){
  319.         switch ($this->getType()) {
  320.             case self::TYPE_ANTICPATED:
  321.                 return "Anticipé";
  322.                 
  323.             default :
  324.                 return "Normal";
  325.         }
  326.     }
  327.     /**
  328.      * Get the value of document
  329.      */ 
  330.     public function getDocument()
  331.     {
  332.         return $this->document;
  333.     }
  334.     /**
  335.      * Set the value of document
  336.      *
  337.      * @return  self
  338.      */ 
  339.     public function setDocument($document)
  340.     {
  341.         $this->document $document;
  342.         return $this;
  343.     }
  344.     /**
  345.      * Get the value of currencyOfTransaction
  346.      */ 
  347.     public function getCurrencyOfTransaction()
  348.     {
  349.         return $this->currencyOfTransaction;
  350.     }
  351.     /**
  352.      * Set the value of currencyOfTransaction
  353.      *
  354.      * @return  self
  355.      */ 
  356.     public function setCurrencyOfTransaction($currencyOfTransaction)
  357.     {
  358.         $this->currencyOfTransaction $currencyOfTransaction;
  359.         return $this;
  360.     }
  361.     public function getArrayToExport(){
  362.         $ret = [];
  363.         $ret[] = $this->getFecha()->format('Y-m-d');
  364.         $ret[] = $this->getUser()->getName();
  365.         $ret[] = $this->getUser()->getSurname();
  366.         $ret[] = $this->getUser()->getUsername();
  367.         $ret[] = $this->getValue();
  368.         $ret[] = $this->getCurrencyOfTransaction();
  369.         $ret[] = $this->getHash();
  370.         $ret[] = $this->getStringState();
  371.         return $ret;
  372.     }
  373.     /**
  374.      * Get the value of wasNotificationSentByMail
  375.      */ 
  376.     public function getWasNotificationSentByMail()
  377.     {
  378.         return $this->wasNotificationSentByMail;
  379.     }
  380.     /**
  381.      * Set the value of wasNotificationSentByMail
  382.      *
  383.      * @return  self
  384.      */ 
  385.     public function setWasNotificationSentByMail($wasNotificationSentByMail)
  386.     {
  387.         $this->wasNotificationSentByMail $wasNotificationSentByMail;
  388.         return $this;
  389.     }
  390.     /**
  391.      * Get the value of transfertMode
  392.      */ 
  393.     public function getTransfertMode()
  394.     {
  395.         return $this->transfertMode;
  396.     }
  397.     /**
  398.      * Set the value of transfertMode
  399.      *
  400.      * @return  self
  401.      */ 
  402.     public function setTransfertMode($transfertMode)
  403.     {
  404.         $this->transfertMode $transfertMode;
  405.         return $this;
  406.     }
  407.     /**
  408.      * Get the value of iban
  409.      */ 
  410.     public function getIban()
  411.     {
  412.         return $this->iban;
  413.     }
  414.     /**
  415.      * Set the value of iban
  416.      *
  417.      * @return  self
  418.      */ 
  419.     public function setIban($iban)
  420.     {
  421.         $this->iban $iban;
  422.         return $this;
  423.     }
  424.     /**
  425.      * Get the value of swift
  426.      */ 
  427.     public function getSwift()
  428.     {
  429.         return $this->swift;
  430.     }
  431.     /**
  432.      * Set the value of swift
  433.      *
  434.      * @return  self
  435.      */ 
  436.     public function setSwift($swift)
  437.     {
  438.         $this->swift $swift;
  439.         return $this;
  440.     }
  441.     /**
  442.      * Get the value of banque
  443.      */ 
  444.     public function getBanque()
  445.     {
  446.         return $this->banque;
  447.     }
  448.     /**
  449.      * Set the value of banque
  450.      *
  451.      * @return  self
  452.      */ 
  453.     public function setBanque($banque)
  454.     {
  455.         $this->banque $banque;
  456.         return $this;
  457.     }
  458.     /**
  459.      * Get the value of beneficiaire
  460.      */ 
  461.     public function getBeneficiaire()
  462.     {
  463.         return $this->beneficiaire;
  464.     }
  465.     /**
  466.      * Set the value of beneficiaire
  467.      *
  468.      * @return  self
  469.      */ 
  470.     public function setBeneficiaire($beneficiaire)
  471.     {
  472.         $this->beneficiaire $beneficiaire;
  473.         return $this;
  474.     }
  475.     public function getTransfertLabel(){
  476.         switch($this->getTransfertMode()) {
  477.             case self::TRANSFERT_BANK:
  478.                 return "Virement bancaire";
  479.             default:
  480.                 return "Transaction crypto";
  481.         }
  482.     }
  483.     /**
  484.      * Get the value of amountWithCurrency
  485.      */ 
  486.     public function getAmountWithCurrency()
  487.     {
  488.         return $this->amountWithCurrency;
  489.     }
  490.     /**
  491.      * Set the value of amountWithCurrency
  492.      *
  493.      * @return  self
  494.      */ 
  495.     public function setAmountWithCurrency($amountWithCurrency)
  496.     {
  497.         $this->amountWithCurrency $amountWithCurrency;
  498.         return $this;
  499.     }
  500.     public function getPaymentLabel(){
  501.         switch($this->getTransfertMode()) {
  502.             case self::TRANSFERT_BANK:
  503.                 return "Virement bancaire - ".$this->getCurrencyOfTransaction();
  504.             default:
  505.                 return "Transfert ".$this->getCurrencyOfTransaction();
  506.         }
  507.     }
  508. }