src/Entity/Transaccion.php line 23
- <?php
- namespace App\Entity;
- use App\Entity\User;
- use App\Entity\TransaccionAfiliado;
- use App\Entity\UserStats;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- use JMS\Serializer\Annotation as JMS;
- use App\Entity\Cupon;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * Transaccion
- *
- * @ORM\Table()
- * @ORM\Entity(repositoryClass="App\Repository\TransaccionRepository")
- * @ORM\HasLifecycleCallbacks()
- */
- class Transaccion
- {
- const EN_PASSARELA_DE_PAGO = "En pasarela de pago";
- const PAGADO = "Pagado";
- const PENDIENTE_DE_PAGO = "Pendiente de pago";
- const COBRADO = "Cobrado";
- const CANCELADO = "Cancelado";
- const ERROR_EN_PASARELA = "ERROR EN PASARELA";
- const DEVUELTO = "Devuelto";
- const PENDIENTE = "PENDIENTE";
- const EN_PROCESO = "EN PROCESO";
- const ENVIADO = "ENVIADO";
- const DISPONIBLE = "DISPONIBLE";
- const ENTREGADO = "ENTREGADO";
- /**
- * @var integer
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- * @JMS\Groups({"api-order"})
- */
- private $id;
- /**
- * @ORM\ManyToOne(targetEntity="Oficina", cascade={"merge"})
- * @ORM\JoinColumn(name="oficina", referencedColumnName="id", nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $oficina;
- /**
- * @ORM\ManyToOne(targetEntity="User", inversedBy="transacciones")
- * @ORM\JoinColumn(name="usuario", referencedColumnName="id", nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $usuario;
- /**
- * @ORM\ManyToOne(targetEntity="User", inversedBy="transaccionesAfiliadas")
- * @ORM\JoinColumn(name="usuarioAfiliado", referencedColumnName="id", nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $usuarioAfiliado;
- /**
- * @var string
- *
- * @ORM\Column(name="cupon", type="string", length=255, nullable=false)
- */
- private $cupon;
- /**
- * @var string
- *
- * @ORM\Column(name="tipoPromo", type="integer", options={"default":0})
- */
- private $tipoPromo;
- /**
- * @var string
- *
- * @ORM\Column(name="anotacion", type="text", nullable=true)
- */
- private $anotacion;
- /**
- * @var string
- *
- * @ORM\Column(name="estado", type="string", length=255)
- * @JMS\Groups({"api-order"})
- */
- private $estado;
- /**
- * @var \DateTime
- *
- * @ORM\Column(name="horaRecogida", type="time", nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $horaRecogida;
- /**
- * @ORM\OneToMany(targetEntity="TransaccionLinea", mappedBy="transaccion", cascade={"persist", "remove"}, orphanRemoval=true)
- */
- private $lineas;
- /**
- * @var \DateTime
- *
- * @ORM\Column(name="fechaRecogida", type="date", nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $fechaRecogida;
- /**
- * Sumatorio de los gastos de todas las divisisas SIN gastos de envio
- * @var integer
- *
- * @ORM\Column(name="totalLineas", type="float")
- */
- private $totalLineas=0;
- /**
- * Sumatorio de los gastos de todas las divisisas CON gastos de envio
- * @var integer
- *
- * @ORM\Column(name="total", type="float")
- */
- private $total=0;
- // private $afiliadoRelacionado="";
- /**
- * @var integer
- *
- * @ORM\Column(name="gastosEnvio", type="float", nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $gastosEnvio=0;
- /**
- * @var string
- *
- * @ORM\Column(name="TipoPago", type="string", length=255)
- * @JMS\Groups({"api-order"})
- */
- private $tipoPago;
- /**
- * @var string
- *
- * @ORM\Column(name="direccionCompleta", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $direccionCompleta;
- /**
- * @var string
- *
- * @ORM\Column(name="codigoPostal", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $codigoPostal;
- /**
- * @var string
- *
- * @ORM\Column(name="ciudad", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $ciudad;
- /**
- * @ORM\ManyToOne(targetEntity="Provincia")
- * @ORM\JoinColumn(name="provincia", referencedColumnName="id", nullable=true)
- */
- private $provincia;
- /**
- * @var string
- *
- * @ORM\Column(name="transaccionFecha", type="datetime", nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $transaccionFecha;
- /**
- * @var string
- *
- * @ORM\Column(name="pais", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $pais;
- /**
- * @var string
- *
- * @ORM\Column(name="devoluciones", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $devoluciones;
- /**
- * @var string
- *
- * @ORM\Column(name="tiempoEnvio", type="datetime",nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $tiempoEnvio;
- /**
- * @var string
- *
- * @ORM\Column(name="estado_envio", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- private $estadoEnvio='PENDIENTE';
- /**
- * @ORM\ManyToOne(targetEntity="Nacex", cascade={"persist", "remove"})
- * @ORM\JoinColumn(name="nacex", referencedColumnName="id", nullable=true)
- */
- private $nacex;
- /**
- * @ORM\Column(name="dni_envio", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- protected $cardSend;
- /**
- * @ORM\Column(name="nombre_envio", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- protected $nameSend;
- /**
- * @ORM\Column(name="titular", type="string", length=255, nullable=true)
- * @JMS\Groups({"api-order"})
- */
- protected $titular;
- /**
- * @var UserStats[]
- * @ORM\ManyToMany(targetEntity="UserStats", mappedBy="orderConversions")
- *
- */
- protected $userStats;
- /**
- * @var \DateTime
- *
- * @ORM\Column(name="fecha_pagado", type="datetime", nullable=true)
- */
- private $fechaPagado;
- /**
- * @var string
- *
- * @ORM\Column(name="token_email", type="string", length=255, nullable=true)
- */
- private $tokenEmail;
- /**
- * @var string
- *
- * @ORM\Column(name="email_titular", type="string", length=255, nullable=true)
- */
- private $emailTitular;
- /**
- * @ORM\OneToOne(targetEntity="App\Entity\EmailTransaccionAbandonada", mappedBy="transaccion")
- */
- private $emailTransaccionAbandonada;
- /**
- * @var string
- *
- * @ORM\Column(name="idioma", type="string", length=45, nullable=true)
- */
- private $idioma;
- /**
- * @var ArrayCollection
- *
- * @ORM\OneToMany(targetEntity="HistorialDevolucion", mappedBy="transaccion")
- */
- protected $historialDevoluciones;
- /**
- * @var float
- *
- * @ORM\Column(name="devuelto", type="float")
- */
- private $devuelto=0;
- /**
- * @var string
- *
- * @ORM\Column(name="telefono", type="string", length=20, nullable=true)
- */
- private $telefono;
- public function __construct() {
- $this->transaccionFecha = new \DateTime();
- $this->lineas = new ArrayCollection();
- $this->userStats = new ArrayCollection();
- $this->historialDevoluciones = new ArrayCollection();
- }
- public function __toString() {
- return $this->getId();
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set oficina
- *
- * @param string $oficina
- * @return Transaccion
- */
- public function setOficina($oficina)
- {
- $this->oficina = $oficina;
- return $this;
- }
- /**
- * Get oficina
- *
- * @return Oficina
- */
- public function getOficina()
- {
- return $this->oficina;
- }
- /**
- * Set cupon
- *
- * @param string $cupon
- * @return Transaccion
- */
- public function setCupon($cupon)
- {
- $this->cupon = $cupon;
- return $this;
- }
- /**
- * Get cupon
- *
- * @return Cupon
- */
- public function getCupon()
- {
- return $this->cupon;
- }
- /**
- * Set usuario
- *
- * @param string $usuario
- * @return Transaccion
- */
- public function setUsuario($usuario)
- {
- $this->usuario = $usuario;
- return $this;
- }
- /**
- * Get usuario
- *
- * @return User
- */
- public function getUsuario()
- {
- return $this->usuario;
- }
- /**
- * Set usuarioAfiliado
- *
- * @param string $usuarioAfiliado
- * @return Transaccion
- */
- public function setUsuarioAfiliado($usuarioAfiliado)
- {
- $this->usuarioAfiliado = $usuarioAfiliado;
- return $this;
- }
- /**
- * Get usuarioAfiliado
- *
- * @return User
- */
- public function getUsuarioAfiliado()
- {
- return $this->usuarioAfiliado;
- }
- /**
- * Set anotacion
- *
- * @param string $anotacion
- * @return Transaccion
- */
- public function setAnotacion($anotacion)
- {
- $this->anotacion = $anotacion;
- return $this;
- }
- /**
- * Get anotacion
- *
- * @return string
- */
- public function getAnotacion()
- {
- return $this->anotacion;
- }
- /**
- * Set estado
- *
- * @param string $estado
- * @return Transaccion
- */
- public function setEstado($estado)
- {
- $this->estado = $estado;
- return $this;
- }
- /**
- * Get estado
- *
- * @return string
- */
- public function getEstado()
- {
- return $this->estado;
- }
- /**
- * Set horaRecogida
- *
- * @param string $horaRecogida
- * @return Transaccion
- */
- public function setHoraRecogida($horaRecogida)
- {
- $this->horaRecogida = $horaRecogida;
- return $this;
- }
- /**
- * Set lineas
- *
- * @param Linea $lineas
- * @return Reserva
- */
- public function addLinea($linea)
- {
- $this->lineas[] = $linea;
- $linea->setTransaccion($this);
- return $this;
- }
- /**
- * Get horaRecogida
- *
- * @return \DateTime
- */
- public function getHoraRecogida()
- {
- return $this->horaRecogida;
- }
- /**
- * Set lineas
- *
- * @param string $lineas
- * @return Transaccion
- */
- public function setLineas($lineas)
- {
- $this->lineas = $lineas;
- return $this;
- }
- /**
- * Get lineas
- *
- * @return ArrayCollection
- */
- public function getLineas()
- {
- return $this->lineas;
- }
- /**
- * Set fechaRecogida
- *
- * @param string $fechaRecogida
- * @return Transaccion
- */
- public function setFechaRecogida($fechaRecogida)
- {
- $this->fechaRecogida = $fechaRecogida;
- return $this;
- }
- /**
- * Get fechaRecogida
- *
- * @return \DateTime
- */
- public function getFechaRecogida()
- {
- return $this->fechaRecogida;
- }
- /**
- * Get fechaTransaccion
- *
- * @return \DateTime
- */
- public function getFechaTransaccion()
- {
- return $this->fechaTransaccion;
- }
- /**
- * Set tipoPago
- *
- * @param string $tipoPago
- * @return Transaccion
- */
- public function setTipoPago($tipoPago)
- {
- $this->tipoPago = $tipoPago;
- return $this;
- }
- /**
- * Get tipoPago
- *
- * @return string
- */
- public function getTipoPago()
- {
- return $this->tipoPago;
- }
- /**
- * Set direccionCompleta
- *
- * @param string $direccionCompleta
- * @return Transaccion
- */
- public function setDireccionCompleta($direccionCompleta)
- {
- $this->direccionCompleta = $direccionCompleta;
- return $this;
- }
- /**
- * Get direccionCompleta
- *
- * @return string
- */
- public function getDireccionCompleta()
- {
- return $this->direccionCompleta;
- }
- /**
- * Set codigoPostal
- *
- * @param string $codigoPostal
- * @return Transaccion
- */
- public function setCodigoPostal($codigoPostal)
- {
- $this->codigoPostal = $codigoPostal;
- return $this;
- }
- /**
- * Get codigoPostal
- *
- * @return string
- */
- public function getCodigoPostal()
- {
- return $this->codigoPostal;
- }
- /**
- * Set ciudad
- *
- * @param string $ciudad
- * @return Transaccion
- */
- public function setCiudad($ciudad)
- {
- $this->ciudad = $ciudad;
- return $this;
- }
- /**
- * Get ciudad
- *
- * @return string
- */
- public function getCiudad()
- {
- return $this->ciudad;
- }
- /**
- * Set provincia
- *
- * @param string $provincia
- * @return Transaccion
- */
- public function setProvincia($provincia)
- {
- $this->provincia = $provincia;
- return $this;
- }
- /**
- * Get provincia
- *
- * @return string
- */
- public function getProvincia()
- {
- return $this->provincia;
- }
- /**
- * Set pais
- *
- * @param string $pais
- * @return Transaccion
- */
- public function setPais($pais)
- {
- $this->pais = $pais;
- return $this;
- }
- /**
- * Get pais
- *
- * @return string
- */
- public function getPais()
- {
- return $this->pais;
- }
- /**
- * Set devoluciones
- *
- * @param string $devoluciones
- * @return Transaccion
- */
- public function setDevoluciones($devoluciones)
- {
- $this->devoluciones = $devoluciones;
- return $this;
- }
- /**
- * Get devoluciones
- *
- * @return string
- */
- public function getDevoluciones()
- {
- return $this->devoluciones;
- }
- /**
- * Set transaccionFecha
- *
- * @param string $transaccionFecha
- * @return Transaccion
- */
- public function setTransaccionFecha($transaccionFecha)
- {
- $this->transaccionFecha = $transaccionFecha;
- return $this;
- }
- /**
- * Get transaccionFecha
- *
- * @return \DateTime
- */
- public function getTransaccionFecha()
- {
- return $this->transaccionFecha;
- }
- /**
- * Set totalLineas
- *
- * @param string $totalLineas
- * @return Transaccion
- */
- public function setTotalLineas($totalLineas)
- {
- $this->totalLineas = $totalLineas;
- return $this;
- }
- /**
- * Get horaRecogida
- *
- * @return string
- */
- public function getTotalLineas()
- {
- return $this->totalLineas;
- }
- /**
- * Set estadoEnvio
- *
- * @param string $estadoEnvio
- * @return Transaccion
- */
- public function setEstadoEnvio($estadoEnvio)
- {
- $this->estadoEnvio = $estadoEnvio;
- return $this;
- }
- /**
- * Get estadoEnvio
- *
- * @return string
- */
- public function getEstadoEnvio()
- {
- return $this->estadoEnvio;
- }
- /**
- * Set gastosEnvio
- *
- * @param string gastosEnvio
- * @return Transaccion
- */
- public function setGastosEnvio($gastosEnvio)
- {
- $this->gastosEnvio = $gastosEnvio;
- return $this;
- }
- /**
- * Get gastosEnvio
- *
- * @return string
- */
- public function getGastosEnvio()
- {
- return $this->gastosEnvio;
- }
- /**
- * Set total
- *
- * @param float $total
- * @return Transaccion
- */
- public function setTotal($total)
- {
- $this->total = $total;
- return $this;
- }
- /**
- * Get total
- *
- * @return string
- */
- public function getTotal()
- {
- return $this->total;
- }
- /**
- * @ORM\PrePersist
- * @ORM\PreUpdate
- */
- public function prePersist(){
- if ($this->provincia and $this->totalLineas < 500){
- $this->gastosEnvio=$this->provincia->getGastos();
- }
- $this->total=$this->totalLineas+$this->gastosEnvio;
- }
- /**
- * @return \DateTime
- */
- public function getTiempoEnvio()
- {
- return $this->tiempoEnvio;
- }
- /**
- * @param string $tiempoEnvio
- */
- public function setTiempoEnvio($tiempoEnvio)
- {
- $this->tiempoEnvio = $tiempoEnvio;
- }
- /**
- * @return Nacex
- */
- public function getNacex()
- {
- return $this->nacex;
- }
- /**
- * @param mixed $nacex
- */
- public function setNacex($nacex)
- {
- $this->nacex = $nacex;
- }
- /**
- * @return mixed
- */
- public function getCardSend()
- {
- return $this->cardSend;
- }
- /**
- * @param mixed $cardSend
- */
- public function setCardSend($cardSend)
- {
- $this->cardSend = $cardSend;
- }
- /**
- * @return mixed
- */
- public function getNameSend()
- {
- return $this->nameSend;
- }
- /**
- * @param mixed $nameSend
- */
- public function setNameSend($nameSend)
- {
- $this->nameSend = $nameSend;
- }
- /**
- * @return mixed
- */
- public function getTitular()
- {
- return $this->titular;
- }
- /**
- * @param mixed $titular
- */
- public function setTitular($titular)
- {
- $this->titular = $titular;
- }
- /**
- * @return UserStats[]
- */
- public function getUserStats()
- {
- return $this->userStats;
- }
- /**
- * Set fechaPagado
- *
- * @param string $fechaPagado
- * @return DateTime
- */
- public function setFechaPagado($fechaPagado)
- {
- $this->fechaPagado = $fechaPagado;
- return $this;
- }
- /**
- * Get fechaPagado
- *
- * @return \DateTime
- */
- public function getFechaPagado()
- {
- return $this->fechaPagado;
- }
- public static function getEstadosPago()
- {
- return array(
- self::EN_PASSARELA_DE_PAGO => "En pasarela de pago",
- self::PAGADO => "Pagado",
- self::PENDIENTE_DE_PAGO => "Pendiente de pago",
- self::COBRADO => "Cobrado",
- self::CANCELADO => "Cancelado",
- self::DEVUELTO => "Devuelto",
- );
- }
- public static function getEstadosEnvio()
- {
- return array(
- self::PENDIENTE => "PENDIENTE",
- self::EN_PROCESO => "EN PROCESO",
- self::ENVIADO => "ENVIADO",
- self::DISPONIBLE => "DISPONIBLE",
- self::ENTREGADO => "ENTREGADO",
- );
- }
- public function isPagado() {
- return ($this->getEstado() == self::COBRADO);
- }
- public function puedeDevolver() {
- return ($this->getEstado() == self::DEVUELTO and $this->getTotal() > $this->getDevuelto());
- }
- /**
- * @return integer
- */
- public function getTipoPromo()
- {
- return $this->tipoPromo;
- }
- /**
- * @param integer $tipoPromo
- */
- public function setTipoPromo($tipoPromo)
- {
- $this->tipoPromo = $tipoPromo;
- }
- public function setTokenEmail($tokenEmail)
- {
- $this->tokenEmail = $tokenEmail;
- return $this;
- }
- public function getTokenEmail()
- {
- return $this->tokenEmail;
- }
- public function setEmailTitular($emailTitular)
- {
- $this->emailTitular = $emailTitular;
- return $this;
- }
- public function getEmailTitular()
- {
- return $this->emailTitular;
- }
- public function getEmailTransaccionAbandonada()
- {
- return $this->emailTransaccionAbandonada;
- }
- public function setEmailTransaccionAbandonada($emailTransaccionAbandonada)
- {
- $this->emailTransaccionAbandonada = $emailTransaccionAbandonada;
- return $this;
- }
- public function setIdioma($idioma)
- {
- $this->idioma = $idioma;
- return $this;
- }
- public function getIdioma()
- {
- return $this->idioma;
- }
- public function getHistorialDevoluciones()
- {
- return $this->historialDevoluciones;
- }
- public function addHistorialDevolucion($historialDevolucion)
- {
- if (!$this->historialDevoluciones->contains($historialDevolucion)) {
- $this->historialDevoluciones->add($historialDevolucion);
- $historialDevolucion->setTransaccion($this);
- }
- return $this;
- }
- public function removeHistorialDevolucion($historialDevolucion)
- {
- if ($this->historialDevoluciones->removeElement($historialDevolucion)) {
- // set the owning side to null (unless already changed)
- if ($historialDevolucion->getTransaccion() === $this) {
- $historialDevolucion->setTransaccion(null);
- }
- }
- return $this;
- }
- public function getDevuelto()
- {
- return $this->devuelto;
- }
- public function setDevuelto(float $devuelto)
- {
- $this->devuelto = $devuelto;
- return $this;
- }
- public function setTelefono($telefono)
- {
- $this->telefono = $telefono;
- return $this;
- }
- public function getTelefono()
- {
- return $this->telefono;
- }
- }