D
Modul

Laporan

Sales overview, team performance, product performance, customer location analytics, chat report. MongoDB aggregation pipeline.

Modul report menyediakan analitik penjualan, performa tim, produk, lokasi customer, dan chat report CS. Semua query pakai MongoDB aggregation pipeline.

File kunci

FileBarisPeran
app/Http/Controllers/ReportController.php1.265Semua report
app/Exports/ChatReportExport.phpExport Excel chat report

Jenis report

ReportMethodIsi
Sales overviewsales_overviewTotal penjualan + persentase 60 hari
Team performanceteam_performanceAggregate per team_id, top 5 by paid_ratio
Team performance detailteam_performance_detailPer team: total_cost_order, gross_revenue, net_revenue, gross_profit
Product performanceproduct_performanceAggregate per produk+variant, paginasi manual
Customer locationcustomer_locationGroup by province/city
Customer location detailcustomer_location_detailGroup by province/city/district/subdistrict + success_rate
Chat reportgetChatReportDataSummary chat (new/open/pending/resolved) + table CS
Auto report settingsave_groupreportSimpan report_group/report_time ke Store

Route

Web (routes/web.php:272)

Prefix /report:

MethodPathFungsi
GET/reportIndex + autoreport setting
GET/report/chatChat report
GET/report/show_team_performanceTeam performance
GET/report/show_prduct_performanceProduct performance (typo prduct)
GET/report/show_customer_locationCustomer location

API (routes/api.php:341)

Prefix /report:

MethodPathFungsi
POST/report/sales_overviewSales
POST/report/team_performanceTeam
POST/report/product_performanceProduct
POST/report/customer_locationLocation
GET/report/chatChat data
GET/report/chat/exportExport 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