fix: 老板驾驶舱统一全口径数据源 - 实收/客单价/账单数/风险占比均取自store-expense/overview,与利润瀑布一致

This commit is contained in:
freedakgmail
2026-07-30 14:42:40 +08:00
parent fca917dc13
commit 42e4287473
2 changed files with 7 additions and 4 deletions
+3
View File
@@ -16,6 +16,7 @@ router.get('/overview', async (req: AuthRequest, res) => {
r.store_code,
r.store_name,
r.received,
r.bill_count,
r.theoretical_margin_pct,
COALESCE(e.operating_expense, 0) AS operating_expense,
COALESCE(e.wage_expense, 0) AS wage_expense,
@@ -40,7 +41,9 @@ router.get('/overview', async (req: AuthRequest, res) => {
count(*) FILTER (WHERE actual_store_contribution > 0) AS profitable_stores,
count(*) FILTER (WHERE actual_store_contribution <= 0 AND received > 0) AS loss_stores,
count(*) FILTER (WHERE operating_expense = 0) AS no_expense_stores,
sum(bill_count)::bigint AS total_bills,
round(sum(received)::numeric, 2) AS total_received,
round(sum(received) / nullif(sum(bill_count), 0), 2) AS avg_bill_value,
round(sum(operating_expense)::numeric, 2) AS total_expense,
round(sum(wage_expense)::numeric, 2) AS total_wage,
round(sum(rent_expense)::numeric, 2) AS total_rent,