deplay phase 1
This commit is contained in:
parent
e3dc1afd8e
commit
5a7478907e
68 changed files with 2831 additions and 818 deletions
|
|
@ -37,7 +37,7 @@ class ContactsFindDuplicates extends Command
|
|||
|
||||
// ── HIGH: gleiche E-Mail ──────────────────────────────────────────
|
||||
if ($this->shouldCheck('HIGH')) {
|
||||
$emailDupes = DB::table('contacts')
|
||||
$emailDupes = DB::table('customer')
|
||||
->select('email', DB::raw('COUNT(*) as cnt'), DB::raw('GROUP_CONCAT(id ORDER BY updated_at DESC) as ids'))
|
||||
->whereNotNull('email')
|
||||
->where('email', '!=', '')
|
||||
|
|
@ -60,7 +60,7 @@ class ContactsFindDuplicates extends Command
|
|||
|
||||
// ── MEDIUM: Name + Vorname + Geburtsdatum ────────────────────────
|
||||
if ($this->shouldCheck('MEDIUM')) {
|
||||
$nameBdDupes = DB::table('contacts')
|
||||
$nameBdDupes = DB::table('customer')
|
||||
->select(
|
||||
'name', 'firstname', 'birthdate',
|
||||
DB::raw('COUNT(*) as cnt'),
|
||||
|
|
@ -88,7 +88,7 @@ class ContactsFindDuplicates extends Command
|
|||
|
||||
// ── LOW: Name + Vorname + PLZ ─────────────────────────────────────
|
||||
if ($this->shouldCheck('LOW')) {
|
||||
$nameZipDupes = DB::table('contacts')
|
||||
$nameZipDupes = DB::table('customer')
|
||||
->select(
|
||||
'name', 'firstname', 'zip',
|
||||
DB::raw('COUNT(*) as cnt'),
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class ContactsMergeDuplicates extends Command
|
|||
|
||||
private function findByEmail(): array
|
||||
{
|
||||
return DB::table('contacts')
|
||||
return DB::table('customer')
|
||||
->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('contacts')
|
||||
return DB::table('customer')
|
||||
->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('contacts')
|
||||
return DB::table('customer')
|
||||
->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('inquiries')->where('customer_id', $dupeId)->count();
|
||||
$leadCount = DB::table('lead')->where('customer_id', $dupeId)->count();
|
||||
if ($leadCount > 0) {
|
||||
$this->line(" lead.customer_id: {$leadCount} Zeile(n) → #{$masterId}");
|
||||
if (!$this->dryRun) {
|
||||
DB::table('inquiries')
|
||||
DB::table('lead')
|
||||
->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('contacts')
|
||||
DB::table('customer')
|
||||
->where('id', $dupeId)
|
||||
->update([
|
||||
'merged_into_id' => $masterId,
|
||||
|
|
|
|||
|
|
@ -193,8 +193,7 @@ class SyncNewsletterKulturreisen extends Command
|
|||
'description' => 'Kontakt durch Kulturreisen-Buchung erstellt',
|
||||
'metadata' => [
|
||||
'booking_id' => $booking->id,
|
||||
// Metadaten-Key bleibt `lead_id`; Wert kommt aus booking.inquiry_id.
|
||||
'lead_id' => $booking->inquiry_id,
|
||||
'lead_id' => $booking->lead_id,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue