|
|
@ -68,15 +68,26 @@ class ConvertUser extends Command
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function insertPhone($phones,$userId)
|
|
|
|
private function insertPhone($phones,$userId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$phones = json_decode($phones);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($phones as $phone)
|
|
|
|
foreach($phones as $phone)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$number_type ;
|
|
|
|
|
|
|
|
$regex = '/^09[0,1,2,3,9]{1}[0-9]{8}$/';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (preg_match($regex,$phone->tel) == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$number_type = 'cellphone';
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$number_type = 'telephone';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Database::table('wmuser_common.phones')->insertOrIgnore([
|
|
|
|
Database::table('wmuser_common.phones')->insertOrIgnore([
|
|
|
|
'phonable_id' => $userId,
|
|
|
|
'phonable_id' => $userId,
|
|
|
|
'number' => $phone->tel,
|
|
|
|
'number' => $phone->tel,
|
|
|
|
'label' => $phone->label,
|
|
|
|
'label' => $phone->label,
|
|
|
|
|
|
|
|
'number_type' => $number_type,
|
|
|
|
'phonable_type' => 'user',
|
|
|
|
'phonable_type' => 'user',
|
|
|
|
'created_at' => Carbon::now(),
|
|
|
|
'created_at' => Carbon::now(),
|
|
|
|
'updated_at' => Carbon::now(),
|
|
|
|
'updated_at' => Carbon::now(),
|
|
|
@ -127,8 +138,7 @@ class ConvertUser extends Command
|
|
|
|
private function insertToClientStatuses($clientStatus)
|
|
|
|
private function insertToClientStatuses($clientStatus)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$check_client_status = Database::table('wmuser_crm.client_statuses')
|
|
|
|
$check_client_status = DB::table('wmuser_crm.client_statuses')
|
|
|
|
|
|
|
|
->where('name' , $clientStatus)
|
|
|
|
->where('name' , $clientStatus)
|
|
|
|
->first();
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
|
@ -195,7 +205,7 @@ class ConvertUser extends Command
|
|
|
|
Database::table('wmuser_crm.client_categories')->insertOrIgnore([
|
|
|
|
Database::table('wmuser_crm.client_categories')->insertOrIgnore([
|
|
|
|
'name_en' => $category->name_en,
|
|
|
|
'name_en' => $category->name_en,
|
|
|
|
'name' => $category->name_fa,
|
|
|
|
'name' => $category->name_fa,
|
|
|
|
'parent_id' => $category->parent_id,
|
|
|
|
'parent_id' => null,
|
|
|
|
'business_id' => 3,
|
|
|
|
'business_id' => 3,
|
|
|
|
'user_id' => $client_id,
|
|
|
|
'user_id' => $client_id,
|
|
|
|
'level' => 1,
|
|
|
|
'level' => 1,
|
|
|
@ -244,12 +254,27 @@ class ConvertUser extends Command
|
|
|
|
|
|
|
|
|
|
|
|
$cellPhone = null;
|
|
|
|
$cellPhone = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($phones as $phone)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$phone->tel = str_replace(' ','',$phone->tel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for( $i=0; $i <= count($phones)-1 ; $i++ )
|
|
|
|
for( $i=0; $i <= count($phones)-1 ; $i++ )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if($phones[$i]->label == 'Mobile')
|
|
|
|
|
|
|
|
|
|
|
|
$regex = '/^09[0,1,2,3,9]{1}[0-9]{8}$/';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$match = preg_match($regex,$phones[$i]->tel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($match == 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cellPhone = $phones[$i]->tel;
|
|
|
|
$cellPhone = $phones[$i]->tel;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -264,6 +289,7 @@ class ConvertUser extends Command
|
|
|
|
|
|
|
|
|
|
|
|
$userTableData = [
|
|
|
|
$userTableData = [
|
|
|
|
'name' => $userData->brand_fa,
|
|
|
|
'name' => $userData->brand_fa,
|
|
|
|
|
|
|
|
'name_en' => $userData->brand_en,
|
|
|
|
'business_id' => 3,
|
|
|
|
'business_id' => 3,
|
|
|
|
'cell_number' => $cellPhone,
|
|
|
|
'cell_number' => $cellPhone,
|
|
|
|
'detail' => json_encode($userTableDedails),
|
|
|
|
'detail' => json_encode($userTableDedails),
|
|
|
@ -284,7 +310,7 @@ class ConvertUser extends Command
|
|
|
|
$newUserId = $this->insertRowToUsers($userTableData);
|
|
|
|
$newUserId = $this->insertRowToUsers($userTableData);
|
|
|
|
$this->categoriesConfig($userData->category_id, $newUserId);
|
|
|
|
$this->categoriesConfig($userData->category_id, $newUserId);
|
|
|
|
$this->InsertAddress($userAddress, $userData->id,$newUserId);
|
|
|
|
$this->InsertAddress($userAddress, $userData->id,$newUserId);
|
|
|
|
$this->insertPhone($userData->phones , $newUserId);
|
|
|
|
$this->insertPhone($phones , $newUserId);
|
|
|
|
$lastStatusId = $this->insertToClientStatuses($userData->status);
|
|
|
|
$lastStatusId = $this->insertToClientStatuses($userData->status);
|
|
|
|
$this->updateToUserStatus($newUserId,$lastStatusId);
|
|
|
|
$this->updateToUserStatus($newUserId,$lastStatusId);
|
|
|
|
$count ++;
|
|
|
|
$count ++;
|
|
|
|