src/Entity/System/Customer.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use App\Factory\ControlPanel\Wishlist\WishListFactory;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11. * Customer
  12. *
  13. * @ORM\Entity(repositoryClass="App\Repository\System\CustomerRepository")
  14. *
  15. * @ORM\Table(name="ps_customer",
  16. * indexes={
  17. *
  18. * @ORM\Index(name="ps_customer_hubspot_contact_id_index", columns={"hubspot_contact_id"}),
  19. * @ORM\Index(name="date_add", columns={"date_add"}),
  20. * @ORM\Index(name="ps_customer_linkedin_account_id_index", columns={"linkedin_account_id"}),
  21. * @ORM\Index(name="customer_login", columns={"email", "passwd"}),
  22. * @ORM\Index(name="id_customer_passwd", columns={"id_customer", "passwd"}),
  23. * @ORM\Index(name="ps_customer_hubspot_company_id_index", columns={"hubspot_company_id"}),
  24. * @ORM\Index(name="active", columns={"active"}),
  25. * @ORM\Index(name="ps_customer_google_account_id_index", columns={"google_account_id"}),
  26. * @ORM\Index(name="customer_email", columns={"email"}),
  27. * @ORM\Index(name="stripe_reference", columns={"stripe_reference"}),
  28. * @ORM\Index(name="ps_customer_fraud_index", columns={"moroso"})
  29. * }
  30. * )
  31. */
  32. class Customer implements UserInterface, PasswordAuthenticatedUserInterface
  33. {
  34. public const DEFAULT_SYS_USER_ID = 1523;
  35. public const IDS_USERS_SYS = [self::DEFAULT_SYS_USER_ID, 131588, 131590, 245190];
  36. public const PARTIAL_CREATION_STEP_1_ID = 2;
  37. public const PARTIAL_CREATION_STEP_2_ID = 1;
  38. public const PARTIAL_CREATION_STEP_COMPLETE_ID = 0;
  39. public const WORKHUMAN_CUSTOMER_IDS = [232487, 235957, 235968, 235969, 235972, 235973, 235974, 235976, 235977, 235978, 235980, 235986, 235989, 235993, 235994, 235996, 277077, 425892, 425896, 454066, 454504, 454508, 454511, 454513, 454515, 635273, 669050];
  40. public const WORKHUMAN_PRICE_FACTOR = 1.01;
  41. public const PREFIX_DROP = 'baja_';
  42. public const NINE_CUSTOMER_ID = 132688;
  43. public const CUSTOMER_DISABLE_CONTROL_FLAG = '_baja';
  44. public const CUSTOMER_PERCENTAGE_COST_PRICES_INDEXED_BY_CUSTOMER_ID = [self::NINE_CUSTOMER_ID => 0.0];
  45. public const EQUIVALENCE_SURCHARGE_2_NAME = 'REC_EQ_2';
  46. public const EQUIVALENCE_SURCHARGE_2_VALUE = 0.0026;
  47. public const EQUIVALENCE_SURCHARGE_4_NAME = 'REC_EQ_4';
  48. public const EQUIVALENCE_SURCHARGE_4_VALUE = 0.005;
  49. public const EQUIVALENCE_SURCHARGE_5_NAME = 'REC_EQ_5';
  50. public const EQUIVALENCE_SURCHARGE_5_VALUE = 0.006;
  51. public const EQUIVALENCE_SURCHARGE_7_NAME = 'REC_EQ_7';
  52. public const EQUIVALENCE_SURCHARGE_7_VALUE = 0.01;
  53. public const EQUIVALENCE_SURCHARGE_10_NAME = 'REC_EQ_10';
  54. public const EQUIVALENCE_SURCHARGE_10_VALUE = 0.014;
  55. public const EQUIVALENCE_SURCHARGE_21_NAME = 'REC_EQ_21';
  56. public const EQUIVALENCE_SURCHARGE_21_VALUE = 0.052;
  57. public const EQUIVALENCE_SURCHARGE_PERCENTAGE_INDEXED_BY_NAME = [
  58. self::EQUIVALENCE_SURCHARGE_2_NAME => self::EQUIVALENCE_SURCHARGE_2_VALUE,
  59. self::EQUIVALENCE_SURCHARGE_4_NAME => self::EQUIVALENCE_SURCHARGE_4_VALUE,
  60. self::EQUIVALENCE_SURCHARGE_5_NAME => self::EQUIVALENCE_SURCHARGE_5_VALUE,
  61. self::EQUIVALENCE_SURCHARGE_7_NAME => self::EQUIVALENCE_SURCHARGE_7_VALUE,
  62. self::EQUIVALENCE_SURCHARGE_10_NAME => self::EQUIVALENCE_SURCHARGE_10_VALUE,
  63. self::EQUIVALENCE_SURCHARGE_21_NAME => self::EQUIVALENCE_SURCHARGE_21_VALUE,
  64. ];
  65. /**
  66. * @var int
  67. *
  68. * @ORM\Id()
  69. *
  70. * @ORM\GeneratedValue()
  71. *
  72. * @ORM\Column(type="integer", name="id_customer")
  73. */
  74. private $id;
  75. /**
  76. * @var Group
  77. *
  78. * @ORM\ManyToOne(targetEntity="App\Entity\System\Group", inversedBy="customers")
  79. *
  80. * @ORM\JoinColumn(name="id_group", referencedColumnName="id_group", nullable=false)
  81. */
  82. private $group;
  83. /**
  84. * @var Language
  85. *
  86. * @ORM\ManyToOne(targetEntity="App\Entity\System\Language")
  87. *
  88. * @ORM\JoinColumn(name="id_lang", referencedColumnName="id_lang", nullable=false)
  89. */
  90. private $language;
  91. /**
  92. * @var string
  93. *
  94. * @ORM\Column(type="string", length=100, nullable=false)
  95. */
  96. private $name;
  97. /**
  98. * @var string|null
  99. *
  100. * @ORM\Column(type="string", length=32, nullable=true)
  101. */
  102. private $surnames;
  103. /**
  104. * @var string
  105. *
  106. * @Assert\Email
  107. *
  108. * @ORM\Column(type="string", length=128, unique=true)
  109. */
  110. private $email;
  111. /**
  112. * @var string
  113. *
  114. * @ORM\Column(type="string", length=100)
  115. */
  116. private $passwd;
  117. /**
  118. * @var float
  119. *
  120. * @ORM\Column(type="float", nullable=false)
  121. */
  122. private $purse;
  123. /**
  124. * @var \DateTime
  125. *
  126. * @ORM\Column(type="datetime", options={"default" : "CURRENT_TIMESTAMP"})
  127. */
  128. private $lastPasswdGen;
  129. /**
  130. * @var bool
  131. *
  132. * @ORM\Column(type="boolean", options={"default" : 0})
  133. */
  134. private $multifactorAuthEnabled;
  135. /**
  136. * @var int|null
  137. * Number of hours that orders owned by this customer
  138. * must be delayed until confirmed by ERP
  139. *
  140. * @ORM\Column(type="integer", nullable=true)
  141. */
  142. private $orderConfirmationDelay;
  143. /**
  144. * @var bool
  145. *
  146. * @ORM\Column(type="boolean", options={"default" : 0})
  147. */
  148. private $active;
  149. /**
  150. * @var bool
  151. *
  152. * @ORM\Column(type="boolean", options={"default" : 0})
  153. */
  154. private $dropshipping;
  155. /**
  156. * @var \DateTime
  157. *
  158. * @ORM\Column(type="datetime")
  159. */
  160. private $dateAdd;
  161. /**
  162. * @var \DateTime
  163. *
  164. * @ORM\Column(type="datetime")
  165. */
  166. private $dateUpd;
  167. /**
  168. * @var string|null
  169. *
  170. * @ORM\Column(type="text", nullable=true)
  171. */
  172. private $comment;
  173. /**
  174. * @var \DateTime|null
  175. *
  176. * @ORM\Column(type="datetime", nullable=true)
  177. */
  178. private $dateBasicFree;
  179. /**
  180. * @var string|null
  181. *
  182. * @ORM\Column(type="string", length=30, nullable=true, options={"default" : "0"})
  183. */
  184. private $paypalBillingAgreement;
  185. /**
  186. * @var string|null
  187. *
  188. * @ORM\Column(type="string", length=255, nullable=true))
  189. */
  190. private $stripeReference;
  191. /**
  192. * @var \DateTime|null
  193. *
  194. * @ORM\Column(type="datetime", nullable=true)
  195. */
  196. private $datePack;
  197. /**
  198. * @var string|null
  199. *
  200. * @ORM\Column(type="string", length=2, nullable=true)
  201. */
  202. private $csvLang;
  203. /**
  204. * @var string|null
  205. *
  206. * @ORM\Column(type="string", length=50, nullable=true)
  207. */
  208. private $dropshippingName;
  209. /**
  210. * @var string|null
  211. *
  212. * @ORM\Column(type="string", length=100, nullable=true)
  213. */
  214. private $emailPaypal;
  215. /**
  216. * @var bool
  217. *
  218. * @ORM\Column(type="boolean", name="moroso", options={"default" : 0})
  219. */
  220. private $defaulter;
  221. /**
  222. * @var bool
  223. *
  224. * @ORM\Column(type="boolean", options={"default" : 0})
  225. */
  226. private $fraudster;
  227. /**
  228. * @var string|null
  229. *
  230. * @ORM\Column(type="string", length=25, nullable=true)
  231. */
  232. private $payerIdPaypal;
  233. /**
  234. * @var bool|null
  235. *
  236. * @ORM\Column(type="boolean", nullable=true)
  237. */
  238. private $excluirVies;
  239. /**
  240. * @var \DateTime|null
  241. *
  242. * @ORM\Column(type="datetime", nullable=true)
  243. */
  244. private $dateExcluirIva;
  245. /**
  246. * @var bool|null
  247. *
  248. * @ORM\Column(type="boolean", options={"default" : 0}, nullable=true)
  249. */
  250. private $forcePasswordUpdate;
  251. /**
  252. * @var \DateTime|null
  253. *
  254. * @ORM\Column(type="datetime", nullable=true)
  255. */
  256. private $readPolicyCookies;
  257. /**
  258. * @var bool
  259. *
  260. * @ORM\Column(type="boolean", options={"default" : 0}, nullable=false)
  261. */
  262. private $packByPurse;
  263. /**
  264. * @var int
  265. *
  266. * @ORM\Column(type="integer", length=1)
  267. */
  268. private $partialCreation;
  269. /**
  270. * @var bool|null
  271. *
  272. * @ORM\Column(type="boolean", options={"default" : 0}, nullable=true)
  273. */
  274. private $purchaseNotAllowed;
  275. /**
  276. * @var bool|null
  277. *
  278. * @ORM\Column(type="boolean", options={"default" : 0}, nullable=true)
  279. */
  280. private $packBankwirePayment;
  281. /**
  282. * @var Collection<int, Order>&iterable<Order>
  283. *
  284. * @ORM\OneToMany(targetEntity="App\Entity\System\Order", mappedBy="customer")
  285. */
  286. private $orders;
  287. /**
  288. * @var Collection<int, SubscriptionLine>&iterable<SubscriptionLine>
  289. *
  290. * @ORM\OneToMany(targetEntity="App\Entity\System\SubscriptionLine", mappedBy="customer")
  291. */
  292. private $subscriptionLines;
  293. /**
  294. * @var Collection<int, ServiceCustomer>&iterable<ServiceCustomer>
  295. *
  296. * @ORM\OneToMany(targetEntity="App\Entity\System\ServiceCustomer", mappedBy="customer", cascade={"persist"})
  297. */
  298. private $serviceCustomer;
  299. /**
  300. * @var Collection<int, CustomerApi>&iterable<CustomerApi>
  301. *
  302. * @ORM\OneToMany(targetEntity="App\Entity\System\CustomerApi", mappedBy="customer", cascade={"persist"})
  303. */
  304. private $customerApi;
  305. /**
  306. * @var Collection<int, CustomerLog>&iterable<CustomerLog>
  307. *
  308. * @ORM\OneToMany(targetEntity="App\Entity\System\CustomerLog", mappedBy="customer", cascade={"persist"})
  309. */
  310. private $customerLog;
  311. /**
  312. * @var Collection<int, Ftp>&iterable<Ftp>
  313. *
  314. * @ORM\OneToMany(targetEntity="App\Entity\System\Ftp", mappedBy="customer")
  315. */
  316. private $ftp;
  317. /**
  318. * @var Collection<int, SynchronisedShopConfiguration>&iterable<SynchronisedShopConfiguration>
  319. *
  320. * @ORM\OneToMany(targetEntity="App\Entity\System\SynchronisedShopConfiguration", mappedBy="customer")
  321. */
  322. private $syncronisedShopConfiguration;
  323. /**
  324. * @var Collection<int, CustomerMigration>&iterable<CustomerMigration>
  325. *
  326. * @ORM\OneToMany(targetEntity="App\Entity\System\CustomerMigration", mappedBy="customer")
  327. */
  328. private $customerMigration;
  329. /**
  330. * @var Pack
  331. *
  332. * @ORM\ManyToOne(targetEntity="App\Entity\System\Pack")
  333. *
  334. * @ORM\JoinColumn(name="id_pack", referencedColumnName="id_pack", nullable=false)
  335. */
  336. private $pack;
  337. /**
  338. * @var Collection<int, Role>&iterable<Role>
  339. *
  340. * @ORM\ManyToMany(targetEntity="App\Entity\System\Role", inversedBy="customers")
  341. *
  342. * @ORM\JoinTable(name="customer_role",
  343. * joinColumns={@ORM\JoinColumn(name="id_customer", referencedColumnName="id_customer")},
  344. * inverseJoinColumns={@ORM\JoinColumn(name="id_role", referencedColumnName="id_role")}
  345. * )
  346. */
  347. private $roles;
  348. /**
  349. * @var Collection<int, CustomerCatalog>&iterable<CustomerCatalog>
  350. *
  351. * @ORM\OneToMany(targetEntity="App\Entity\System\CustomerCatalog", mappedBy="customer", cascade={"persist"}, indexBy="catalog_id")
  352. */
  353. private $customerCatalogs;
  354. /**
  355. * @var Collection<int, AdditionalInfoAnswer>&iterable<AdditionalInfoAnswer>
  356. *
  357. * @ORM\ManyToMany(targetEntity="App\Entity\System\AdditionalInfoAnswer", inversedBy="customers")
  358. *
  359. * @ORM\JoinTable(
  360. * name="customer_additional_info_answer",
  361. * inverseJoinColumns={@ORM\JoinColumn(name="answer_id", referencedColumnName="id")},
  362. * joinColumns={@ORM\JoinColumn(name="customer_id", referencedColumnName="id_customer")}
  363. * )
  364. */
  365. private $additionalInfoAnswers;
  366. /**
  367. * @var string|null
  368. *
  369. * @ORM\Column(type="string", length=64, nullable=true)
  370. */
  371. private $adyenPaymentId;
  372. /**
  373. * @var Collection<int, Wishlist>&iterable<Wishlist>
  374. *
  375. * @ORM\OneToMany(targetEntity="App\Entity\System\Wishlist", mappedBy="customer", cascade={"persist"})
  376. */
  377. private $wishlists;
  378. /**
  379. * @var string|null
  380. *
  381. * @ORM\Column(type="string", length=50, nullable=true)
  382. */
  383. private $googleAccountId;
  384. /**
  385. * @var string|null
  386. *
  387. * @ORM\Column(type="string", length=50, nullable=true)
  388. */
  389. private $linkedinAccountId;
  390. /**
  391. * @ORM\Column(type="string", nullable=true)
  392. */
  393. private ?string $hubspotCompanyId = null;
  394. /**
  395. * @ORM\Column(type="string", nullable=true)
  396. */
  397. private ?string $hubspotContactId = null;
  398. /**
  399. * @var \DateTime|null
  400. *
  401. * @ORM\Column(type="datetime", nullable=true)
  402. */
  403. private ?\DateTime $lastAccess = null;
  404. /**
  405. * @ORM\Column(type="string", length=255, nullable=true)
  406. */
  407. private ?string $stripeDefaultPaymentMethodReference;
  408. /**
  409. * @ORM\OneToOne(targetEntity="App\Entity\System\CustomerInvoiceAddress", mappedBy="customer")
  410. */
  411. private ?CustomerInvoiceAddress $customerInvoiceAddress = null;
  412. /**
  413. * @var Collection<int, CustomerPaymentMethod>
  414. *
  415. * @ORM\OneToMany(targetEntity="App\Entity\System\CustomerPaymentMethod", mappedBy="customer")
  416. */
  417. private $customerPaymentMethods;
  418. /**
  419. * Customer constructor.
  420. *
  421. * @throws \Exception
  422. */
  423. public function __construct()
  424. {
  425. $this->lastPasswdGen = new \DateTime();
  426. $this->active = false;
  427. $this->dropshipping = false;
  428. $this->paypalBillingAgreement = '0';
  429. $this->defaulter = false;
  430. $this->fraudster = false;
  431. $this->orders = new ArrayCollection();
  432. $this->subscriptionLines = new ArrayCollection();
  433. $this->serviceCustomer = new ArrayCollection();
  434. $this->customerApi = new ArrayCollection();
  435. $this->customerLog = new ArrayCollection();
  436. $this->customerMigration = new ArrayCollection();
  437. $this->syncronisedShopConfiguration = new ArrayCollection();
  438. $this->ftp = new ArrayCollection();
  439. $this->roles = new ArrayCollection();
  440. $this->customerCatalogs = new ArrayCollection();
  441. $this->additionalInfoAnswers = new ArrayCollection();
  442. $this->wishlists = new ArrayCollection();
  443. $this->dateAdd = new \DateTime();
  444. $this->multifactorAuthEnabled = true;
  445. $this->forcePasswordUpdate = false;
  446. $this->purchaseNotAllowed = false;
  447. $this->packByPurse = false;
  448. $this->customerPaymentMethods = new ArrayCollection();
  449. }
  450. public static function createEmptyCustomer(string $email, string $password, Group $group, Role $role, Language $language, \DateTime $currentDateTime): Customer
  451. {
  452. $customer = new self();
  453. $customer->email = $email;
  454. $customer->passwd = $password;
  455. $customer->language = $language;
  456. $customer->active = true;
  457. $customer->purse = 0;
  458. $customer->dateAdd = $currentDateTime;
  459. $customer->dateUpd = $currentDateTime;
  460. $customer->dateExcluirIva = null;
  461. $customer->packByPurse = false;
  462. $customer->group = $group;
  463. $customer->name = '';
  464. $customer->partialCreation = self::PARTIAL_CREATION_STEP_1_ID;
  465. $customer->multifactorAuthEnabled = true;
  466. $customer->roles = new ArrayCollection([$role]);
  467. $customer->wishlists = new ArrayCollection([WishListFactory::createDefault($customer, $customer->getLanguage()->getId())]);
  468. return $customer;
  469. }
  470. public function getPassword(): string
  471. {
  472. return $this->getPasswd();
  473. }
  474. public function getSalt(): ?string
  475. {
  476. return null;
  477. }
  478. public function getUsername(): string
  479. {
  480. return $this->email;
  481. }
  482. public function eraseCredentials(): void
  483. {
  484. }
  485. public function getEncoderName(): ?string
  486. {
  487. return 'customer_encoder';
  488. }
  489. public function getId(): int
  490. {
  491. return $this->id;
  492. }
  493. public function getUserIdentifier(): string
  494. {
  495. return (string)$this->id;
  496. }
  497. public function setId(int $id): Customer
  498. {
  499. $this->id = $id;
  500. return $this;
  501. }
  502. public function getGroup(): Group
  503. {
  504. return $this->group;
  505. }
  506. public function setGroup(Group $group): Customer
  507. {
  508. $this->group = $group;
  509. return $this;
  510. }
  511. public function getLanguage(): Language
  512. {
  513. return $this->language;
  514. }
  515. public function setLanguage(Language $language): Customer
  516. {
  517. $this->language = $language;
  518. return $this;
  519. }
  520. public function getName(): string
  521. {
  522. return $this->name;
  523. }
  524. public function setName(string $name): Customer
  525. {
  526. $this->name = $name;
  527. return $this;
  528. }
  529. public function getSurnames(): ?string
  530. {
  531. return $this->surnames;
  532. }
  533. public function getLastname(): ?string
  534. {
  535. return $this->surnames;
  536. }
  537. public function setSurnames(?string $surnames): Customer
  538. {
  539. $this->surnames = $surnames;
  540. return $this;
  541. }
  542. public function getEmail(): string
  543. {
  544. return $this->email;
  545. }
  546. public function setEmail(string $email): Customer
  547. {
  548. $this->email = $email;
  549. return $this;
  550. }
  551. public function getPasswd(): string
  552. {
  553. return $this->passwd;
  554. }
  555. public function setPasswd(string $passwd): Customer
  556. {
  557. $this->passwd = $passwd;
  558. return $this;
  559. }
  560. public function getPurse(): float
  561. {
  562. return $this->purse;
  563. }
  564. public function setPurse(float $purse): Customer
  565. {
  566. $this->purse = $purse;
  567. return $this;
  568. }
  569. public function getLastPasswdGen(): \DateTime
  570. {
  571. return $this->lastPasswdGen;
  572. }
  573. public function setLastPasswdGen(\DateTime $lastPasswdGen): Customer
  574. {
  575. $this->lastPasswdGen = $lastPasswdGen;
  576. return $this;
  577. }
  578. public function isActive(): bool
  579. {
  580. return $this->active;
  581. }
  582. public function isEnabled(): bool
  583. {
  584. return $this->active;
  585. }
  586. public function setActive(bool $active): Customer
  587. {
  588. $this->active = $active;
  589. return $this;
  590. }
  591. public function isDropshipping(): bool
  592. {
  593. return $this->dropshipping;
  594. }
  595. public function setDropshipping(bool $dropshipping): Customer
  596. {
  597. $this->dropshipping = $dropshipping;
  598. return $this;
  599. }
  600. public function getDateAdd(): \DateTime
  601. {
  602. return $this->dateAdd;
  603. }
  604. public function setDateAdd(\DateTime $dateAdd): Customer
  605. {
  606. $this->dateAdd = $dateAdd;
  607. return $this;
  608. }
  609. public function getDateUpd(): \DateTime
  610. {
  611. return $this->dateUpd;
  612. }
  613. public function setDateUpd(\DateTime $dateUpd): Customer
  614. {
  615. $this->dateUpd = $dateUpd;
  616. return $this;
  617. }
  618. public function getComment(): ?string
  619. {
  620. return $this->comment;
  621. }
  622. public function setComment(?string $comment): Customer
  623. {
  624. $this->comment = $comment;
  625. return $this;
  626. }
  627. public function getDateBasicFree(): ?\DateTime
  628. {
  629. return $this->dateBasicFree;
  630. }
  631. public function setDateBasicFree(?\DateTime $dateBasicFree): Customer
  632. {
  633. $this->dateBasicFree = $dateBasicFree;
  634. return $this;
  635. }
  636. public function getPaypalBillingAgreement(): ?string
  637. {
  638. if ($this->paypalBillingAgreement === '0' || $this->paypalBillingAgreement === '') {
  639. return null;
  640. }
  641. return $this->paypalBillingAgreement;
  642. }
  643. public function setPaypalBillingAgreement(?string $paypalBillingAgreement): Customer
  644. {
  645. $this->paypalBillingAgreement = $paypalBillingAgreement;
  646. return $this;
  647. }
  648. public function getDatePack(): ?\DateTime
  649. {
  650. return $this->datePack;
  651. }
  652. public function setDatePack(?\DateTime $datePack): Customer
  653. {
  654. $this->datePack = $datePack;
  655. return $this;
  656. }
  657. public function getCsvLang(): ?string
  658. {
  659. return $this->csvLang;
  660. }
  661. public function setCsvLang(?string $csvLang): Customer
  662. {
  663. $this->csvLang = $csvLang;
  664. return $this;
  665. }
  666. public function getDropshippingName(): ?string
  667. {
  668. return $this->dropshippingName;
  669. }
  670. public function setDropshippingName(?string $dropshippingName): Customer
  671. {
  672. $this->dropshippingName = $dropshippingName;
  673. return $this;
  674. }
  675. public function getEmailPaypal(): ?string
  676. {
  677. return $this->emailPaypal;
  678. }
  679. public function setEmailPaypal(?string $emailPaypal): Customer
  680. {
  681. $this->emailPaypal = $emailPaypal;
  682. return $this;
  683. }
  684. public function isDefaulter(): bool
  685. {
  686. return $this->defaulter;
  687. }
  688. public function setDefaulter(bool $defaulter): Customer
  689. {
  690. $this->defaulter = $defaulter;
  691. return $this;
  692. }
  693. public function isFraudster(): bool
  694. {
  695. return $this->fraudster;
  696. }
  697. public function setFraudster(bool $fraudster): Customer
  698. {
  699. $this->fraudster = $fraudster;
  700. return $this;
  701. }
  702. public function getPayerIdPaypal(): ?string
  703. {
  704. return $this->payerIdPaypal;
  705. }
  706. public function setPayerIdPaypal(?string $payerIdPaypal): Customer
  707. {
  708. $this->payerIdPaypal = $payerIdPaypal;
  709. return $this;
  710. }
  711. public function getExcluirVies(): ?bool
  712. {
  713. return $this->excluirVies;
  714. }
  715. public function setExcluirVies(?bool $excluirVies): Customer
  716. {
  717. $this->excluirVies = $excluirVies;
  718. return $this;
  719. }
  720. public function getDateExcluirIva(): ?\DateTime
  721. {
  722. return $this->dateExcluirIva;
  723. }
  724. public function setDateExcluirIva(?\DateTime $dateExcluirIva): Customer
  725. {
  726. $this->dateExcluirIva = $dateExcluirIva;
  727. return $this;
  728. }
  729. public function getReadPolicyCookies(): ?\DateTime
  730. {
  731. return $this->readPolicyCookies;
  732. }
  733. public function setReadPolicyCookies(?\DateTime $readPolicyCookies): Customer
  734. {
  735. $this->readPolicyCookies = $readPolicyCookies;
  736. return $this;
  737. }
  738. public function getPackByPurse(): bool
  739. {
  740. return $this->packByPurse;
  741. }
  742. public function setPackByPurse(bool $packByPurse): Customer
  743. {
  744. $this->packByPurse = $packByPurse;
  745. return $this;
  746. }
  747. public function getPartialCreation(): int
  748. {
  749. return $this->partialCreation;
  750. }
  751. public function setPartialCreation(int $partialCreation): Customer
  752. {
  753. $this->partialCreation = $partialCreation;
  754. return $this;
  755. }
  756. /**
  757. * @return Collection<int, Order>&iterable<Order>
  758. */
  759. public function getOrders()
  760. {
  761. throw new \LogicException();
  762. }
  763. public function getPurchaseNotAllowed(): ?bool
  764. {
  765. return $this->purchaseNotAllowed;
  766. }
  767. public function setPurchaseNotAllowed(?bool $purchaseNotAllowed): self
  768. {
  769. $this->purchaseNotAllowed = $purchaseNotAllowed;
  770. return $this;
  771. }
  772. /**
  773. * @return Collection<int, SubscriptionLine>&iterable<SubscriptionLine>
  774. */
  775. public function getSubscriptionLines()
  776. {
  777. return $this->subscriptionLines;
  778. }
  779. /**
  780. * @param Collection<int, SubscriptionLine>&iterable<SubscriptionLine> $subscriptionLines
  781. *
  782. * @return Customer
  783. */
  784. public function setSubscriptionLines($subscriptionLines)
  785. {
  786. $this->subscriptionLines = $subscriptionLines;
  787. return $this;
  788. }
  789. /**
  790. * @return Collection<int, ServiceCustomer>&iterable<ServiceCustomer>
  791. */
  792. public function getServiceCustomer()
  793. {
  794. return $this->serviceCustomer;
  795. }
  796. /**
  797. * @param Collection<int, ServiceCustomer>&iterable<ServiceCustomer> $serviceCustomer
  798. */
  799. public function setServiceCustomer($serviceCustomer): Customer
  800. {
  801. $this->serviceCustomer = $serviceCustomer;
  802. return $this;
  803. }
  804. /**
  805. * @return Collection<int, CustomerApi>&iterable<CustomerApi>
  806. */
  807. public function getCustomerApi()
  808. {
  809. return $this->customerApi;
  810. }
  811. /**
  812. * @param Collection<int, CustomerApi>&iterable<CustomerApi> $customerApi
  813. */
  814. public function setCustomerApi($customerApi): Customer
  815. {
  816. $this->customerApi = $customerApi;
  817. return $this;
  818. }
  819. /**
  820. * @return Collection<int, CustomerLog>&iterable<CustomerLog>
  821. */
  822. public function getCustomerLog()
  823. {
  824. return $this->customerLog;
  825. }
  826. /**
  827. * @param Collection<int, CustomerLog>&iterable<CustomerLog> $customerLog
  828. */
  829. public function setCustomerLog($customerLog): Customer
  830. {
  831. $this->customerLog = $customerLog;
  832. return $this;
  833. }
  834. /**
  835. * @return Collection<int, Ftp>&iterable<Ftp>
  836. */
  837. public function getFtp()
  838. {
  839. return $this->ftp;
  840. }
  841. /**
  842. * @param Collection<int, Ftp>&iterable<Ftp> $ftp
  843. */
  844. public function setFtp($ftp): Customer
  845. {
  846. $this->ftp = $ftp;
  847. return $this;
  848. }
  849. /**
  850. * @return Collection<int, SynchronisedShopConfiguration>&iterable<SynchronisedShopConfiguration>
  851. */
  852. public function getSyncronisedShopConfiguration()
  853. {
  854. return $this->syncronisedShopConfiguration;
  855. }
  856. /**
  857. * @param Collection<int, SynchronisedShopConfiguration>&iterable<SynchronisedShopConfiguration> $syncronisedShopConfiguration
  858. */
  859. public function setSyncronisedShopConfiguration($syncronisedShopConfiguration): Customer
  860. {
  861. $this->syncronisedShopConfiguration = $syncronisedShopConfiguration;
  862. return $this;
  863. }
  864. /**
  865. * @return Collection<int, CustomerMigration>&iterable<CustomerMigration>
  866. */
  867. public function getCustomerMigration()
  868. {
  869. return $this->customerMigration;
  870. }
  871. /**
  872. * @param Collection<int, CustomerMigration>&iterable<CustomerMigration> $customerMigration
  873. */
  874. public function setCustomerMigration($customerMigration): Customer
  875. {
  876. $this->customerMigration = $customerMigration;
  877. return $this;
  878. }
  879. public function getRoles(): array
  880. {
  881. $roles = [];
  882. foreach ($this->roles as $role) {
  883. $roleName = $role->getName();
  884. if (!$role->isEmployee() && !in_array($roleName, $roles, true)) {
  885. $roles[$role->getId()] = $role->getName();
  886. }
  887. }
  888. return $roles;
  889. }
  890. public function hasRole(string $roleName): bool
  891. {
  892. return \in_array(\strtoupper($roleName), $this->getRoles(), true);
  893. }
  894. /**
  895. * @return Collection<int, Role>&iterable<Role>
  896. */
  897. public function getRoleCollection()
  898. {
  899. return $this->roles;
  900. }
  901. /**
  902. * @param Collection<int, Role>&iterable<Role> $roles
  903. */
  904. public function setRoleCollection($roles): Customer
  905. {
  906. $this->roles = $roles;
  907. return $this;
  908. }
  909. public function hasMultifactorAuthEnabled(): bool
  910. {
  911. return $this->multifactorAuthEnabled;
  912. }
  913. /**
  914. * Resets paypal-related fields
  915. */
  916. public function resetBillingAgreement(): void
  917. {
  918. $this->setPaypalBillingAgreement(null);
  919. $this->setEmailPaypal('');
  920. $this->setPayerIdPaypal('');
  921. }
  922. public function setPackValuesFromOldCustomer(Customer $oldCustomer): void
  923. {
  924. $this->group = $oldCustomer->getGroup();
  925. $this->pack = $oldCustomer->getPack();
  926. $this->datePack = $oldCustomer->getDatePack();
  927. $this->payerIdPaypal = $oldCustomer->getPayerIdPaypal();
  928. $this->emailPaypal = $oldCustomer->getEmailPaypal();
  929. }
  930. public function setValuesAfterMigration(Group $groupReference): void
  931. {
  932. $this->group = $groupReference;
  933. $this->datePack = null;
  934. $this->purchaseNotAllowed = true;
  935. }
  936. /**
  937. * @return Collection<int, CustomerCatalog>&iterable<CustomerCatalog>
  938. */
  939. public function getCustomerCatalogs()
  940. {
  941. return $this->customerCatalogs;
  942. }
  943. /**
  944. * @param Collection<int, CustomerCatalog>&iterable<CustomerCatalog> $customerCatalogs
  945. */
  946. public function setCustomerCatalogs($customerCatalogs): self
  947. {
  948. $this->customerCatalogs = $customerCatalogs;
  949. return $this;
  950. }
  951. public function getFullName(): string
  952. {
  953. return $this->name.' '.$this->surnames;
  954. }
  955. public function setMultifactorAuthEnabled(bool $multifactorAuthEnabled): void
  956. {
  957. $this->multifactorAuthEnabled = $multifactorAuthEnabled;
  958. }
  959. public function removeAllAnswers(): void
  960. {
  961. $this->additionalInfoAnswers->clear();
  962. }
  963. public function addAnswers(array $answers): void
  964. {
  965. /** @var AdditionalInfoAnswer|null $answer */
  966. foreach ($answers as $answer) {
  967. if ($answer && !$this->additionalInfoAnswers->contains($answer)) {
  968. $this->additionalInfoAnswers->add($answer);
  969. }
  970. }
  971. }
  972. public function getAdyenPaymentId(): ?string
  973. {
  974. return $this->adyenPaymentId;
  975. }
  976. public function setAdyenPaymentId(?string $adyenPaymentId): self
  977. {
  978. $this->adyenPaymentId = $adyenPaymentId;
  979. return $this;
  980. }
  981. /**
  982. * @return Collection<int, Wishlist>&iterable<Wishlist>
  983. */
  984. public function getWishlists()
  985. {
  986. return $this->wishlists;
  987. }
  988. public function checkInactive(): bool
  989. {
  990. return str_starts_with($this->email, self::PREFIX_DROP);
  991. }
  992. public function getGoogleAccountId(): ?string
  993. {
  994. return $this->googleAccountId;
  995. }
  996. public function setGoogleAccountId(?string $googleAccountId): Customer
  997. {
  998. $this->googleAccountId = $googleAccountId;
  999. return $this;
  1000. }
  1001. public function getLinkedinAccountId(): ?string
  1002. {
  1003. return $this->linkedinAccountId;
  1004. }
  1005. public function setLinkedinAccountId(?string $linkedinAccountId): Customer
  1006. {
  1007. $this->linkedinAccountId = $linkedinAccountId;
  1008. return $this;
  1009. }
  1010. public function getPackBankwirePayment(): ?bool
  1011. {
  1012. return $this->packBankwirePayment;
  1013. }
  1014. public function setPackBankwirePayment(bool $packBankwirePayment): Customer
  1015. {
  1016. $this->packBankwirePayment = $packBankwirePayment;
  1017. return $this;
  1018. }
  1019. public function getForcePasswordUpdate(): ?bool
  1020. {
  1021. return $this->forcePasswordUpdate;
  1022. }
  1023. public function setForcePasswordUpdate(?bool $forcePasswordUpdate): void
  1024. {
  1025. $this->forcePasswordUpdate = $forcePasswordUpdate;
  1026. }
  1027. public function getHubspotCompanyId(): ?string
  1028. {
  1029. return $this->hubspotCompanyId;
  1030. }
  1031. public function setHubspotCompanyId(string $hubspotCompanyId): Customer
  1032. {
  1033. $this->hubspotCompanyId = $hubspotCompanyId;
  1034. return $this;
  1035. }
  1036. public function getHubspotContactId(): ?string
  1037. {
  1038. return $this->hubspotContactId;
  1039. }
  1040. public function setHubspotContactId(?string $hubspotContactId): Customer
  1041. {
  1042. $this->hubspotContactId = $hubspotContactId;
  1043. return $this;
  1044. }
  1045. public function getOrderConfirmationDelay(): ?int
  1046. {
  1047. if (null === $this->orderConfirmationDelay) {
  1048. return null;
  1049. }
  1050. if (0 === $this->orderConfirmationDelay) { // set by legacy model
  1051. return null;
  1052. }
  1053. return $this->orderConfirmationDelay;
  1054. }
  1055. public function setOrderConfirmationDelay(?int $orderConfirmationDelay): void
  1056. {
  1057. $this->orderConfirmationDelay = $orderConfirmationDelay;
  1058. }
  1059. public function getLastAccess(): ?\DateTime
  1060. {
  1061. return $this->lastAccess;
  1062. }
  1063. public function setLastAccess(?\DateTime $lastAccess): Customer
  1064. {
  1065. $this->lastAccess = $lastAccess;
  1066. return $this;
  1067. }
  1068. public function __toString(): string
  1069. {
  1070. return $this->name.' '.$this->surnames;
  1071. }
  1072. public function getStripeReference(): ?string
  1073. {
  1074. return $this->stripeReference;
  1075. }
  1076. public function setStripeReference(?string $stripeReference): Customer
  1077. {
  1078. $this->stripeReference = $stripeReference;
  1079. return $this;
  1080. }
  1081. public function getStripeDefaultPaymentMethodReference(): ?string
  1082. {
  1083. return $this->stripeDefaultPaymentMethodReference;
  1084. }
  1085. public function setStripeDefaultPaymentMethodReference(?string $stripeDefaultPaymentMethodReference): Customer
  1086. {
  1087. $this->stripeDefaultPaymentMethodReference = $stripeDefaultPaymentMethodReference;
  1088. return $this;
  1089. }
  1090. public function getCustomerInvoiceAddress(): ?CustomerInvoiceAddress
  1091. {
  1092. return $this->customerInvoiceAddress;
  1093. }
  1094. public function setCustomerInvoiceAddress(CustomerInvoiceAddress $customerInvoiceAddress): Customer
  1095. {
  1096. $this->customerInvoiceAddress = $customerInvoiceAddress;
  1097. return $this;
  1098. }
  1099. public function getPack(): Pack
  1100. {
  1101. return $this->pack;
  1102. }
  1103. public function setPack(Pack $pack): Customer
  1104. {
  1105. $this->pack = $pack;
  1106. return $this;
  1107. }
  1108. }