Modul Kontak mengelola database pelanggan merchant: kontak, tag, segment, import, dan reputation tracking lintas toko.
File kunci
| File | Baris | Peran |
|---|---|---|
app/Http/Controllers/ContactController.php | 2.842 | CRUD contact, tag, segment, import, reputation |
app/Models/Customer.php | 71 | Model customer |
app/Models/Tag.php | 26 | Model tag |
app/Models/Segment.php | 31 | Model segment |
Model Customer
Field: name, wa, email, province/city/subdistrict/village/postal_code/address, tags (array of UUID), segment_id, rating, type ('Customer'), category ('private'/'group'), status ('archive'/aktif), store_id, profilepic, addresses, chat_note.
Relasi: orders() hasMany Order, segment() belongsTo, chats() (query builder, bukan relasi proper — N+1 manual).
Reputation tracking
profitRputationData() (:2264) — hitung reputation customer lintas toko. Query tanpa store_id — ambil semua customer dengan wa sama di seluruh platform. Tiap toko hitung 3 sub-skala: reputasi_pembelian_perchat, reputasi_pembayaran_perpembelian, skala_rating.
Controller method utama
| Method | Fungsi |
|---|---|
store() | Create — BUG double-create (lihat bug tracker) |
createContact() | Alternatif create (API) |
updateContact() | Update |
updateTags() | Update tag + upsert Tag |
importContact() | Import CSV |
getDetailContact() | API reputation |
updateRating() | Update rating → trigger profitRputationData |
restoreOrArchiveContact() | Archive/restore |
Route
Web (routes/web.php:250)
Prefix /contact:
| Method | Path | Fungsi |
|---|---|---|
| GET | /contact | Index |
| GET | /contact/segment | Segment list |
| GET | /contact/tag | Tag list |
| GET | /contact/archive | Arsip |
| GET | /contact/detail/{id} | Detail |
| POST | /contact/store | Create |
API (routes/api.php:295)
Prefix /contact:
| Method | Path | Fungsi |
|---|---|---|
| POST | /contact/list | List lengkap |
| POST | /contact/list_paginate | Paginate + filter |
| PATCH | /contact/update | Update |
| POST | /contact/reputations | Reputation |
| POST | /contact/import-contact | Import CSV |
| POST | /contact/create-contact | Create (API) |
Temuan
store()double-create (:629-640) — Customer dibuat 2x- Validasi
waregex tidak konsisten — store tanpa+, update dengan+ chats()return query builder — N+1 manual diindex()Index.vue(1.944 baris) vsIndexV2.vue(797 baris) — controller render V2, lama orphan