src/Entity/System/Cart.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\ORM\Mapping\JoinColumn;
  7. use Doctrine\ORM\Mapping\OneToOne;
  8. /**
  9. * Cart
  10. *
  11. * @ORM\Table(
  12. * name="ps_cart",
  13. * indexes={
  14. *
  15. * @ORM\Index(name="is_sync", columns={"is_sync"}),
  16. * @ORM\Index(name="is_virtual", columns={"is_virtual"}),
  17. * @ORM\Index(name="id_currency", columns={"id_currency"}),
  18. * @ORM\Index(name="secure_key", columns={"secure_key"}),
  19. * @ORM\Index(name="delivery_option", columns={"delivery_option"})
  20. * }
  21. * )
  22. *
  23. * @ORM\Entity(repositoryClass="App\Repository\System\CartRepository")
  24. */
  25. class Cart
  26. {
  27. public const DEFAULT_CURRENCY_EUR = 1;
  28. /**
  29. * @var int
  30. *
  31. * @ORM\Id
  32. *
  33. * @ORM\GeneratedValue(strategy="AUTO")
  34. *
  35. * @ORM\Column(type="integer", name="id_cart")
  36. */
  37. private $id;
  38. /**
  39. * One Cart has One Order.
  40. *
  41. * @var Order|null
  42. *
  43. * @OneToOne(targetEntity="App\Entity\System\Order", inversedBy="cart")
  44. *
  45. * @JoinColumn(name="id_order", referencedColumnName="id_order", nullable=true)
  46. */
  47. private $order;
  48. /**
  49. * @ORM\ManyToOne(targetEntity="App\Entity\System\Carrier")
  50. *
  51. * @ORM\JoinColumn(name="id_carrier", referencedColumnName="id_carrier", nullable=true)
  52. */
  53. private ?Carrier $carrier;
  54. /**
  55. * @var string
  56. *
  57. * @ORM\Column(type="string", length=1000)
  58. */
  59. private $deliveryOption;
  60. /**
  61. * @ORM\ManyToOne(targetEntity="App\Entity\System\Address")
  62. *
  63. * @ORM\JoinColumn(referencedColumnName="id_address", name="id_address_delivery", nullable=true)
  64. */
  65. private ?Address $addressDelivery;
  66. /**
  67. * @var int
  68. *
  69. * @ORM\Column(type="integer", length=10, name="id_currency")
  70. */
  71. private $currencyId;
  72. /**
  73. * @ORM\ManyToOne(targetEntity="App\Entity\System\Customer")
  74. *
  75. * @ORM\JoinColumn(name="id_customer", referencedColumnName="id_customer", nullable=false)
  76. */
  77. private Customer $customer;
  78. /**
  79. * @var string|null
  80. *
  81. * @ORM\Column(type="string", length=32, nullable=true, options={"default" : "-1"})
  82. */
  83. private $secureKey;
  84. /**
  85. * @var bool
  86. *
  87. * @ORM\Column(type="boolean", options={"default" : 1})
  88. */
  89. private $recyclable;
  90. /**
  91. * @var \DateTime
  92. *
  93. * @ORM\Column(type="datetime")
  94. */
  95. private $dateUpd;
  96. /**
  97. * @var \DateTime
  98. *
  99. * @ORM\Column(type="datetime")
  100. */
  101. private $dateAdd;
  102. /**
  103. * @var bool
  104. *
  105. * @ORM\Column(type="boolean", options={"default" : 0}, name="is_virtual")
  106. */
  107. private $virtual;
  108. /**
  109. * @var bool
  110. *
  111. * @ORM\Column(type="boolean", options={"default" : 0}, name="is_sync")
  112. */
  113. private bool $sync;
  114. /**
  115. * @var bool
  116. *
  117. * @ORM\Column(type="boolean", options={"default" : 0}, name="is_mobile")
  118. */
  119. private $mobile;
  120. /**
  121. * @var bool
  122. *
  123. * @ORM\Column(type="boolean", options={"default" : 0})
  124. */
  125. private $dropshipping;
  126. /**
  127. * @var string|null
  128. *
  129. * @ORM\Column(type="string", nullable=true)
  130. */
  131. private $payment;
  132. /**
  133. * @var string|null
  134. *
  135. * @ORM\Column(type="string", length=64, nullable=true)
  136. */
  137. private ?string $paymentMethodType = null;
  138. /**
  139. * @var string|null
  140. *
  141. * @ORM\Column(type="string", length=64, nullable=true)
  142. */
  143. private ?string $paymentMethodId = null;
  144. /**
  145. * One Cart has One PackPaymentMethod.
  146. *
  147. * @var PaymentMethod|null
  148. *
  149. * @ORM\ManyToOne(targetEntity="App\Entity\System\PaymentMethod", inversedBy="packCarts")
  150. *
  151. * @JoinColumn(name="pack_payment_method_id", referencedColumnName="id_payment_method", nullable=true)
  152. */
  153. private $packPaymentMethod;
  154. /**
  155. * @var string|null
  156. *
  157. * @ORM\Column(type="string", nullable=true)
  158. */
  159. private $packStoredPaymentMethodId;
  160. /**
  161. * One Cart has One ServicesPaymentMethod.
  162. *
  163. * @var PaymentMethod|null
  164. *
  165. * @ORM\ManyToOne(targetEntity="App\Entity\System\PaymentMethod", inversedBy="servicesCarts")
  166. *
  167. * @JoinColumn(name="services_payment_method_id", referencedColumnName="id_payment_method", nullable=true)
  168. */
  169. private $servicesPaymentMethod;
  170. /**
  171. * @var string|null
  172. *
  173. * @ORM\Column(type="string", nullable=true)
  174. */
  175. private $servicesStoredPaymentMethodId;
  176. /**
  177. * @var float|null
  178. *
  179. * @ORM\Column(type="float", options={"default" : 0.00}, nullable=true)
  180. */
  181. private $totalProducts;
  182. /**
  183. * @var float|null
  184. *
  185. * @ORM\Column(type="float", options={"default" : 0.00}, nullable=true, name="total_envio")
  186. */
  187. private $totalShipping;
  188. /**
  189. * @ORM\Column(type="float", nullable=true, name="logistic_weight")
  190. */
  191. private ?float $logisticWeight;
  192. /**
  193. * @var Collection<int, CartProduct>&iterable<CartProduct>
  194. *
  195. * @ORM\OneToMany(targetEntity="CartProduct", mappedBy="cart", cascade={"persist", "remove"})
  196. */
  197. private $cartProducts;
  198. /**
  199. * @ORM\Column(type="string", length=50, nullable=true)
  200. */
  201. private ?string $refOrderSupplier = null;
  202. /**
  203. * @ORM\Column(type="boolean", options={"default" : 0}, name="is_system")
  204. */
  205. private bool $system = false;
  206. /**
  207. * @ORM\Column(type="string", length=64, nullable=true)
  208. */
  209. private ?string $sellingChannel = null;
  210. /**
  211. * @ORM\Column(type="string", length=256, nullable=true)
  212. */
  213. private ?string $additionalParameters = null;
  214. /**
  215. * @ORM\Column(type="datetime", nullable=true)
  216. */
  217. private ?\DateTime $dateAmazon = null;
  218. /**
  219. * @ORM\Column(type="boolean", options={"default" : 0})
  220. */
  221. private bool $fba = false;
  222. /**
  223. * @ORM\Column(type="datetime", nullable=true)
  224. */
  225. private ?\DateTime $maxDeliveryDatetime = null;
  226. /**
  227. * @ORM\Column(type="datetime", nullable=true)
  228. */
  229. private ?\DateTime $maxExpeditionDatetime = null;
  230. /**
  231. * @ORM\Column(type="text", nullable=true)
  232. */
  233. private ?string $shipmentChoices = null;
  234. /**
  235. * @ORM\ManyToOne(targetEntity="App\Entity\System\CodeDiscount")
  236. *
  237. * @ORM\JoinColumn(name="code_discount_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  238. */
  239. private ?CodeDiscount $codeDiscount = null;
  240. /**
  241. * @ORM\ManyToOne(targetEntity="App\Entity\System\Cart", inversedBy="cartChildren")
  242. *
  243. * @ORM\JoinColumn(name="cart_parent_id", referencedColumnName="id_cart", nullable=true)
  244. */
  245. private ?Cart $cartParent = null;
  246. /**
  247. * @var Collection<int, Cart>&iterable<Cart>
  248. *
  249. * @ORM\OneToMany(targetEntity="App\Entity\System\Cart", mappedBy="cartParent")
  250. */
  251. private $cartChildren;
  252. /**
  253. * @ORM\ManyToOne(targetEntity="App\Entity\System\PaymentMethod")
  254. *
  255. * @ORM\JoinColumn(name="payment_method", referencedColumnName="id_payment_method", nullable=true)
  256. */
  257. private ?PaymentMethod $paymentMethod = null;
  258. public function __construct()
  259. {
  260. $this->currencyId = self::DEFAULT_CURRENCY_EUR;
  261. $this->recyclable = false;
  262. $this->sync = false;
  263. $this->logisticWeight = 0;
  264. $this->cartProducts = new ArrayCollection();
  265. $this->cartChildren = new ArrayCollection();
  266. $this->dropshipping = false;
  267. $this->mobile = false;
  268. }
  269. /**
  270. * @return int
  271. */
  272. public function getId(): int
  273. {
  274. return $this->id;
  275. }
  276. /**
  277. * @param int|null $id
  278. *
  279. * @return Cart
  280. */
  281. public function setIdCart(?int $id): Cart
  282. {
  283. $this->id = $id;
  284. return $this;
  285. }
  286. /**
  287. * @return Order|null
  288. */
  289. public function getOrder(): ?Order
  290. {
  291. if ($this->order && $this->order->getId() === 0) {
  292. return null;
  293. }
  294. return $this->order;
  295. }
  296. /**
  297. * @param Order|null $order
  298. *
  299. * @return Cart
  300. */
  301. public function setOrder(?Order $order): Cart
  302. {
  303. $this->order = $order;
  304. return $this;
  305. }
  306. public function getCarrier(): ?Carrier
  307. {
  308. return $this->carrier;
  309. }
  310. public function setCarrier(?Carrier $carrier): Cart
  311. {
  312. $this->carrier = $carrier;
  313. return $this;
  314. }
  315. /**
  316. * @return string
  317. */
  318. public function getDeliveryOption(): string
  319. {
  320. return $this->deliveryOption;
  321. }
  322. /**
  323. * @param string $deliveryOption
  324. *
  325. * @return Cart
  326. */
  327. public function setDeliveryOption(string $deliveryOption): self
  328. {
  329. $this->deliveryOption = $deliveryOption;
  330. return $this;
  331. }
  332. public function getAddressDelivery(): ?Address
  333. {
  334. if ($this->addressDelivery && $this->addressDelivery->getId() === 0) {
  335. return null;
  336. }
  337. return $this->addressDelivery;
  338. }
  339. public function setAddressDelivery(?Address $addressDelivery): Cart
  340. {
  341. $this->addressDelivery = $addressDelivery;
  342. return $this;
  343. }
  344. /**
  345. * @return int
  346. */
  347. public function getCurrencyId(): int
  348. {
  349. return $this->currencyId;
  350. }
  351. /**
  352. * @param int $currencyId
  353. *
  354. * @return Cart
  355. */
  356. public function setCurrencyId(int $currencyId): self
  357. {
  358. $this->currencyId = $currencyId;
  359. return $this;
  360. }
  361. public function getCustomer(): Customer
  362. {
  363. return $this->customer;
  364. }
  365. public function setCustomer(Customer $customer): Cart
  366. {
  367. $this->customer = $customer;
  368. return $this;
  369. }
  370. /**
  371. * @return string|null
  372. */
  373. public function getSecureKey(): ?string
  374. {
  375. return $this->secureKey;
  376. }
  377. /**
  378. * @param string|null $secureKey
  379. *
  380. * @return Cart
  381. */
  382. public function setSecureKey(?string $secureKey): self
  383. {
  384. $this->secureKey = $secureKey;
  385. return $this;
  386. }
  387. public function isRecyclable(): bool
  388. {
  389. return $this->recyclable;
  390. }
  391. public function setRecyclable(bool $recyclable): self
  392. {
  393. $this->recyclable = $recyclable;
  394. return $this;
  395. }
  396. /**
  397. * @return \DateTime
  398. */
  399. public function getDateUpd(): \DateTime
  400. {
  401. return $this->dateUpd;
  402. }
  403. /**
  404. * @param \DateTime $dateUpd
  405. *
  406. * @return Cart
  407. */
  408. public function setDateUpd(\DateTime $dateUpd): self
  409. {
  410. $this->dateUpd = $dateUpd;
  411. return $this;
  412. }
  413. /**
  414. * @return \DateTime
  415. */
  416. public function getDateAdd(): \DateTime
  417. {
  418. return $this->dateAdd;
  419. }
  420. /**
  421. * @param \DateTime $dateAdd
  422. *
  423. * @return Cart
  424. */
  425. public function setDateAdd(\DateTime $dateAdd): self
  426. {
  427. $this->dateAdd = $dateAdd;
  428. return $this;
  429. }
  430. public function isVirtual(): bool
  431. {
  432. return $this->virtual;
  433. }
  434. public function setVirtual(bool $virtual): self
  435. {
  436. $this->virtual = $virtual;
  437. return $this;
  438. }
  439. public function getSync(): bool
  440. {
  441. return $this->sync;
  442. }
  443. /**
  444. * @param bool $sync
  445. *
  446. * @return Cart
  447. */
  448. public function setSync(bool $sync): self
  449. {
  450. $this->sync = $sync;
  451. return $this;
  452. }
  453. public function isMobile(): bool
  454. {
  455. return $this->mobile;
  456. }
  457. public function setMobile(bool $mobile): self
  458. {
  459. $this->mobile = $mobile;
  460. return $this;
  461. }
  462. public function isDropshipping(): bool
  463. {
  464. return $this->dropshipping;
  465. }
  466. public function setDropshipping(bool $dropshipping): self
  467. {
  468. $this->dropshipping = $dropshipping;
  469. return $this;
  470. }
  471. public function getPayment(): ?string
  472. {
  473. return $this->payment;
  474. }
  475. /**
  476. * @param string|null $payment
  477. *
  478. * @return Cart
  479. */
  480. public function setPayment(?string $payment): self
  481. {
  482. $this->payment = $payment;
  483. return $this;
  484. }
  485. public function getPaymentMethodType(): ?string
  486. {
  487. return $this->paymentMethodType;
  488. }
  489. public function setPaymentMethodType(?string $paymentMethodType): Cart
  490. {
  491. $this->paymentMethodType = $paymentMethodType;
  492. return $this;
  493. }
  494. public function getPaymentMethodId(): ?string
  495. {
  496. return $this->paymentMethodId;
  497. }
  498. public function setPaymentMethodId(?string $paymentMethodId): Cart
  499. {
  500. $this->paymentMethodId = $paymentMethodId;
  501. return $this;
  502. }
  503. public function getPackPaymentMethod(): ?PaymentMethod
  504. {
  505. return $this->packPaymentMethod;
  506. }
  507. public function setPackPaymentMethod(?PaymentMethod $packPaymentMethod): Cart
  508. {
  509. $this->packPaymentMethod = $packPaymentMethod;
  510. return $this;
  511. }
  512. public function getPackStoredPaymentMethodId(): ?string
  513. {
  514. return $this->packStoredPaymentMethodId;
  515. }
  516. public function setPackStoredPaymentMethodId(?string $packStoredPaymentMethodId): Cart
  517. {
  518. $this->packStoredPaymentMethodId = $packStoredPaymentMethodId;
  519. return $this;
  520. }
  521. public function getServicesPaymentMethod(): ?PaymentMethod
  522. {
  523. return $this->servicesPaymentMethod;
  524. }
  525. public function setServicesPaymentMethod(?PaymentMethod $servicesPaymentMethod): Cart
  526. {
  527. $this->servicesPaymentMethod = $servicesPaymentMethod;
  528. return $this;
  529. }
  530. public function getServicesStoredPaymentMethodId(): ?string
  531. {
  532. return $this->servicesStoredPaymentMethodId;
  533. }
  534. public function setServicesStoredPaymentMethodId(?string $servicesStoredPaymentMethodId): Cart
  535. {
  536. $this->servicesStoredPaymentMethodId = $servicesStoredPaymentMethodId;
  537. return $this;
  538. }
  539. public function getTotalProducts(): ?float
  540. {
  541. return $this->totalProducts;
  542. }
  543. public function setTotalProducts(?float $totalProducts): self
  544. {
  545. $this->totalProducts = $totalProducts;
  546. return $this;
  547. }
  548. public function getTotalShipping(): ?float
  549. {
  550. return $this->totalShipping;
  551. }
  552. public function setTotalShipping(?float $totalShipping): self
  553. {
  554. $this->totalShipping = $totalShipping;
  555. return $this;
  556. }
  557. /**
  558. * @param Collection<int, CartProduct>&iterable<CartProduct> $cartProducts
  559. *
  560. * @return $this
  561. */
  562. public function setCartProducts($cartProducts): Cart
  563. {
  564. $this->cartProducts = $cartProducts;
  565. return $this;
  566. }
  567. public function addCartProduct(CartProduct $cartProduct): Cart
  568. {
  569. if (!$this->cartProducts->contains($cartProduct)) {
  570. $this->cartProducts[] = $cartProduct;
  571. $cartProduct->setCart($this);
  572. }
  573. return $this;
  574. }
  575. public function removeCartProduct(CartProduct $cartProduct): Cart
  576. {
  577. if ($this->cartProducts->contains($cartProduct)) {
  578. $this->cartProducts->removeElement($cartProduct);
  579. }
  580. return $this;
  581. }
  582. /**
  583. * @param CartProduct[] $cartProducts
  584. */
  585. public function addCartProducts(array $cartProducts): void
  586. {
  587. foreach ($cartProducts as $cartProduct) {
  588. $this->cartProducts->add($cartProduct);
  589. }
  590. }
  591. /**
  592. * @return CartProduct[]|Collection<int, CartProduct>
  593. */
  594. public function getCartProducts()
  595. {
  596. return $this->cartProducts;
  597. }
  598. public function getRefOrderSupplier(): ?string
  599. {
  600. return $this->refOrderSupplier;
  601. }
  602. public function setRefOrderSupplier(?string $refOrderSupplier): Cart
  603. {
  604. $this->refOrderSupplier = $refOrderSupplier;
  605. return $this;
  606. }
  607. public function isSystem(): bool
  608. {
  609. return $this->system;
  610. }
  611. public function setSystem(bool $system): Cart
  612. {
  613. $this->system = $system;
  614. return $this;
  615. }
  616. public function getSellingChannel(): ?string
  617. {
  618. return $this->sellingChannel;
  619. }
  620. public function setSellingChannel(?string $sellingChannel): Cart
  621. {
  622. $this->sellingChannel = $sellingChannel;
  623. return $this;
  624. }
  625. public function getAdditionalParameters(): ?string
  626. {
  627. return $this->additionalParameters;
  628. }
  629. public function setAdditionalParameters(?string $additionalParameters): Cart
  630. {
  631. $this->additionalParameters = $additionalParameters;
  632. return $this;
  633. }
  634. public function getDateAmazon(): ?\DateTime
  635. {
  636. return $this->dateAmazon;
  637. }
  638. public function setDateAmazon(?\DateTime $dateAmazon): Cart
  639. {
  640. $this->dateAmazon = $dateAmazon;
  641. return $this;
  642. }
  643. public function isFba(): bool
  644. {
  645. return $this->fba;
  646. }
  647. public function setFba(bool $fba): Cart
  648. {
  649. $this->fba = $fba;
  650. return $this;
  651. }
  652. public function getMaxDeliveryDatetime(): ?\DateTime
  653. {
  654. return $this->maxDeliveryDatetime;
  655. }
  656. public function setMaxDeliveryDatetime(?\DateTime $maxDeliveryDatetime): Cart
  657. {
  658. $this->maxDeliveryDatetime = $maxDeliveryDatetime;
  659. return $this;
  660. }
  661. public function getMaxExpeditionDatetime(): ?\DateTime
  662. {
  663. return $this->maxExpeditionDatetime;
  664. }
  665. public function setMaxExpeditionDatetime(?\DateTime $maxExpeditionDatetime): Cart
  666. {
  667. $this->maxExpeditionDatetime = $maxExpeditionDatetime;
  668. return $this;
  669. }
  670. public function getCodeDiscount(): ?CodeDiscount
  671. {
  672. if ($this->codeDiscount && $this->codeDiscount->getId() === 0) {
  673. return null;
  674. }
  675. return $this->codeDiscount;
  676. }
  677. public function setCodeDiscount(?CodeDiscount $codeDiscount): Cart
  678. {
  679. $this->codeDiscount = $codeDiscount;
  680. return $this;
  681. }
  682. public function getShipmentChoices(): ?string
  683. {
  684. return $this->shipmentChoices;
  685. }
  686. public function setShipmentChoices(?string $shipmentChoices): Cart
  687. {
  688. $this->shipmentChoices = $shipmentChoices;
  689. return $this;
  690. }
  691. public function getCartParent(): ?Cart
  692. {
  693. return $this->cartParent;
  694. }
  695. public function setCartParent(?Cart $cartParent): Cart
  696. {
  697. $this->cartParent = $cartParent;
  698. return $this;
  699. }
  700. /**
  701. * @return Collection<int, Cart>&iterable<Cart>
  702. */
  703. public function getCartChildren()
  704. {
  705. return $this->cartChildren;
  706. }
  707. public function addCart(Cart $cart): Cart
  708. {
  709. if (!$this->cartChildren->contains($cart)) {
  710. $this->cartChildren[] = $cart;
  711. $cart->setCartParent($this);
  712. }
  713. return $this;
  714. }
  715. public function getLogisticWeight(): ?float
  716. {
  717. return $this->logisticWeight;
  718. }
  719. public function setLogisticWeight(?float $logisticWeight): void
  720. {
  721. $this->logisticWeight = $logisticWeight;
  722. }
  723. public function getPaymentMethod(): ?PaymentMethod
  724. {
  725. return $this->paymentMethod;
  726. }
  727. public function setPaymentMethod(?PaymentMethod $paymentMethod): Cart
  728. {
  729. $this->paymentMethod = $paymentMethod;
  730. return $this;
  731. }
  732. }