Просмотр исходного кода

merge: 家庭工作台维度下钻(CF获取来源/任务执行率/报告方案状态汇总)

Xiaogang Liao 10 часов назад
Родитель
Сommit
f55e249aa3

+ 11 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminFamilyOverviewController.java

@@ -39,4 +39,15 @@ public class AdminFamilyOverviewController {
         long size = params != null && params.get("size") != null ? ((Number) params.get("size")).longValue() : 20L;
         long size = params != null && params.get("size") != null ? ((Number) params.get("size")).longValue() : 20L;
         return Result.success(service.pageTasks(id, page, size));
         return Result.success(service.pageTasks(id, page, size));
     }
     }
+
+    @Operation(summary = "家庭CF值流水分页(工作台CF获取抽屉)")
+    @PostMapping("/families/{id}/cf-logs")
+    public Result<Page<Map<String, Object>>> cfLogs(@PathVariable Long id,
+                                                    @RequestBody(required = false) Map<String, Object> params,
+                                                    @RequestAttribute("role") String role) {
+        if (!"admin".equals(role)) return Result.error("无权限");
+        long page = params != null && params.get("page") != null ? ((Number) params.get("page")).longValue() : 1L;
+        long size = params != null && params.get("size") != null ? ((Number) params.get("size")).longValue() : 20L;
+        return Result.success(service.pageCfLogs(id, page, size));
+    }
 }
 }

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/dto/FamilyOverviewDTO.java

@@ -22,4 +22,13 @@ public class FamilyOverviewDTO {
     private List<FamilyReportItemVO> reports;
     private List<FamilyReportItemVO> reports;
 
 
     private List<FamilyPlanItemVO> plans;
     private List<FamilyPlanItemVO> plans;
+
+    /** 维度汇总(CF获取 / 任务执行 / 报告上传 / 方案生成) */
+    private Map<String, Object> cfSummary;
+
+    private Map<String, Object> taskSummary;
+
+    private Map<String, Object> reportSummary;
+
+    private Map<String, Object> planSummary;
 }
 }

+ 57 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/FamilyAdminOverviewService.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.etotem.cfc.dto.*;
 import com.etotem.cfc.dto.*;
 import com.etotem.cfc.entity.*;
 import com.etotem.cfc.entity.*;
 import com.etotem.cfc.mapper.*;
 import com.etotem.cfc.mapper.*;
