From 42e4287473f62e341ebd3108946fe4474ffdc551 Mon Sep 17 00:00:00 2001 From: freedakgmail Date: Thu, 30 Jul 2026 14:42:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=80=81=E6=9D=BF=E9=A9=BE=E9=A9=B6?= =?UTF-8?q?=E8=88=B1=E7=BB=9F=E4=B8=80=E5=85=A8=E5=8F=A3=E5=BE=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=BA=90=20-=20=E5=AE=9E=E6=94=B6/=E5=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=BB=B7/=E8=B4=A6=E5=8D=95=E6=95=B0/=E9=A3=8E=E9=99=A9?= =?UTF-8?q?=E5=8D=A0=E6=AF=94=E5=9D=87=E5=8F=96=E8=87=AAstore-expense/over?= =?UTF-8?q?view=EF=BC=8C=E4=B8=8E=E5=88=A9=E6=B6=A6=E7=80=91=E5=B8=83?= =?UTF-8?q?=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/BossPage.tsx | 8 ++++---- server/src/routes/store-expense.ts | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) 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,