Procházet zdrojové kódy

feat(web,backend): 后台首页 KPI 新/总口径 + 家庭/用户等跳转链接

需求:首页家庭总数加链接直达家庭运营工作台并显示"新/总";家长/孩子改措辞为
用户总数(含账号)和非用户总数(无账号成员,userId为空),用户总数链用户管理;
商品/订单/文章/活动新增卡均按"新/总"显示并各自链接;移除独立"本月新增家庭"卡。

后端 /api/stats/dashboard 补充:
- weekNewFamilies/weekNewParents/totalNonUsers/weekNewNonUsers
- totalProducts/weekNewProducts、totalOrders/weekNewOrders(仅商品订单)
- totalArticles/weekNewArticles、totalActivities/weekNewActivities
- 总=有效口径(商品on_shelf/订单排除cancelled,closed,refunded/文章,活动published;人全量)
- 新=近7天(created_at>=7天前)且同套有效过滤

前端 Dashboard.vue:
- kpiCards 重组;模板按 card.newKey/totalKey 渲染"新/总";badge 改显式 card.badge
- 仅在待审规划师/待审任务模板显示"待处理"角标(避免可点卡误显)

TDD:后端 StatsControllerDashboardContractTest(纯Mockito,值断言覆盖有效过滤+近7天+新/总) 1/1;
前端 Dashboard.kpiNewTotal.contract.spec.js 8/8;前后端 build 通过。
Xiaogang Liao před 2 hodinami
rodič
revize
d75f0de6f9

+ 51 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/stats/StatsController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.etotem.cfc.common.Result;
 import com.etotem.cfc.common.Result;
 import com.etotem.cfc.entity.Article;
 import com.etotem.cfc.entity.Article;
+import com.etotem.cfc.entity.Activity;
 import com.etotem.cfc.entity.AfterSalesRequest;
 import com.etotem.cfc.entity.AfterSalesRequest;
 import com.etotem.cfc.entity.ArticleReadingRecord;
 import com.etotem.cfc.entity.ArticleReadingRecord;
 import com.etotem.cfc.entity.CommissionRecord;
 import com.etotem.cfc.entity.CommissionRecord;
@@ -20,6 +21,7 @@ import com.etotem.cfc.entity.ShareRead;
 import com.etotem.cfc.entity.Task;
 import com.etotem.cfc.entity.Task;
 import com.etotem.cfc.entity.TrialMembership;
 import com.etotem.cfc.entity.TrialMembership;
 import com.etotem.cfc.entity.User;
 import com.etotem.cfc.entity.User;
+import com.etotem.cfc.mapper.ActivityMapper;
 import com.etotem.cfc.mapper.AfterSalesRequestMapper;
 import com.etotem.cfc.mapper.AfterSalesRequestMapper;
 import com.etotem.cfc.mapper.ArticleMapper;
 import com.etotem.cfc.mapper.ArticleMapper;
 import com.etotem.cfc.mapper.ArticleReadingRecordMapper;
 import com.etotem.cfc.mapper.ArticleReadingRecordMapper;
@@ -82,6 +84,7 @@ public class StatsController {
     @Resource private ProductMapper productMapper;
     @Resource private ProductMapper productMapper;
     @Resource private ProductViewRecordMapper productViewRecordMapper;
     @Resource private ProductViewRecordMapper productViewRecordMapper;
     @Resource private ShareReadMapper shareReadMapper;
     @Resource private ShareReadMapper shareReadMapper;
+    @Resource private ActivityMapper activityMapper;
 
 
     /** 单条停留时长上限(秒):超过 30 分钟按 30 分钟计,避免后台挂起/埋点异常把时长放大成天文数字 */
     /** 单条停留时长上限(秒):超过 30 分钟按 30 分钟计,避免后台挂起/埋点异常把时长放大成天文数字 */
     private static final int MAX_DWELL_SECONDS = 1800;
     private static final int MAX_DWELL_SECONDS = 1800;
@@ -111,6 +114,42 @@ public class StatsController {
         }, taskExecutor);
         }, taskExecutor);
         CompletableFuture<Long> pendingRefundFuture = CompletableFuture.supplyAsync(() ->
         CompletableFuture<Long> pendingRefundFuture = CompletableFuture.supplyAsync(() ->
             afterSalesRequestMapper.selectCount(new QueryWrapper<AfterSalesRequest>().eq("status", "pending")), taskExecutor);
             afterSalesRequestMapper.selectCount(new QueryWrapper<AfterSalesRequest>().eq("status", "pending")), taskExecutor);