+import com.etotem.cfc.util.FamilyDimensionSummaryBuilder;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.*;
@@ -20,6 +21,8 @@ public class FamilyAdminOverviewService {
     @Resource private HealthPlanMapper planMapper;
     @Resource private HealthPlanMapper planMapper;
     @Resource private TaskMapper taskMapper;
     @Resource private TaskMapper taskMapper;
     @Resource private UserMapper userMapper;
     @Resource private UserMapper userMapper;
+    @Resource private CfBalanceMapper cfBalanceMapper;
+    @Resource private CfBalanceLogMapper cfBalanceLogMapper;
 
 
     public FamilyOverviewDTO buildOverview(Long familyId) {
     public FamilyOverviewDTO buildOverview(Long familyId) {
         Family family = familyMapper.selectById(familyId);
         Family family = familyMapper.selectById(familyId);
@@ -46,6 +49,36 @@ public class FamilyAdminOverviewService {
         counts.setTaskStatusCounts(countBy(taskMapper, "status", "family_id", familyId));
         counts.setTaskStatusCounts(countBy(taskMapper, "status", "family_id", familyId));
         dto.setCounts(counts);
         dto.setCounts(counts);
 
 
+        // ---- 维度汇总(工作台统计卡/抽屉下钻,familyId 全程锁定) ----
+        Map<String, Integer> tmplCounts = countBy(taskMapper, "is_template", "family_id", familyId);
+        long templates = tmplCounts.getOrDefault("1", 0);
+        long instances = tmplCounts.getOrDefault("0", 0);
+        dto.setTaskSummary(FamilyDimensionSummaryBuilder.task(
+                counts.getTasks(), counts.getTaskStatusCounts(),
+                countBy(taskMapper, "source_type", "family_id", familyId),
+                countBy(taskMapper, "category", "family_id", familyId),
+                templates, instances));
+
+        long earned = 0, available = 0, frozen = 0, withdrawn = 0, exchanged = 0;
+        for (CfBalance cb : cfBalanceMapper.selectList(
+                new LambdaQueryWrapper<CfBalance>().eq(CfBalance::getFamilyId, familyId))) {
+            if (cb.getTotalEarned() != null) earned += cb.getTotalEarned();
+            if (cb.getAvailable() != null) available += cb.getAvailable();
+            if (cb.getFrozen() != null) frozen += cb.getFrozen();
+            if (cb.getWithdrawn() != null) withdrawn += cb.getWithdrawn();
+            if (cb.getExchanged() != null) exchanged += cb.getExchanged();
+        }
+        long logCount = cfBalanceLogMapper.selectCount(
+                new LambdaQueryWrapper<CfBalanceLog>().eq(CfBalanceLog::getFamilyId, familyId));
+        dto.setCfSummary(FamilyDimensionSummaryBuilder.cf(earned, available, frozen, withdrawn, exchanged,
+                logCount, countBy(cfBalanceLogMapper, "ref_type", "family_id", familyId)));
+
+        dto.setReportSummary(FamilyDimensionSummaryBuilder.report(counts.getReports(),
+                counts.getReportTypeCounts(), countBy(reportMapper, "status", "family_id", familyId)));
+        dto.setPlanSummary(FamilyDimensionSummaryBuilder.plan(counts.getPlans(),
+                countBy(planMapper, "plan_type", "family_id", familyId),
+                countBy(planMapper, "status", "family_id", familyId)));
+
         // 报告明细:全量、按报告日期倒序(同日期按 id 倒序)
         // 报告明细:全量、按报告日期倒序(同日期按 id 倒序)
         List<HealthReport> reports = reportMapper.selectList(new LambdaQueryWrapper<HealthReport>()
         List<HealthReport> reports = reportMapper.selectList(new LambdaQueryWrapper<HealthReport>()
                 .eq(HealthReport::getFamilyId, familyId)
                 .eq(HealthReport::getFamilyId, familyId)
@@ -93,6 +126,30 @@ public class FamilyAdminOverviewService {
         return out;
         return out;
     }
     }
 
 
+    /** CF 值流水分页(工作台 CF 获取抽屉) */
+    public Page<Map<String, Object>> pageCfLogs(Long familyId, long page, long size) {
+        long safeSize = Math.min(Math.max(size, 1), 100);
+        Page<CfBalanceLog> raw = cfBalanceLogMapper.selectPage(new Page<>(page, safeSize),
+                new LambdaQueryWrapper<CfBalanceLog>().eq(CfBalanceLog::getFamilyId, familyId)
+                        .orderByDesc(CfBalanceLog::getCreatedAt).orderByDesc(CfBalanceLog::getId));
+        Page<Map<String, Object>> out = new Page<>(raw.getCurrent(), raw.getSize(), raw.getTotal());
+        List<Map<String, Object>> rows = new ArrayList<>();
+        for (CfBalanceLog l : raw.getRecords()) {
+            Map<String, Object> m = new HashMap<>();
+            m.put("id", l.getId());
+            m.put("type", l.getType());
+            m.put("refType", l.getRefType());
+            m.put("refId", l.getRefId());
+            m.put("amount", l.getAmount());
+            m.put("balanceAfter", l.getBalanceAfter());
+            m.put("remark", l.getRemark());
+            m.put("createdAt", l.getCreatedAt());
+            rows.add(m);
+        }
+        out.setRecords(rows);
+        return out;
+    }
+
     public Page<TaskItemVO> pageTasks(Long familyId, long page, long size) {
     public Page<TaskItemVO> pageTasks(Long familyId, long page, long size) {
         long safeSize = Math.min(Math.max(size, 1), 100);
         long safeSize = Math.min(Math.max(size, 1), 100);
         Page<Task> raw = taskMapper.selectPage(new Page<>(page, safeSize),
         Page<Task> raw = taskMapper.selectPage(new Page<>(page, safeSize),

+ 65 - 0
cfc-backend/src/main/java/com/etotem/cfc/util/FamilyDimensionSummaryBuilder.java

@@ -0,0 +1,65 @@
+package com.etotem.cfc.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/** 家庭工作台维度汇总:把分组计数整理为前端可直接渲染的汇总 Map(纯函数,便于单测)。 */
+public final class FamilyDimensionSummaryBuilder {
+
+    private FamilyDimensionSummaryBuilder() {}
+
+    /** 任务执行汇总:总数/已完成/待办/完成率 + 模板/实例 + 来源/类别分布。 */
+    public static Map<String, Object> task(long total, Map<String, Integer> statusCounts,
+                                           Map<String, Integer> sourceCounts, Map<String, Integer> categoryCounts,
+                                           long templates, long instances) {
+        Map<String, Object> out = new HashMap<>();
+        out.put("total", total);
+        out.put("completed", n(statusCounts, "completed"));
+        out.put("pending", n(statusCounts, "pending"));
+        out.put("inProgress", n(statusCounts, "in_progress"));
+        out.put("templates", templates);
+        out.put("instances", instances);
+        double rate = total > 0 ? Math.round(n(statusCounts, "completed") * 1000.0 / total) / 10.0 : 0.0;
+        out.put("completionRate", rate);
+        out.put("bySource", sourceCounts == null ? new HashMap<String, Integer>() : sourceCounts);
+        out.put("byCategory", categoryCounts == null ? new HashMap<String, Integer>() : categoryCounts);
+        return out;
+    }
+
+    /** CF 获取汇总:账户各余额口径 + 流水笔数 + 来源分布。 */
+    public static Map<String, Object> cf(long earned, long available, long frozen, long withdrawn,
+                                         long exchanged, long logCount, Map<String, Integer> bySource) {
+        Map<String, Object> out = new HashMap<>();
+        out.put("earned", earned);
+        out.put("available", available);
+        out.put("frozen", frozen);
+        out.put("withdrawn", withdrawn);
+        out.put("exchanged", exchanged);
+        out.put("logCount", logCount);
+        out.put("bySource", bySource == null ? new HashMap<String, Integer>() : bySource);
+        return out;
+    }
+
+    /** 报告上传汇总:总数 + 类型/状态分布。 */
+    public static Map<String, Object> report(long total, Map<String, Integer> byType, Map<String, Integer> byStatus) {
+        Map<String, Object> out = new HashMap<>();
+        out.put("total", total);
+        out.put("byType", byType == null ? new HashMap<String, Integer>() : byType);
+        out.put("byStatus", byStatus == null ? new HashMap<String, Integer>() : byStatus);
+        return out;
+    }
+
+    /** 方案生成汇总:总数 + 类型/状态分布。 */
+    public static Map<String, Object> plan(long total, Map<String, Integer> byType, Map<String, Integer> byStatus) {
+        Map<String, Object> out = new HashMap<>();
+        out.put("total", total);
+        out.put("byType", byType == null ? new HashMap<String, Integer>() : byType);
+        out.put("byStatus", byStatus == null ? new HashMap<String, Integer>() : byStatus);
+        return out;
+    }
+
+    private static long n(Map<String, Integer> m, String key) {
+        if (m == null || m.get(key) == null) return 0L;
+        return m.get(key).longValue();
+    }
+}

+ 6 - 0
cfc-backend/src/test/java/com/etotem/cfc/service/FamilyAdminOverviewServiceTest.java

@@ -31,6 +31,8 @@ public class FamilyAdminOverviewServiceTest {
     @MockBean private HealthPlanMapper planMapper;
     @MockBean private HealthPlanMapper planMapper;
     @MockBean private TaskMapper taskMapper;
     @MockBean private TaskMapper taskMapper;
     @MockBean private UserMapper userMapper;
     @MockBean private UserMapper userMapper;
+    @MockBean private CfBalanceMapper cfBalanceMapper;
+    @MockBean private CfBalanceLogMapper cfBalanceLogMapper;
 
 
     @Test void overview_计数与明细() {
     @Test void overview_计数与明细() {
         Family f = new Family(); f.setId(7L); f.setName("王五家庭"); f.setCreatorId(10L);
         Family f = new Family(); f.setId(7L); f.setName("王五家庭"); f.setCreatorId(10L);
@@ -43,6 +45,10 @@ public class FamilyAdminOverviewServiceTest {
         when(taskMapper.selectMaps(any())).thenReturn(Arrays.asList(map("pending","340"), map("completed","6")));
         when(taskMapper.selectMaps(any())).thenReturn(Arrays.asList(map("pending","340"), map("completed","6")));
         when(reportMapper.selectList(any())).thenReturn(new ArrayList<>());
         when(reportMapper.selectList(any())).thenReturn(new ArrayList<>());
         when(planMapper.selectList(any())).thenReturn(new ArrayList<>());
         when(planMapper.selectList(any())).thenReturn(new ArrayList<>());
+        // 维度汇总新增依赖:CF余额/流水
+        when(cfBalanceMapper.selectList(any())).thenReturn(new ArrayList<>());
+        when(cfBalanceLogMapper.selectCount(any())).thenReturn(0L);
+        when(cfBalanceLogMapper.selectMaps(any())).thenReturn(new ArrayList<>());
 
 
         FamilyOverviewDTO dto = svc.buildOverview(7L);
         FamilyOverviewDTO dto = svc.buildOverview(7L);
         assertEquals(8L, dto.getCounts().getReports());
         assertEquals(8L, dto.getCounts().getReports());

+ 78 - 0
cfc-backend/src/test/java/com/etotem/cfc/util/FamilyDimensionSummaryBuilderTest.java

@@ -0,0 +1,78 @@
+package com.etotem.cfc.util;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/** 家庭工作台维度汇总纯函数契约:任务执行率/CF获取/报告上传/方案生成。 */
+class FamilyDimensionSummaryBuilderTest {
+
+    private Map<String, Integer> counts(Object... kv) {
+        Map<String, Integer> m = new HashMap<>();
+        for (int i = 0; i < kv.length; i += 2) m.put((String) kv[i], (Integer) kv[i + 1]);
+        return m;
+    }
+
+    @Test
+    void task_完成率与模板实例区分() {
+        Map<String, Object> s = FamilyDimensionSummaryBuilder.task(
+                201, counts("pending", 201, "completed", 0),
+                counts("health_plan", 144, "self", 57),
+                counts("饮食任务", 96, "健康打卡", 57, "运动任务", 48),
+                9L, 192L);
+        assertEquals(201L, s.get("total"));
+        assertEquals(0L, s.get("completed"));
+        assertEquals(201L, s.get("pending"));
+        assertEquals(9L, s.get("templates"));
+        assertEquals(192L, s.get("instances"));
+        assertEquals(0.0, (Double) s.get("completionRate"), 0.001);
+        assertEquals(144, ((Map<?, ?>) s.get("bySource")).get("health_plan"));
+        assertEquals(96, ((Map<?, ?>) s.get("byCategory")).get("饮食任务"));
+    }
+
+    @Test
+    void task_部分完成_完成率四舍五入() {
+        Map<String, Object> s = FamilyDimensionSummaryBuilder.task(
+                8, counts("completed", 3, "pending", 5), counts(), counts(), 1L, 7L);
+        assertEquals(37.5, (Double) s.get("completionRate"), 0.001);
+        assertEquals(3L, s.get("completed"));
+    }
+
+    @Test
+    void task_总数0_完成率0不除零() {
+        Map<String, Object> s = FamilyDimensionSummaryBuilder.task(
+                0, counts(), counts(), counts(), 0L, 0L);
+        assertEquals(0.0, (Double) s.get("completionRate"), 0.001);
+    }
+
+    @Test
+    void cf_累计获取与来源分布() {
+        Map<String, Object> s = FamilyDimensionSummaryBuilder.cf(
+                125190L, 125190L, 0L, 0L, 0L, 7L,
+                counts("cf_consume_order", 3, "F03a", 2, "migration_user_wallet", 1, "referral_register", 1));
+        assertEquals(125190L, s.get("earned"));
+        assertEquals(125190L, s.get("available"));
+        assertEquals(7L, s.get("logCount"));
+        assertEquals(3, ((Map<?, ?>) s.get("bySource")).get("cf_consume_order"));
+    }
+
+    @Test
+    void report_按类型与状态汇总() {
+        Map<String, Object> s = FamilyDimensionSummaryBuilder.report(
+                2, counts("gut_flora", 2), counts("active", 1, "archived", 1));
+        assertEquals(2L, s.get("total"));
+        assertEquals(1, ((Map<?, ?>) s.get("byStatus")).get("active"));
+    }
+
+    @Test
+    void plan_按类型与状态汇总() {
+        Map<String, Object> s = FamilyDimensionSummaryBuilder.plan(
+                3, counts("health_plan", 3), counts("published", 2, "pending_review", 1));
+        assertEquals(3L, s.get("total"));
+        assertEquals(2, ((Map<?, ?>) s.get("byStatus")).get("published"));
+        assertEquals(1, ((Map<?, ?>) s.get("byStatus")).get("pending_review"));
+    }
+}

+ 51 - 0
cfc-web/src/__tests__/views/FamilyWorkbench.dimensions.spec.js

@@ -0,0 +1,51 @@
+import { readFileSync } from 'fs'
+import { resolve } from 'path'
+
+// 契约:家庭工作台「维度下钻」增强(CF获取 / 任务执行 / 报告上传 / 方案生成)
+// 溯源:FamilyWorkbench.vue + api/familyWorkbench.js + AdminFamilyOverviewController
+const VUE_PATH = resolve(__dirname, '../../views/FamilyWorkbench.vue')
+const API_PATH = resolve(__dirname, '../../api/familyWorkbench.js')
+const source = readFileSync(VUE_PATH, 'utf8')
+const api = readFileSync(API_PATH, 'utf8')
+
+describe('FamilyWorkbench.vue 维度下钻(CF/任务/报告/方案)', () => {
+  test('CF统计卡可点击并打开CF获取抽屉(不再是静态卡)', () => {
+    expect(source).toMatch(/key === "cf"/)
+    expect(source).toMatch(/cfDrawerVisible\s*=\s*true/)
+    expect(source).not.toMatch(/key === "cf"\s*\?\s*"wb-card-static"/)
+  })
+
+  test('CF抽屉展示累计获取/来源分布与流水分页表', () => {
+    expect(source).toMatch(/CF值获取(来源与流水)/)
+    expect(source).toMatch(/cfSummary\.earned/)
+    expect(source).toMatch(/cfSummary\.bySource/)
+    expect(source).toMatch(/cfLogList/)
+    expect(source).toMatch(/loadCfLogs/)
+  })
+
+  test('任务抽屉展示完成率、模板/实例区分与来源类别分布', () => {
+    expect(source).toMatch(/taskSummary\.completionRate/)
+    expect(source).toMatch(/taskSummary\.templates/)
+    expect(source).toMatch(/taskSummary\.instances/)
+    expect(source).toMatch(/taskSummary\.bySource/)
+    expect(source).toMatch(/taskSummary\.byCategory/)
+  })
+
+  test('报告与方案抽屉展示状态/类型汇总', () => {
+    expect(source).toMatch(/reportSummary\.byStatus/)
+    expect(source).toMatch(/planSummary\.byStatus/)
+    expect(source).toMatch(/planSummary\.byType/)
+  })
+
+  test('loadOverview 同时装载四类汇总数据', () => {
+    expect(source).toMatch(/res\.data\.cfSummary/)
+    expect(source).toMatch(/res\.data\.taskSummary/)
+    expect(source).toMatch(/res\.data\.reportSummary/)
+    expect(source).toMatch(/res\.data\.planSummary/)
+  })
+
+  test('API 导出 getFamilyCfLogs 并指向 cf-logs 端点', () => {
+    expect(api).toMatch(/export function getFamilyCfLogs/)
+    expect(api).toMatch(/families\/\$\{id\}\/cf-logs/)
+  })
+})

+ 4 - 0
cfc-web/src/api/familyWorkbench.js

@@ -31,3 +31,7 @@ export function createFamilyPlan(id, data) {
 export function updateFamilyPlan(id, data) {
 export function updateFamilyPlan(id, data) {
   return request({ url: `/api/admin/families/${id}/plans/update`, method: "post", data })
   return request({ url: `/api/admin/families/${id}/plans/update`, method: "post", data })
 }
 }
+
+export function getFamilyCfLogs(id, params) {
+  return request({ url: `/api/admin/families/${id}/cf-logs`, method: "post", data: params })
+}

+ 77 - 5
cfc-web/src/views/FamilyWorkbench.vue

@@ -49,6 +49,15 @@
       <div class="mb-12">
       <div class="mb-12">
         <el-button type="primary" size="mini" @click="openTaskForm()">新增任务</el-button>
         <el-button type="primary" size="mini" @click="openTaskForm()">新增任务</el-button>
       </div>
       </div>
+      <div class="wb-summary" v-if="taskSummary.total !== undefined">
+        <span>总数 <b>{{ taskSummary.total }}</b></span>
+        <span>已完成 <b>{{ taskSummary.completed }}</b></span>
+        <span>待办 <b>{{ taskSummary.pending }}</b></span>
+        <span>完成率 <b>{{ taskSummary.completionRate }}%</b></span>
+        <span>模板 <b>{{ taskSummary.templates }}</b> / 实例 <b>{{ taskSummary.instances }}</b></span>
+        <span>来源:<b v-for="(v, k) in taskSummary.bySource" :key="k">{{ k }} {{ v }} </b></span>
+        <span>类别:<b v-for="(v, k) in taskSummary.byCategory" :key="k">{{ k }} {{ v }} </b></span>
+      </div>
       <el-table :data="taskList" size="small" border>
       <el-table :data="taskList" size="small" border>
         <el-table-column prop="title" label="标题" min-width="140"></el-table-column>
         <el-table-column prop="title" label="标题" min-width="140"></el-table-column>
         <el-table-column prop="status" label="状态" width="90"></el-table-column>
         <el-table-column prop="status" label="状态" width="90"></el-table-column>
@@ -68,6 +77,11 @@
       <div class="mb-12">
       <div class="mb-12">
         <el-button type="primary" size="mini" @click="openPlanForm()">新增方案</el-button>
         <el-button type="primary" size="mini" @click="openPlanForm()">新增方案</el-button>
       </div>
       </div>
+      <div class="wb-summary" v-if="planSummary.total !== undefined">
+        <span>总数 <b>{{ planSummary.total }}</b></span>
+        <span>状态:<b v-for="(v, k) in planSummary.byStatus" :key="k">{{ k }} {{ v }} </b></span>
+        <span>类型:<b v-for="(v, k) in planSummary.byType" :key="k">{{ k }} {{ v }} </b></span>
+      </div>
       <el-table :data="planList" size="small" border>
       <el-table :data="planList" size="small" border>
         <el-table-column prop="planType" label="类型" width="90"></el-table-column>
         <el-table-column prop="planType" label="类型" width="90"></el-table-column>
         <el-table-column prop="memberName" label="成员" width="90"></el-table-column>
         <el-table-column prop="memberName" label="成员" width="90"></el-table-column>
@@ -86,6 +100,11 @@
       <div class="mb-12">
       <div class="mb-12">
         <el-button type="primary" size="mini" @click="reportFormVisible = true">手动新增报告</el-button>
         <el-button type="primary" size="mini" @click="reportFormVisible = true">手动新增报告</el-button>
       </div>
       </div>
+      <div class="wb-summary" v-if="reportSummary.total !== undefined">
+        <span>总数 <b>{{ reportSummary.total }}</b></span>
+        <span>状态:<b v-for="(v, k) in reportSummary.byStatus" :key="k">{{ k }} {{ v }} </b></span>
+        <span>类型:<b v-for="(v, k) in reportSummary.byType" :key="k">{{ k }} {{ v }} </b></span>
+      </div>
       <el-table :data="reportList" size="small" border>
       <el-table :data="reportList" size="small" border>
         <el-table-column prop="reportDate" label="日期" width="110"></el-table-column>
         <el-table-column prop="reportDate" label="日期" width="110"></el-table-column>
         <el-table-column prop="personName" label="成员" width="90"></el-table-column>
         <el-table-column prop="personName" label="成员" width="90"></el-table-column>
@@ -95,6 +114,29 @@
       </el-table>
       </el-table>
     </el-drawer>
     </el-drawer>
 
 
+    <!-- CF值获取抽屉 -->
+    <el-drawer title="CF值获取(来源与流水)" :visible.sync="cfDrawerVisible" size="65%">
+      <div class="wb-summary" v-if="cfSummary.earned !== undefined">
+        <span>累计获取 <b>{{ cfSummary.earned }}</b></span>
+        <span>可用 <b>{{ cfSummary.available }}</b></span>
+        <span>冻结 <b>{{ cfSummary.frozen }}</b></span>
+        <span>已提现 <b>{{ cfSummary.withdrawn }}</b></span>
+        <span>已兑换 <b>{{ cfSummary.exchanged }}</b></span>
+        <span>流水 <b>{{ cfSummary.logCount }}</b> 笔</span>
+        <span>来源:<b v-for="(v, k) in cfSummary.bySource" :key="k">{{ k }} {{ v }}笔 </b></span>
+      </div>
+      <el-table :data="cfLogList" size="small" border>
+        <el-table-column prop="createdAt" label="时间" width="160"></el-table-column>
+        <el-table-column prop="type" label="类型" width="90"></el-table-column>
+        <el-table-column prop="refType" label="来源" min-width="150"></el-table-column>
+        <el-table-column prop="amount" label="变动" width="90"></el-table-column>
+        <el-table-column prop="balanceAfter" label="余额" width="90"></el-table-column>
+        <el-table-column prop="remark" label="备注" min-width="150"></el-table-column>
+      </el-table>
+      <el-pagination class="pagination-right-mt12" small background layout="prev, pager, next, total"
+        :total="cfLogTotal" :page-size="cfLogPageSize" :current-page="cfLogPage" @current-change="loadCfLogs"></el-pagination>
+    </el-drawer>
+
     <!-- 消息抽屉 -->
     <!-- 消息抽屉 -->
     <el-drawer title="消息(只读)" :visible.sync="messageDrawerVisible" size="65%">
     <el-drawer title="消息(只读)" :visible.sync="messageDrawerVisible" size="65%">
       <el-button v-if="activeConversationId" size="mini" class="mb-12" @click="messageBack">返回会话列表</el-button>
       <el-button v-if="activeConversationId" size="mini" class="mb-12" @click="messageBack">返回会话列表</el-button>
@@ -182,7 +224,8 @@ import {
   createFamilyTask,
   createFamilyTask,
   updateFamilyTask,
   updateFamilyTask,
   createFamilyPlan,
   createFamilyPlan,
-  updateFamilyPlan
+  updateFamilyPlan,
+  getFamilyCfLogs
 } from "@/api/familyWorkbench"
 } from "@/api/familyWorkbench"
 import { getFamilyTasks, getFamilyOverview } from "@/api/admin"
 import { getFamilyTasks, getFamilyOverview } from "@/api/admin"
 import ChildrenPanel from '@/views/admin/ChildrenPanel.vue'
 import ChildrenPanel from '@/views/admin/ChildrenPanel.vue'
@@ -227,6 +270,15 @@ export default {
       reportList: [],
       reportList: [],
       reportFormVisible: false,
       reportFormVisible: false,
       reportForm: {},
       reportForm: {},
+      cfDrawerVisible: false,
+      cfLogList: [],
+      cfLogTotal: 0,
+      cfLogPage: 1,
+      cfLogPageSize: 10,
+      cfSummary: {},
+      taskSummary: {},
+      reportSummary: {},
+      planSummary: {},
       messageDrawerVisible: false,
       messageDrawerVisible: false,
       conversationList: [],
       conversationList: [],
       conversationPage: 1,
       conversationPage: 1,
@@ -272,8 +324,8 @@ export default {
         this.loading = false
         this.loading = false
       }
       }
     },
     },
-    cardStaticClass(key) {
-      return key === "cf" ? "wb-card-static" : ""
+    cardStaticClass() {
+      return ""
     },
     },
     cardClass(key) {
     cardClass(key) {
       return "wb-card-" + key
       return "wb-card-" + key
@@ -299,11 +351,14 @@ export default {
       })
       })
     },
     },
     openModule(key) {
     openModule(key) {
-      if (key === "cf") return
       this.activeModule = key
       this.activeModule = key
-      if (key === "tasks") {
+      if (key === "cf") {
+        this.cfDrawerVisible = true
+        this.loadCfLogs(1)
+      } else if (key === "tasks") {
         this.taskDrawerVisible = true
         this.taskDrawerVisible = true
         this.loadTasks(1)
         this.loadTasks(1)
+        this.loadOverview()
       } else if (key === "plans") {
       } else if (key === "plans") {
         this.planDrawerVisible = true
         this.planDrawerVisible = true
         this.loadOverview()
         this.loadOverview()
@@ -332,10 +387,25 @@ export default {
         const res = await getFamilyOverview(this.familyId)
         const res = await getFamilyOverview(this.familyId)
         this.reportList = res.data.reports || []
         this.reportList = res.data.reports || []
         this.planList = res.data.plans || []
         this.planList = res.data.plans || []
+        this.cfSummary = res.data.cfSummary || {}
+        this.taskSummary = res.data.taskSummary || {}
+        this.reportSummary = res.data.reportSummary || {}
+        this.planSummary = res.data.planSummary || {}
       } catch (error) {
       } catch (error) {
         this.$message.error(error.message || "加载明细失败")
         this.$message.error(error.message || "加载明细失败")
       }
       }
     },
     },
+    async loadCfLogs(page) {
+      this.cfLogPage = page
+      try {
+        const res = await getFamilyCfLogs(this.familyId, { page, size: this.cfLogPageSize })
+        this.cfLogList = res.data.records || []
+        this.cfLogTotal = res.data.total || 0
+        this.loadOverview()
+      } catch (error) {
+        this.$message.error(error.message || "加载CF流水失败")
+      }
+    },
     openTaskForm(row) {
     openTaskForm(row) {
       this.taskForm = row ? { ...row } : { title: "", category: "", points: 0, taskType: "once", description: "" }
       this.taskForm = row ? { ...row } : { title: "", category: "", points: 0, taskType: "once", description: "" }
       this.taskFormVisible = true
       this.taskFormVisible = true
@@ -433,6 +503,8 @@ export default {
 .wb-card:hover { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); }
 .wb-card:hover { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); }
 .wb-card-static { cursor: default; }
 .wb-card-static { cursor: default; }
 .wb-card-static:hover { box-shadow: none; }
 .wb-card-static:hover { box-shadow: none; }
+.wb-summary { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--adm-text-65); margin-bottom: 12px; padding: 8px; background: #f8f9fb; border-radius: 4px; }
+.wb-summary b { color: var(--adm-text-88); }
 .wb-card-label { font-size: 12px; color: var(--adm-text-65); line-height: 18px; }
 .wb-card-label { font-size: 12px; color: var(--adm-text-65); line-height: 18px; }
 .wb-card-total { font-size: 18px; font-weight: 600; color: var(--adm-text-88); margin: 0 0 2px; line-height: 24px; }
 .wb-card-total { font-size: 18px; font-weight: 600; color: var(--adm-text-88); margin: 0 0 2px; line-height: 24px; }
 .wb-card-chart { height: 24px; }
 .wb-card-chart { height: 24px; }