diff --git a/client/src/pages/BossPage.tsx b/client/src/pages/BossPage.tsx index 5692ff5..017e830 100644 --- a/client/src/pages/BossPage.tsx +++ b/client/src/pages/BossPage.tsx @@ -73,7 +73,7 @@ export function BossPage() { return acc }, {}) const totalStores = riskRows.length - const totalRev = Number(od?.received || 0) + const totalRev = Number(ex?.total_received || 0) // P0/P1门店 const p0Stores = priorityRows.filter((s: any) => s.action_priority?.startsWith('P0')) @@ -155,10 +155,10 @@ export function BossPage() { {/* ① 核心经营指标 */}
- 0 ? '↑' : '↓'} ${Math.abs(trendReceived)}%`} /> + 0 ? '↑' : '↓'} ${Math.abs(trendReceived)}%`} /> - - 0 ? sumKey(last7, 'received') / sumKey(last7, 'bill_count') : 0), (prev7.length > 0 ? sumKey(prev7, 'received') / sumKey(prev7, 'bill_count') : 0))} description={`账单 ${formatNumber(od?.bill_count)} 笔 · 公式:实收 ÷ 账单数`} /> + + 0 ? sumKey(last7, 'received') / sumKey(last7, 'bill_count') : 0), (prev7.length > 0 ? sumKey(prev7, 'received') / sumKey(prev7, 'bill_count') : 0))} description={`账单 ${formatNumber(ex?.total_bills)} 笔 · 公式:实收 ÷ 账单数`} />
{/* ② 利润瀑布 */} diff --git a/server/src/routes/store-expense.ts b/server/src/routes/store-expense.ts index b566139..661445a 100644 --- a/server/src/routes/store-expense.ts +++ b/server/src/routes/store-expense.ts @@ -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,