Modul report menyediakan analitik penjualan, performa tim, produk, lokasi customer, dan chat report CS. Semua query pakai MongoDB aggregation pipeline.
File kunci
| File | Baris | Peran |
|---|
app/Http/Controllers/ReportController.php | 1.265 | Semua report |
app/Exports/ChatReportExport.php | — | Export Excel chat report |
Jenis report
| Report | Method | Isi |
|---|
| Sales overview | sales_overview | Total penjualan + persentase 60 hari |
| Team performance | team_performance | Aggregate per team_id, top 5 by paid_ratio |
| Team performance detail | team_performance_detail | Per team: total_cost_order, gross_revenue, net_revenue, gross_profit |
| Product performance | product_performance | Aggregate per produk+variant, paginasi manual |
| Customer location | customer_location | Group by province/city |
| Customer location detail | customer_location_detail | Group by province/city/district/subdistrict + success_rate |
| Chat report | getChatReportData | Summary chat (new/open/pending/resolved) + table CS |
| Auto report setting | save_groupreport | Simpan report_group/report_time ke Store |
Route
Web (routes/web.php:272)
Prefix /report:
| Method | Path | Fungsi |
|---|
| GET | /report | Index + autoreport setting |
| GET | /report/chat | Chat report |
| GET | /report/show_team_performance | Team performance |
| GET | /report/show_prduct_performance | Product performance (typo prduct) |
| GET | /report/show_customer_location | Customer location |
API (routes/api.php:341)
Prefix /report:
| Method | Path | Fungsi |
|---|
| POST | /report/sales_overview | Sales |
| POST | /report/team_performance | Team |
| POST | /report/product_performance | Product |
| POST | /report/customer_location | Location |
| GET | /report/chat | Chat data |
| GET | /report/chat/export | Export Excel |
Integrasi
- MongoDB aggregation — semua pakai
$match/$lookup/$group/$addFields, konversi created_at via UTCDateTime
- Maatwebsite Excel untuk export
.xlsx
Temuan
- Route
/api/report/chat ada dalam prefix /report — full path jadi /api/report/api/report/chat. Sangat janggal, kemungkinan salah
- Typo
show_prduct_performance di nama route
- Paginasi manual via
array_slice — seluruh aggregate dimuat ke memori dulu baru di-slice. Tidak efisien untuk dataset besar
save_groupreport simpan setting tapi tidak ada pelaksanaan jadwal — fitur auto report nampak setengah jadi
chatReportIndex cek role via $user->user_store->role — bila user_store null akan error
product_performance tanpa input date — bisa menarik semua data historis