+
+        // ── 「新/总」口径:总=有效状态全量,新=近7天新增(created_at >= 7天前)且同样套用有效过滤 ──
+        Date weekAgo = new Date(System.currentTimeMillis() - 7L * 24 * 60 * 60 * 1000);
+        // 家庭:新=近7天创建的家庭数
+        CompletableFuture<Long> weekNewFamiliesFuture = CompletableFuture.supplyAsync(() ->
+            familyMapper.selectCount(new QueryWrapper<Family>().ge("created_at", weekAgo)), taskExecutor);
+        // 用户(家长账号):新=近7天新增家长
+        CompletableFuture<Long> weekNewParentsFuture = CompletableFuture.supplyAsync(() ->
+            userMapper.selectCount(new QueryWrapper<User>().eq("role", "parent").ge("created_at", weekAgo)), taskExecutor);
+        // 非用户:家庭成员中 userId 为空(无账号)
+        CompletableFuture<Long> totalNonUsersFuture = CompletableFuture.supplyAsync(() ->
+            familyMemberMapper.selectCount(new QueryWrapper<FamilyMember>().isNull("user_id")), taskExecutor);
+        CompletableFuture<Long> weekNewNonUsersFuture = CompletableFuture.supplyAsync(() ->
+            familyMemberMapper.selectCount(new QueryWrapper<FamilyMember>().isNull("user_id").ge("created_at", weekAgo)), taskExecutor);
+        // 商品:有效=已上架 on_shelf
+        CompletableFuture<Long> totalProductsFuture = CompletableFuture.supplyAsync(() ->
+            productMapper.selectCount(new QueryWrapper<Product>().eq("status", "on_shelf")), taskExecutor);
+        CompletableFuture<Long> weekNewProductsFuture = CompletableFuture.supplyAsync(() ->
+            productMapper.selectCount(new QueryWrapper<Product>().eq("status", "on_shelf").ge("created_at", weekAgo)), taskExecutor);
+        // 商品订单:有效=排除已取消/已关闭/已退款
+        CompletableFuture<Long> totalOrdersFuture = CompletableFuture.supplyAsync(() ->
+            productOrderMapper.selectCount(new QueryWrapper<ProductOrder>().notIn("status", "cancelled", "closed", "refunded")), taskExecutor);
+        CompletableFuture<Long> weekNewOrdersFuture = CompletableFuture.supplyAsync(() ->
+            productOrderMapper.selectCount(new QueryWrapper<ProductOrder>()
+                .notIn("status", "cancelled", "closed", "refunded").ge("created_at", weekAgo)), taskExecutor);
+        // 文章:有效=已发布 published
+        CompletableFuture<Long> totalArticlesFuture = CompletableFuture.supplyAsync(() ->
+            articleMapper.selectCount(new QueryWrapper<Article>().eq("status", "published")), taskExecutor);
+        CompletableFuture<Long> weekNewArticlesFuture = CompletableFuture.supplyAsync(() ->
+            articleMapper.selectCount(new QueryWrapper<Article>().eq("status", "published").ge("created_at", weekAgo)), taskExecutor);
+        // 活动:有效=发布中 published
+        CompletableFuture<Long> totalActivitiesFuture = CompletableFuture.supplyAsync(() ->
+            activityMapper.selectCount(new QueryWrapper<Activity>().eq("status", "published")), taskExecutor);
+        CompletableFuture<Long> weekNewActivitiesFuture = CompletableFuture.supplyAsync(() ->
+            activityMapper.selectCount(new QueryWrapper<Activity>().eq("status", "published").ge("created_at", weekAgo)), taskExecutor);
+
         try {
         try {
             data.put("totalFamilies", familyFuture.get());
             data.put("totalFamilies", familyFuture.get());
             data.put("totalParents", parentFuture.get());
             data.put("totalParents", parentFuture.get());
@@ -119,6 +158,18 @@ public class StatsController {
             data.put("pendingGuideCount", pendingGuideFuture.get());
             data.put("pendingGuideCount", pendingGuideFuture.get());
             data.put("pendingPackageCount", pendingPackageFuture.get());
             data.put("pendingPackageCount", pendingPackageFuture.get());
             data.put("pendingRefundCount", pendingRefundFuture.get());
             data.put("pendingRefundCount", pendingRefundFuture.get());
+            data.put("weekNewFamilies", weekNewFamiliesFuture.get());
+            data.put("weekNewParents", weekNewParentsFuture.get());
+            data.put("totalNonUsers", totalNonUsersFuture.get());
+            data.put("weekNewNonUsers", weekNewNonUsersFuture.get());
+            data.put("totalProducts", totalProductsFuture.get());
+            data.put("weekNewProducts", weekNewProductsFuture.get());
+            data.put("totalOrders", totalOrdersFuture.get());
+            data.put("weekNewOrders", weekNewOrdersFuture.get());
+            data.put("totalArticles", totalArticlesFuture.get());
+            data.put("weekNewArticles", weekNewArticlesFuture.get());
+            data.put("totalActivities", totalActivitiesFuture.get());
+            data.put("weekNewActivities", weekNewActivitiesFuture.get());
             data.put("recentTasks", recentTasksFuture.get());
             data.put("recentTasks", recentTasksFuture.get());
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("获取仪表盘数据失败", e);
             log.error("获取仪表盘数据失败", e);

+ 129 - 0
cfc-backend/src/test/java/com/etotem/cfc/controller/stats/StatsControllerDashboardContractTest.java

@@ -0,0 +1,129 @@
+package com.etotem.cfc.controller.stats;
+
+import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.controller.stats.StatsController;
+import com.etotem.cfc.mapper.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * TDD 契约:/api/stats/dashboard 返回「新/总」统计(有效口径 + 近7天新增)。
+ * 纯 Mockito 单测(@SpringBootTest 需连库,本地不可用),不启动 Spring/DB。
+ * 存根用 argThat 按「状态参数 + created_at 边界」区分 total/new;若实现漏掉任一条件,
+ * 该存根不匹配 -> 返回 0 -> 断言失败。RED:新 key 未实现 -> 值缺失/失败;GREEN:全通过。
+ */
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
+public class StatsControllerDashboardContractTest {
+
+    @Mock private ThreadPoolTaskExecutor taskExecutor;
+    @Mock private FamilyMapper familyMapper;
+    @Mock private UserMapper userMapper;
+    @Mock private FamilyMemberMapper familyMemberMapper;
+    @Mock private GuidePackageMapper guidePackageMapper;
+    @Mock private TaskMapper taskMapper;
+    @Mock private AfterSalesRequestMapper afterSalesRequestMapper;
+    @Mock private ProductMapper productMapper;
+    @Mock private ProductOrderMapper productOrderMapper;
+    @Mock private ArticleMapper articleMapper;
+    @Mock private ActivityMapper activityMapper;
+
+    @InjectMocks private StatsController controller;
+
+    // —— wrapper 辅助判断(QueryWrapper 在 controller 中构造)——
+    private static boolean hasCreatedAt(Object w) {
+        return w != null && ((AbstractWrapper) w).getSqlSegment().toUpperCase().contains("CREATED_AT");
+    }
+    private static boolean hasParam(Object w, Object v) {
+        if (w == null) return false;
+        AbstractWrapper aw = (AbstractWrapper) w;
+        aw.getSqlSegment(); // MyBatis-Plus: 参数在渲染 SQL 时才物化到 paramNameValuePairs
+        return aw.getParamNameValuePairs().containsValue(v);
+    }
+    private static boolean hasSql(Object w, String frag) {
+        return w != null && ((AbstractWrapper) w).getSqlSegment().toUpperCase().contains(frag);
+    }
+
+    @BeforeEach
+    void setUp() {
+        // 让 CompletableFuture.supplyAsync(supplier, taskExecutor) 内联同步执行
+        doAnswer(inv -> { ((Runnable) inv.getArgument(0)).run(); return null; })
+                .when(taskExecutor).execute(any(Runnable.class));
+
+        // 家庭:total=selectCount(null)=120,weekNew=带 created_at=12
+        when(familyMapper.selectCount(isNull())).thenReturn(120L);
+        when(familyMapper.selectCount(argThat(w -> hasCreatedAt(w)))).thenReturn(12L);
+        // 用户(家长账号):total(无created_at)=300,weekNew(带created_at)=30;teacher/pending 复用 total 存根
+        when(userMapper.selectCount(argThat(w -> !hasCreatedAt(w)))).thenReturn(300L);
+        when(userMapper.selectCount(argThat(w -> hasCreatedAt(w)))).thenReturn(30L);
+        // 非用户(userId IS NULL):total=88,weekNew=8
+        when(familyMemberMapper.selectCount(isNull())).thenReturn(0L); // 总孩子数(childFuture,null查询)
+        when(familyMemberMapper.selectCount(argThat(w -> hasSql(w, "IS NULL") && !hasCreatedAt(w)))).thenReturn(88L);
+        when(familyMemberMapper.selectCount(argThat(w -> hasSql(w, "IS NULL") && hasCreatedAt(w)))).thenReturn(8L);
+        // 规划师相关:任一 guidePackage/售后
+        when(guidePackageMapper.selectCount(any())).thenReturn(7L);
+        when(afterSalesRequestMapper.selectCount(any())).thenReturn(3L);
+        // 商品(有效=on_shelf):total=45,weekNew=5
+        when(productMapper.selectCount(argThat(w -> hasParam(w, "on_shelf") && !hasCreatedAt(w)))).thenReturn(45L);
+        when(productMapper.selectCount(argThat(w -> hasParam(w, "on_shelf") && hasCreatedAt(w)))).thenReturn(5L);
+        // 商品订单(有效=排除 cancelled/closed/refunded):total=210,weekNew=21
+        when(productOrderMapper.selectCount(argThat(w -> hasSql(w, "NOT IN") && !hasCreatedAt(w)))).thenReturn(210L);
+        when(productOrderMapper.selectCount(argThat(w -> hasSql(w, "NOT IN") && hasCreatedAt(w)))).thenReturn(21L);
+        // 文章(有效=published):total=60,weekNew=6
+        when(articleMapper.selectCount(argThat(w -> hasParam(w, "published") && !hasCreatedAt(w)))).thenReturn(60L);
+        when(articleMapper.selectCount(argThat(w -> hasParam(w, "published") && hasCreatedAt(w)))).thenReturn(6L);
+        // 活动(有效=published):total=25,weekNew=2
+        when(activityMapper.selectCount(argThat(w -> hasParam(w, "published") && !hasCreatedAt(w)))).thenReturn(25L);
+        when(activityMapper.selectCount(argThat(w -> hasParam(w, "published") && hasCreatedAt(w)))).thenReturn(2L);
+        // 任务列表(最近任务):空
+        when(taskMapper.selectList(any())).thenReturn(Collections.emptyList());
+    }
+
+    private Map<String, Object> call() {
+        Result<Map<String, Object>> r = controller.getDashboardSummary();
+        assertNotNull(r, "返回 Result 不能为 null");
+        assertEquals(200, r.getCode(), "业务码应为200");
+        return r.getData();
+    }
+
+    @Test
+    void dashboard_returns_newtotal_counts_with_valid_filters() {
+        Map<String, Object> d = call();
+        // 家庭:新/总
+        assertEquals(120L, d.get("totalFamilies"), "家庭总数");
+        assertEquals(12L, d.get("weekNewFamilies"), "近7天新增家庭");
+        // 用户(家长账号):新/总
+        assertEquals(300L, d.get("totalParents"), "用户总数");
+        assertEquals(30L, d.get("weekNewParents"), "近7天新增用户");
+        // 非用户(userId为空成员):新/总
+        assertEquals(88L, d.get("totalNonUsers"), "非用户总数");
+        assertEquals(8L, d.get("weekNewNonUsers"), "近7天新增非用户");
+        // 商品(有效=on_shelf):新/总
+        assertEquals(45L, d.get("totalProducts"), "商品总数(仅上架)");
+        assertEquals(5L, d.get("weekNewProducts"), "近7天新增商品");
+        // 订单(有效=排除已取消/关闭/退款):新/总
+        assertEquals(210L, d.get("totalOrders"), "订单总数(仅有效)");
+        assertEquals(21L, d.get("weekNewOrders"), "近7天新增订单");
+        // 文章(有效=published):新/总
+        assertEquals(60L, d.get("totalArticles"), "文章总数(仅已发布)");
+        assertEquals(6L, d.get("weekNewArticles"), "近7天新增文章");
+        // 活动(有效=published):新/总
+        assertEquals(25L, d.get("totalActivities"), "活动总数(仅发布中)");
+        assertEquals(2L, d.get("weekNewActivities"), "近7天新增活动");
+    }
+}

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-68962b384421746d099dc48ba7ab6891e6817ec9
+f6806c40c5a05a91f79271cb79d34cfd322af60e

+ 86 - 0
cfc-web/src/__tests__/views/Dashboard.kpiNewTotal.contract.spec.js

@@ -0,0 +1,86 @@
+import { readFileSync } from 'fs'
+import { resolve } from 'path'
+
+// 契约:admin.dashboard.kpiNewTotal(后台首页 KPI「新/总」口径 + 跳转链接 + 措辞改用户/非用户)
+// 需求:
+//  1) 家庭总数 → 链接 /families,显示「新/总」(weekNewFamilies/totalFamilies)
+//  2) 家长总数→用户总数(链接/users),孩子总数→非用户总数(userId为空成员)
+//  3) 商品/订单/文章/活动 新增卡,均显示「新/总」并各自链接
+//  4) 移除独立「本月新增家庭」卡
+//  5) 「待处理」角标仅显式 badge 卡(待审规划师/待审任务模板),非所有可点卡
+const source = readFileSync(resolve(__dirname, '../../views/Dashboard.vue'), 'utf8')
+
+// 提取 kpiCards 数组块
+const kpiStart = source.indexOf('kpiCards: [')
+const kpiEnd = source.indexOf('],', kpiStart)
+const kpi = source.slice(kpiStart, kpiEnd)
+
+// 提取 loadDashboardData 中 stats 赋值块
+const loadStart = source.indexOf('async loadDashboardData()')
+const loadEnd = source.indexOf('}', source.indexOf('async loadTraffic()'))
+const load = source.slice(loadStart, loadEnd > 0 ? loadEnd : loadStart + 4000)
+
+describe('Dashboard KPI 新/总口径与链接', () => {
+  test('家庭总数卡带新/总字段且链接到家庭运营工作台(/families)', () => {
+    const fam = kpi.match(/totalFamilies'[^\]]*\]/)?.[0] || kpi.slice(0, 300)
+    expect(kpi).toMatch(/weekNewFamilies/)
+    expect(kpi).toMatch(/totalFamilies/)
+    expect(kpi).toMatch(/['"]\/families['"]/)
+  })
+
+  test('家长总数改为用户总数并链接用户管理(/users)', () => {
+    expect(kpi).toMatch(/用户总数/)
+    expect(kpi).toMatch(/['"]\/users['"]/)
+    expect(kpi).toMatch(/totalParents/)
+  })
+
+  test('孩子总数改为非用户总数(userId为空成员,无链接)', () => {
+    expect(kpi).toMatch(/非用户总数/)
+    expect(kpi).toMatch(/totalNonUsers/)
+  })
+
+  test('商品/订单/文章/活动均新增且带新/总字段与各自链接', () => {
+    expect(kpi).toMatch(/totalProducts/)
+    expect(kpi).toMatch(/weekNewProducts/)
+    expect(kpi).toMatch(/['"]\/product-manage['"]/)
+    expect(kpi).toMatch(/totalOrders/)
+    expect(kpi).toMatch(/weekNewOrders/)
+    expect(kpi).toMatch(/['"]\/order-manage['"]/)
+    expect(kpi).toMatch(/totalArticles/)
+    expect(kpi).toMatch(/weekNewArticles/)
+    expect(kpi).toMatch(/['"]\/article-manage['"]/)
+    expect(kpi).toMatch(/totalActivities/)
+    expect(kpi).toMatch(/weekNewActivities/)
+    expect(kpi).toMatch(/['"]\/activities['"]/)
+  })
+
+  test('移除独立「本月新增家庭」卡', () => {
+    expect(kpi).not.toMatch(/本月新增家庭/)
+    expect(kpi).not.toMatch(/monthFamilies/)
+  })
+
+  test('「待处理」角标仅显式 badge 卡(非所有可点卡)', () => {
+    // 模板中 badge 条件用 card.badge
+    expect(source).toMatch(/card\.badge/)
+    // kpiCards 中待审卡带 badge: true
+    expect(kpi).toMatch(/badge:\s*true/)
+  })
+
+  test('模板按 newKey/totalKey 渲染「新/总」', () => {
+    expect(source).toMatch(/card\.newKey/)
+    expect(source).toMatch(/card\.totalKey/)
+    // 值渲染表达式包含新/总拼接
+    expect(source).toMatch(/stats\[card\.newKey\]/)
+    expect(source).toMatch(/stats\[card\.totalKey\]/)
+  })
+
+  test('loadDashboardData 把 weekNew/total 写入 stats', () => {
+    expect(load).toMatch(/weekNewFamilies/)
+    expect(load).toMatch(/weekNewProducts/)
+    expect(load).toMatch(/weekNewOrders/)
+    expect(load).toMatch(/weekNewArticles/)
+    expect(load).toMatch(/weekNewActivities/)
+    expect(load).toMatch(/totalNonUsers/)
+    expect(load).toMatch(/weekNewNonUsers/)
+  })
+})

+ 39 - 9
cfc-web/src/views/Dashboard.vue

@@ -44,10 +44,13 @@
             <i :class="card.icon"></i>
             <i :class="card.icon"></i>
           </div>
           </div>
           <div class="kpi-card__body">
           <div class="kpi-card__body">
-            <div class="kpi-card__value adm-num">{{ stats[card.key] || 0 }}</div>
+            <div class="kpi-card__value adm-num">
+              <template v-if="card.newKey">{{ stats[card.newKey] || 0 }}<span class="kpi-slash">/</span>{{ stats[card.totalKey] || 0 }}</template>
+              <template v-else>{{ stats[card.key] || 0 }}</template>
+            </div>
             <div class="kpi-card__label">{{ card.label }}</div>
             <div class="kpi-card__label">{{ card.label }}</div>
           </div>
           </div>
-          <div v-if="card.click && stats[card.key] > 0" class="kpi-card__badge">待处理</div>
+          <div v-if="card.badge && stats[card.key] > 0" class="kpi-card__badge">待处理</div>
         </div>
         </div>
       </el-col>
       </el-col>
     </el-row>
     </el-row>
@@ -286,7 +289,18 @@ export default {
         pendingGuideCount: 0,
         pendingGuideCount: 0,
         pendingPackageCount: 0,
         pendingPackageCount: 0,
         activeUsers: 0,
         activeUsers: 0,
-        monthFamilies: 0
+        weekNewFamilies: 0,
+        weekNewParents: 0,
+        totalNonUsers: 0,
+        weekNewNonUsers: 0,
+        totalProducts: 0,
+        weekNewProducts: 0,
+        totalOrders: 0,
+        weekNewOrders: 0,
+        totalArticles: 0,
+        weekNewArticles: 0,
+        totalActivities: 0,
+        weekNewActivities: 0
       },
       },
       recentTasks: [],
       recentTasks: [],
       trafficLoading: false,
       trafficLoading: false,
@@ -324,14 +338,17 @@ export default {
         cpuUsagePercent: '--'
         cpuUsagePercent: '--'
       },
       },
       kpiCards: [
       kpiCards: [
-        { key: 'totalFamilies', label: '家庭总数', icon: 'el-icon-s-home', color: 'primary' },
-        { key: 'totalParents', label: '家长总数', icon: 'el-icon-user', color: 'primary' },
-        { key: 'totalChildren', label: '孩子总数', icon: 'el-icon-s-custom', color: 'warning' },
+        { key: 'totalFamilies', label: '家庭总数', icon: 'el-icon-s-home', color: 'primary', newKey: 'weekNewFamilies', totalKey: 'totalFamilies', click: '/families' },
+        { key: 'totalParents', label: '用户总数', icon: 'el-icon-user', color: 'primary', click: '/users' },
+        { key: 'totalNonUsers', label: '非用户总数', icon: 'el-icon-s-custom', color: 'warning' },
         { key: 'totalTeachers', label: '规划师总数', icon: 'el-icon-s-cooperation', color: 'success' },
         { key: 'totalTeachers', label: '规划师总数', icon: 'el-icon-s-cooperation', color: 'success' },
-        { key: 'pendingGuideCount', label: '待审规划师', icon: 'el-icon-s-check', color: 'danger', click: '/review-center?tab=guide' },
-        { key: 'pendingPackageCount', label: '待审任务模板', icon: 'el-icon-s-goods', color: 'danger', click: '/review-center?tab=package' },
+        { key: 'pendingGuideCount', label: '待审规划师', icon: 'el-icon-s-check', color: 'danger', click: '/review-center?tab=guide', badge: true },
+        { key: 'pendingPackageCount', label: '待审任务模板', icon: 'el-icon-s-goods', color: 'danger', click: '/review-center?tab=package', badge: true },
         { key: 'activeUsers', label: '活跃用户', icon: 'el-icon-user-solid', color: 'primary' },
         { key: 'activeUsers', label: '活跃用户', icon: 'el-icon-user-solid', color: 'primary' },
-        { key: 'monthFamilies', label: '本月新增家庭', icon: 'el-icon-s-home', color: 'primary' }
+        { key: 'totalProducts', label: '商品', icon: 'el-icon-s-goods', color: 'primary', newKey: 'weekNewProducts', totalKey: 'totalProducts', click: '/product-manage' },
+        { key: 'totalOrders', label: '订单', icon: 'el-icon-s-order', color: 'primary', newKey: 'weekNewOrders', totalKey: 'totalOrders', click: '/order-manage' },
+        { key: 'totalArticles', label: '文章', icon: 'el-icon-document', color: 'primary', newKey: 'weekNewArticles', totalKey: 'totalArticles', click: '/article-manage' },
+        { key: 'totalActivities', label: '活动', icon: 'el-icon-star-off', color: 'primary', newKey: 'weekNewActivities', totalKey: 'totalActivities', click: '/activities' }
       ],
       ],
       dwellSections: [
       dwellSections: [
         { key: 'articleDwell', title: '文章停留时长 Top', sub: '按平均停留排序 · 近30天', icon: 'el-icon-document', iconClass: 'sec--primary', emptyHint: '暂无文章阅读停留数据' },
         { key: 'articleDwell', title: '文章停留时长 Top', sub: '按平均停留排序 · 近30天', icon: 'el-icon-document', iconClass: 'sec--primary', emptyHint: '暂无文章阅读停留数据' },
@@ -488,6 +505,18 @@ export default {
         const overview = overviewRes.data || {}
         const overview = overviewRes.data || {}
         this.stats.activeUsers = overview.activeUsers || 0
         this.stats.activeUsers = overview.activeUsers || 0
         this.stats.monthFamilies = overview.monthFamilies || 0
         this.stats.monthFamilies = overview.monthFamilies || 0
+        this.stats.weekNewFamilies = d.weekNewFamilies || 0
+        this.stats.weekNewParents = d.weekNewParents || 0
+        this.stats.totalNonUsers = d.totalNonUsers || 0
+        this.stats.weekNewNonUsers = d.weekNewNonUsers || 0
+        this.stats.totalProducts = d.totalProducts || 0
+        this.stats.weekNewProducts = d.weekNewProducts || 0
+        this.stats.totalOrders = d.totalOrders || 0
+        this.stats.weekNewOrders = d.weekNewOrders || 0
+        this.stats.totalArticles = d.totalArticles || 0
+        this.stats.weekNewArticles = d.weekNewArticles || 0
+        this.stats.totalActivities = d.totalActivities || 0
+        this.stats.weekNewActivities = d.weekNewActivities || 0
       } catch (error) {
       } catch (error) {
         console.error('加载仪表盘数据失败:', error)
         console.error('加载仪表盘数据失败:', error)
       }
       }
@@ -865,6 +894,7 @@ export default {
   color: var(--adm-text-88);
   color: var(--adm-text-88);
   line-height: 1.2;
   line-height: 1.2;
 }
 }
+.kpi-slash { margin: 0 2px; color: var(--adm-text-45, #909399); font-weight: 400; }
 .kpi-card__label {
 .kpi-card__label {
   font-size: 13px;
   font-size: 13px;
   color: var(--adm-text-45);
   color: var(--adm-text-45);