Proje: Okul Database · Hub: Okul Database — Tables
customers Tablosu
B2B organizasyon/firma hesabı. Okul sahibi veya yöneticisi olan kurumsal müşteriler.
Tam Kolon Listesi
| Kolon | Tip | Nullable | Default | Açıklama |
|---|---|---|---|---|
id | increments | NO | — | PK |
redirect_id | unsignedInt | YES | NULL | → customers.id (yönlendirme) |
current_segment_id | int | YES | NULL | Mevcut segment |
potential_segment_id | int | YES | NULL | Potansiyel segment |
name | varchar(255) | NO | — | Yetkili kişi adı |
firm_name | varchar(255) | YES | NULL | Firma ticari adı |
is_individual | enum(‘0’,‘1’) | NO | — | 1=Bireysel, 0=Kurumsal |
email | varchar(255) | YES | NULL | Firma e-posta |
phone | varchar(255) | YES | NULL | Sabit telefon |
gsm | varchar(255) | YES | NULL | Cep telefonu |
web | varchar(255) | YES | NULL | Web sitesi |
billing_address | varchar(255) | YES | NULL | Fatura adresi |
billing_office | varchar(255) | YES | NULL | Fatura şubesi |
billing_no | varchar(255) | YES | NULL | Fatura numarası |
tc_no | decimal(11,0) | YES | NULL | TC kimlik no |
invoice_email | varchar(255) | YES | NULL | Fatura e-posta |
invoice_type | varchar(255) | YES | NULL | Fatura tipi |
company_type | varchar(255) | NO | 'merchant' | Şirket tipi |
company_extension | varchar(255) | YES | NULL | |
erp_code | varchar(255) | YES | NULL | Muhasebe entegrasyon kodu (LOGO ERP) |
location_level_1 | unsignedInt | YES | NULL | → locations.id (il) |
location_level_2 | unsignedInt | YES | NULL | → locations.id (ilçe) |
status | smallInt | NO | 1 | 1=Aktif, 0=Pasif |
is_key_account | boolean | NO | false | Key account mı |
auth_person1_name | varchar(255) | YES | NULL | Yetkili 1 adı |
auth_person1_phone | varchar(255) | YES | NULL | Yetkili 1 telefon |
auth_person1_email | varchar(255) | YES | NULL | Yetkili 1 e-posta |
auth_person2_name | varchar(255) | YES | NULL | Yetkili 2 adı |
auth_person2_phone | varchar(255) | YES | NULL | Yetkili 2 telefon |
auth_person2_email | varchar(255) | YES | NULL | Yetkili 2 e-posta |
contract_schools | varchar(255) | YES | NULL | Sözleşmeli okul listesi |
is_inflation_auto_updated | tinyInt | NO | 0 | Enflasyon fiyat otogüncelleme |
association_id | unsignedInt | YES | NULL | → associations.id |
erp_sync_flag | int | NO | 0 | ERP senkronizasyon bayrağı |
is_verified_commercial_information | boolean | YES | false | Ticari bilgi doğrulandı mı |
created_at | timestamp | NO | — | |
updated_at | timestamp | NO | — | |
deleted_at | timestamp | YES | NULL | Soft delete |
Customer Scores (customer_scores tablosu)
5 boyutlu sağlık skoru — tinyInt (0-255):
| Boyut | Açıklama |
|---|---|
demand | Talep / aktivite skoru |
communication | İletişim kalitesi |
responsiveness | Lead’lere tepki hızı |
payment | Ödeme düzenlilik skoru |
total | Genel skor |
SELECT c.name, cs.total, cs.demand, cs.payment
FROM customers c
JOIN customer_scores cs ON cs.customer_id = c.id
WHERE c.deleted_at IS NULL
ORDER BY cs.total DESC;Önemli İş Kuralları
erp_code→ LOGO ERP muhasebe sistemi entegrasyon kodu. Fatura sorgulamaları için gerekli.is_inflation_auto_updated = 1→ Sözleşme fiyatları enflasyon_rates tablosuna göre otomatik güncellenir.is_key_account = true→ Stratejik hesap; özel takip gerektirir.company_type = 'merchant'→ Varsayılan. Farklı tipler olabilir.- Bir müşteriye birden fazla okul (
schoolstablosunda) bağlı olabilir:schools WHERE customer_id = ?
Bağlantılı Tablolar
customers
← schools.customer_id (bağlı okullar, 1:N)
← customer_users (portal kullanıcıları, M2M)
← customer_user_schools (okul erişim izni)
← customer_agreements (sözleşmeler)
← payments
← customer_agreements_renew_logs
← customer_agreements_renew_discounts
← customer_scores (sağlık skoru)
← customer_credit_cards (kart tokenları)
← customer_user_daily_activity_logs
← leads.customer_id (gelen leadler)
← school_interactions.customer_id (CRM aktivite)
Örnek Sorgular
-- Aktif müşteri sayısı ve okul dağılımı
SELECT c.id, c.firm_name, COUNT(s.id) as okul_sayisi,
cs.total as skor
FROM customers c
LEFT JOIN schools s ON s.customer_id = c.id AND s.deleted_at IS NULL
LEFT JOIN customer_scores cs ON cs.customer_id = c.id
WHERE c.deleted_at IS NULL AND c.status = 1
GROUP BY c.id, c.firm_name, cs.total
ORDER BY okul_sayisi DESC;
-- Key account listesi
SELECT name, firm_name, erp_code, is_inflation_auto_updated
FROM customers
WHERE is_key_account = 1 AND deleted_at IS NULL AND status = 1;Related
- table-customer-agreements — Sözleşmeler
- domain-users-customers — Customers domain detayı
- domain-payments — Ödeme akışı