Add generated id to customer. #638

This commit is contained in:
Korina Cordero 2021-11-10 06:51:27 +00:00
parent d6cf2de4ab
commit f828db422f
2 changed files with 29 additions and 2 deletions

View file

@ -222,6 +222,12 @@ class Customer
*/
protected $car_club_customer_hub;
// random generated unique id
/**
* @ORM\Column(type="string", length=40, nullable=true)
*/
protected $generated_id;
public function __construct()
{
$this->numbers = new ArrayCollection();
@ -259,6 +265,8 @@ class Customer
$this->date_create = new DateTime();
$this->create_source = 'unknown';
$this->generated_id = '';
}
public function getID()
@ -674,4 +682,5 @@ class Customer
{
return $this->car_club_customer_hub;
}
}

View file

@ -13,10 +13,28 @@ class UniqueIdGenerator
$this->em = $em;
}
public function generateUniqueId($str_length)
public function generateCustomerUniqueId($str_length)
{
// TODO: retry until we get a unique id
// retry until we get a unique id
while (true)
{
try
{
}
catch (DBALException $e)
{
error_log($e->getMessage());
// delay one second and try again
sleep(1);
continue;
}
break;
}
}
protected function generateUniqueId($str_length)
{
return substr(md5(time()), 0, $str_length);
}
}