phase 2 dev
This commit is contained in:
parent
5a7478907e
commit
ba48745809
59 changed files with 2692 additions and 1994 deletions
|
|
@ -90,7 +90,7 @@ class ContactsMergeDuplicates extends Command
|
|||
|
||||
private function findByEmail(): array
|
||||
{
|
||||
return DB::table('customer')
|
||||
return DB::table('contacts')
|
||||
->select('email', DB::raw('GROUP_CONCAT(id ORDER BY updated_at DESC, id DESC) as ids'))
|
||||
->whereNotNull('email')
|
||||
->where('email', '!=', '')
|
||||
|
|
@ -104,7 +104,7 @@ class ContactsMergeDuplicates extends Command
|
|||
|
||||
private function findByNameBirthdate(): array
|
||||
{
|
||||
return DB::table('customer')
|
||||
return DB::table('contacts')
|
||||
->select(DB::raw('GROUP_CONCAT(id ORDER BY updated_at DESC, id DESC) as ids'))
|
||||
->whereNotNull('name')
|
||||
->whereNotNull('firstname')
|
||||
|
|
@ -119,7 +119,7 @@ class ContactsMergeDuplicates extends Command
|
|||
|
||||
private function findByNameZip(): array
|
||||
{
|
||||
return DB::table('customer')
|
||||
return DB::table('contacts')
|
||||
->select(DB::raw('GROUP_CONCAT(id ORDER BY updated_at DESC, id DESC) as ids'))
|
||||
->whereNotNull('name')
|
||||
->whereNotNull('firstname')
|
||||
|
|
@ -173,11 +173,11 @@ class ContactsMergeDuplicates extends Command
|
|||
private function mergeInto(int $masterId, int $dupeId): void
|
||||
{
|
||||
// 1. Leads umhängen
|
||||
$leadCount = DB::table('lead')->where('customer_id', $dupeId)->count();
|
||||
$leadCount = DB::table('inquiries')->where('customer_id', $dupeId)->count();
|
||||
if ($leadCount > 0) {
|
||||
$this->line(" lead.customer_id: {$leadCount} Zeile(n) → #{$masterId}");
|
||||
if (!$this->dryRun) {
|
||||
DB::table('lead')
|
||||
DB::table('inquiries')
|
||||
->where('customer_id', $dupeId)
|
||||
->update(['customer_id' => $masterId]);
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ class ContactsMergeDuplicates extends Command
|
|||
|
||||
// 5. Duplikat als zusammengeführt markieren
|
||||
if (!$this->dryRun) {
|
||||
DB::table('customer')
|
||||
DB::table('contacts')
|
||||
->where('id', $dupeId)
|
||||
->update([
|
||||
'merged_into_id' => $masterId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue