소스 검색

feat(admin): 后台CF值实时查看(个人/家庭汇总/流水)+ 家庭列表CF列与明细

- 新增 /api/admin/cf-balance/{members,families,logs},实时读统一账本 cf_balance / cf_balance_log
- 个人余额:成员昵称/家庭/累计获得/可用/冻结/已提现/已兑换,支持关键字与家庭筛选
- 家庭合计:按 family_id 聚合全体成员可用之和(家庭CF值口径),并给累计获得/已兑换
- 流水明细:按家庭或成员查获取/消费/调整等流水
- 家庭列表加「家庭CF值」列(cf_available 回填),点击弹窗查看该家庭CF明细
- CF值管理页改读实时账本(个人余额/家庭合计/流水明细三 Tab),不再读已停写的旧表
- 迁移465:sys_menu 幂等补 CF值管理菜单(/cf-value,finance:cf-value),种子同步
Xiaogang Liao 2 주 전
부모
커밋
5768275460

+ 36 - 0
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -3493,6 +3493,37 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
         createAttributionCaseStrategyTable();
     }
 
+    /**
+     * 迁移465: 后台「CF值管理」菜单幂等插入。
+     *
+     * <p>CF 账本统一后(F-6/F-8),后台需要一个实时查看个人/家庭 CF 的入口;
+     * 路由 /cf-value 已存在,仅补 sys_menu 记录,挂在「商城营销」下(与家庭收益同级)。
+     * 幂等:path 已存在则跳过;父菜单缺失则跳过并告警。</p>
+     */
+    private void ensureCfValueMenu() {
+        try {
+            Integer exists = jdbcTemplate.queryForObject(
+                    "SELECT COUNT(*) FROM sys_menu WHERE path = '/cf-value'", Integer.class);
+            if (exists != null && exists > 0) {
+                log.info("迁移465: CF值管理菜单已存在,跳过");
+                return;
+            }
+            Long parentId = queryMenuId(
+                    "SELECT id FROM sys_menu WHERE perm = 'commerce:*' AND parent_id = 0 LIMIT 1");
+            if (parentId == null) {
+                log.warn("迁移465: 未找到「商城营销」父菜单,CF值管理菜单跳过");
+                return;
+            }
+            jdbcTemplate.update(
+                    "INSERT INTO sys_menu (parent_id, title, label, path, icon, perm, sort, visible, created_at, updated_at) "
+                            + "VALUES (?, NULL, ?, '/cf-value', 'el-icon-s-finance', 'finance:cf-value', 9, 1, NOW(), NOW())",
+                    parentId, "CF值管理");
+            log.info("迁移465: CF值管理菜单已插入(parentId={})", parentId);
+        } catch (Exception e) {
+            log.warn("迁移465: CF值管理菜单插入失败(忽略): {}", e.getMessage());
+        }
+    }
+
     /**
      * 迁移464: 创建 P3 跨案例聚合承载表(T15 跨案例聚合,S-cfc-119 guhe.p3.lowSideAggregate)。
      *
@@ -10338,6 +10369,10 @@ sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min,
             log.warn("初始化sys_menu种子数据失败: " + e.getMessage());
         }
 
+        // 迁移465: 后台「CF值管理」菜单(/cf-value,finance:cf-value),幂等插入
+        // 放在 sys_menu 种子之后:全新库由种子直接写入,老库由此兜底补齐。
+        ensureCfValueMenu();
+
 // 迁移245: 创建 notification_templates 表(通知模板管理 W3)
         try {
             jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS notification_templates (" +
@@ -10706,6 +10741,7 @@ sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min,
                 {"commerce", "discountRules", "", "限时折扣管理", "/discount-rules", "el-icon-timer", "commerce:discount", "7"},
                 {"commerce", "promotion", "", "推广管理", "/promotion", "el-icon-s-marketing", "commerce:promotion", "7"},
                 {"commerce", "familyEarnings", "", "家庭收益", "/family-earnings", "el-icon-s-money", "finance:family-earnings", "8"},
+                {"commerce", "cfValue", "", "CF值管理", "/cf-value", "el-icon-s-finance", "finance:cf-value", "9"},
                 // 知识中心(articles:*)
                 {"", "knowledge", "知识中心", "", "", "el-icon-document", "articles:*", "6"},
                 {"knowledge", "articleCategories", "", "知识分类", "/article-categories", "el-icon-folder", "articles:categories", "0"},

+ 88 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminCfBalanceController.java

@@ -0,0 +1,88 @@
+package com.etotem.cfc.controller.admin;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.etotem.cfc.common.Result;
+import com.etotem.cfc.dto.CfAdminLogVO;
+import com.etotem.cfc.dto.CfFamilySummaryVO;
+import com.etotem.cfc.dto.CfMemberBalanceVO;
+import com.etotem.cfc.mapper.CfBalanceLogMapper;
+import com.etotem.cfc.mapper.CfBalanceMapper;
+import com.etotem.cfc.util.ParamUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Map;
+
+/**
+ * 后台 CF 值实时查询(个人 / 家庭汇总 / 流水明细)。
+ *
+ * <p>数据源为统一账本 {@code cf_balance} / {@code cf_balance_log}(F-6/F-8 后的唯一事实源),
+ * 与 C 端 {@code /api/cf/*} 同源,避免再读已停写的 {@code user_platform_balance}。</p>
+ */
+@RestController
+@RequestMapping("/api/admin/cf-balance")
+public class AdminCfBalanceController {
+
+    @Resource
+    private CfBalanceMapper cfBalanceMapper;
+
+    @Resource
+    private CfBalanceLogMapper cfBalanceLogMapper;
+
+    /**
+     * 个人 CF 余额列表(分页)。
+     *
+     * <p>params: page / size / keyword(成员昵称|手机|用户ID)/ familyId</p>
+     */
+    @PostMapping("/members")
+    public Result<IPage<CfMemberBalanceVO>> members(@RequestBody Map<String, Object> params) {
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        String keyword = params.get("keyword") != null ? String.valueOf(params.get("keyword")).trim() : null;
+        if (keyword != null && keyword.isEmpty()) {
+            keyword = null;
+        }
+        Long familyId = ParamUtils.getLong(params.get("familyId"));
+        IPage<CfMemberBalanceVO> result =
+                cfBalanceMapper.selectMemberBalances(new Page<>(page, size), keyword, familyId);
+        return Result.success(result);
+    }
+
+    /**
+     * 家庭 CF 汇总(分页,按 family_id 聚合全体成员)。
+     *
+     * <p>params: page / size / keyword(家庭名称)</p>
+     */
+    @PostMapping("/families")
+    public Result<IPage<CfFamilySummaryVO>> families(@RequestBody Map<String, Object> params) {
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        String keyword = params.get("keyword") != null ? String.valueOf(params.get("keyword")).trim() : null;
+        if (keyword != null && keyword.isEmpty()) {
+            keyword = null;
+        }
+        IPage<CfFamilySummaryVO> result =
+                cfBalanceMapper.selectFamilySummary(new Page<>(page, size), keyword);
+        return Result.success(result);
+    }
+
+    /**
+     * CF 流水明细(分页)。
+     *
+     * <p>params: page / size / familyId / memberId(两者至少一个)</p>
+     */
+    @PostMapping("/logs")
+    public Result<IPage<CfAdminLogVO>> logs(@RequestBody Map<String, Object> params) {
+        int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
+        int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
+        Long familyId = ParamUtils.getLong(params.get("familyId"));
+        Long memberId = ParamUtils.getLong(params.get("memberId"));
+        IPage<CfAdminLogVO> result =
+                cfBalanceLogMapper.selectAdminLogs(new Page<>(page, size), familyId, memberId);
+        return Result.success(result);
+    }
+}

+ 17 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/AdminController.java

@@ -71,6 +71,9 @@ public class AdminController {
     @Resource
     private FamilyCouponMapper familyCouponMapper;
 
+    @Resource
+    private CfBalanceMapper cfBalanceMapper;
+
     @Resource
     private TaskTemplateMapper taskTemplateMapper;
 
@@ -838,12 +841,26 @@ public class AdminController {
             Map<Long, Long> planCnt   = countByFamilyIds(healthPlanMapper, ids, null);
             Map<Long, Long> taskCnt   = countByFamilyIds(taskMapper, ids, null);
             Map<Long, Long> couponCnt = countByFamilyIds(familyCouponMapper, ids, null);
+            // 家庭 CF 值回填:cf_balance 按 family_id 批量汇总(可用 / 累计获得)
+            Map<Long, Long> cfAvail = new HashMap<>();
+            Map<Long, Long> cfEarned = new HashMap<>();
+            for (Map<String, Object> row : cfBalanceMapper.sumByFamilyIds(ids)) {
+                Object k = row.get("familyId");
+                if (k == null) continue;
+                long fid = ((Number) k).longValue();
+                Object a = row.get("available");
+                Object e = row.get("totalEarned");
+                cfAvail.put(fid, a != null ? ((Number) a).longValue() : 0L);
+                cfEarned.put(fid, e != null ? ((Number) e).longValue() : 0L);
+            }
             for (Family f : records) {
                 f.setMemberCount(memberCnt.getOrDefault(f.getId(), 0L));
                 f.setReportCount(reportCnt.getOrDefault(f.getId(), 0L));
                 f.setPlanCount(planCnt.getOrDefault(f.getId(), 0L));
                 f.setTaskCount(taskCnt.getOrDefault(f.getId(), 0L));
                 f.setCouponCount(couponCnt.getOrDefault(f.getId(), 0L));
+                f.setCfAvailable(cfAvail.getOrDefault(f.getId(), 0L));
+                f.setCfTotalEarned(cfEarned.getOrDefault(f.getId(), 0L));
             }
         }
         return Result.success(result);

+ 46 - 0
cfc-backend/src/main/java/com/etotem/cfc/dto/CfAdminLogVO.java

@@ -0,0 +1,46 @@
+package com.etotem.cfc.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 后台 CF 流水明细项(cf_balance_log,联查家庭成员昵称)。
+ */
+@Data
+public class CfAdminLogVO implements Serializable {
+
+    private Long id;
+
+    /** family_members.id */
+    private Long memberId;
+
+    private Long userId;
+
+    private Long familyId;
+
+    /** 家庭成员昵称 */
+    private String memberName;
+
+    /** earn/spend/freeze/unfreeze/withdraw/adjust/skip */
+    private String type;
+
+    /** 规则编码或迁移标识(F02~F24 / migration_*) */
+    private String refType;
+
+    private Long refId;
+
+    /** 变动数量(正负) */
+    private Integer amount;
+
+    /** 变动后可用余额 */
+    private Integer balanceAfter;
+
+    private String remark;
+
+    /** 操作人用户ID */
+    private Long operatorUserId;
+
+    private Date createdAt;
+}

+ 37 - 0
cfc-backend/src/main/java/com/etotem/cfc/dto/CfFamilySummaryVO.java

@@ -0,0 +1,37 @@
+package com.etotem.cfc.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 后台「家庭 CF 汇总」列表项(按 cf_balance.family_id 聚合全体成员)。
+ */
+@Data
+public class CfFamilySummaryVO implements Serializable {
+
+    private Long familyId;
+
+    /** 家庭名称 */
+    private String familyName;
+
+    /** 该家庭有 CF 账本的成员数 */
+    private Long memberCount;
+
+    /** 累计获得(成员之和) */
+    private Long totalEarned;
+
+    /** 可用(成员之和,即「家庭CF值」口径) */
+    private Long available;
+
+    private Long frozen;
+
+    private Long withdrawn;
+
+    /** 已兑换消费(成员之和) */
+    private Long exchanged;
+
+    /** 最近变动时间 */
+    private Date updatedAt;
+}

+ 41 - 0
cfc-backend/src/main/java/com/etotem/cfc/dto/CfMemberBalanceVO.java

@@ -0,0 +1,41 @@
+package com.etotem.cfc.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 后台「个人 CF 余额」列表项(实时读 cf_balance,联查家庭成员/家庭名)。
+ */
+@Data
+public class CfMemberBalanceVO implements Serializable {
+
+    /** family_members.id */
+    private Long memberId;
+
+    /** users.id(可为空) */
+    private Long userId;
+
+    private Long familyId;
+
+    /** 家庭成员昵称 */
+    private String memberName;
+
+    private String phone;
+
+    /** 家庭名称 */
+    private String familyName;
+
+    private Integer totalEarned;
+
+    private Integer available;
+
+    private Integer frozen;
+
+    private Integer withdrawn;
+
+    private Integer exchanged;
+
+    private Date updatedAt;
+}

+ 6 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/Family.java

@@ -52,6 +52,12 @@ public class Family implements Serializable {
     @TableField(exist = false)
     private Long couponCount;   // 优惠券数量(family_coupon 记录总数)
 
+    @TableField(exist = false)
+    private Long cfAvailable;   // 家庭CF值(cf_balance 全体成员 available 之和)
+
+    @TableField(exist = false)
+    private Long cfTotalEarned; // 家庭累计获得CF(cf_balance 全体成员 total_earned 之和)
+
     public Long getCreatorId() { return creatorId; }
     public void setCreatorId(Long creatorId) { this.creatorId = creatorId; }
 }

+ 24 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/CfBalanceLogMapper.java

@@ -1,7 +1,31 @@
 package com.etotem.cfc.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.etotem.cfc.dto.CfAdminLogVO;
 import com.etotem.cfc.entity.CfBalanceLog;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 public interface CfBalanceLogMapper extends BaseMapper<CfBalanceLog> {
+
+    /**
+     * 后台:CF 流水明细分页(联查家庭成员昵称),支持按家庭或成员过滤。
+     */
+    @Select("<script>"
+            + "SELECT l.id, l.member_id AS memberId, l.user_id AS userId, l.family_id AS familyId, "
+            + "fm.nickname AS memberName, l.type AS type, l.ref_type AS refType, l.ref_id AS refId, "
+            + "l.amount AS amount, l.balance_after AS balanceAfter, l.remark AS remark, "
+            + "l.operator_user_id AS operatorUserId, l.created_at AS createdAt "
+            + "FROM cf_balance_log l "
+            + "LEFT JOIN family_members fm ON fm.id = l.member_id "
+            + "WHERE 1=1 "
+            + "<if test='familyId != null'> AND l.family_id = #{familyId} </if>"
+            + "<if test='memberId != null'> AND l.member_id = #{memberId} </if>"
+            + "ORDER BY l.created_at DESC, l.id DESC"
+            + "</script>")
+    IPage<CfAdminLogVO> selectAdminLogs(Page<?> page,
+                                        @Param("familyId") Long familyId,
+                                        @Param("memberId") Long memberId);
 }

+ 61 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/CfBalanceMapper.java

@@ -1,10 +1,17 @@
 package com.etotem.cfc.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.etotem.cfc.dto.CfFamilySummaryVO;
+import com.etotem.cfc.dto.CfMemberBalanceVO;
 import com.etotem.cfc.entity.CfBalance;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
+import java.util.List;
+import java.util.Map;
+
 public interface CfBalanceMapper extends BaseMapper<CfBalance> {
 
     /**
@@ -15,4 +22,58 @@ public interface CfBalanceMapper extends BaseMapper<CfBalance> {
      */
     @Select("SELECT * FROM cf_balance WHERE member_id = #{memberId} FOR UPDATE")
     CfBalance selectForUpdate(@Param("memberId") Long memberId);
+
+    /**
+     * 后台:个人 CF 余额分页(联查家庭成员昵称/手机、家庭名称)。
+     */
+    @Select("<script>"
+            + "SELECT cb.member_id AS memberId, cb.user_id AS userId, cb.family_id AS familyId, "
+            + "fm.nickname AS memberName, fm.phone AS phone, f.name AS familyName, "
+            + "cb.total_earned AS totalEarned, cb.available AS available, cb.frozen AS frozen, "
+            + "cb.withdrawn AS withdrawn, cb.exchanged AS exchanged, cb.updated_at AS updatedAt "
+            + "FROM cf_balance cb "
+            + "LEFT JOIN family_members fm ON fm.id = cb.member_id "
+            + "LEFT JOIN families f ON f.id = cb.family_id "
+            + "WHERE 1=1 "
+            + "<if test='familyId != null'> AND cb.family_id = #{familyId} </if>"
+            + "<if test='keyword != null and keyword != \"\"'> AND (fm.nickname LIKE CONCAT('%', #{keyword}, '%') "
+            + "OR fm.phone LIKE CONCAT('%', #{keyword}, '%') OR CAST(cb.user_id AS CHAR) = #{keyword}) </if>"
+            + "ORDER BY cb.updated_at DESC, cb.id DESC"
+            + "</script>")
+    IPage<CfMemberBalanceVO> selectMemberBalances(Page<?> page,
+                                                  @Param("keyword") String keyword,
+                                                  @Param("familyId") Long familyId);
+
+    /**
+     * 后台:家庭 CF 汇总分页(按 family_id 聚合全体成员)。
+     */
+    @Select("<script>"
+            + "SELECT cb.family_id AS familyId, f.name AS familyName, COUNT(*) AS memberCount, "
+            + "CAST(SUM(cb.total_earned) AS SIGNED) AS totalEarned, "
+            + "CAST(SUM(cb.available) AS SIGNED) AS available, "
+            + "CAST(SUM(cb.frozen) AS SIGNED) AS frozen, "
+            + "CAST(SUM(cb.withdrawn) AS SIGNED) AS withdrawn, "
+            + "CAST(SUM(cb.exchanged) AS SIGNED) AS exchanged, "
+            + "MAX(cb.updated_at) AS updatedAt "
+            + "FROM cf_balance cb "
+            + "LEFT JOIN families f ON f.id = cb.family_id "
+            + "WHERE cb.family_id IS NOT NULL AND cb.family_id &gt; 0 "
+            + "<if test='keyword != null and keyword != \"\"'> AND f.name LIKE CONCAT('%', #{keyword}, '%') </if>"
+            + "GROUP BY cb.family_id, f.name "
+            + "ORDER BY SUM(cb.available) DESC, cb.family_id ASC"
+            + "</script>")
+    IPage<CfFamilySummaryVO> selectFamilySummary(Page<?> page, @Param("keyword") String keyword);
+
+    /**
+     * 家庭列表回填:按家庭ID批量汇总可用/累计获得。
+     */
+    @Select("<script>"
+            + "SELECT family_id AS familyId, "
+            + "CAST(SUM(available) AS SIGNED) AS available, "
+            + "CAST(SUM(total_earned) AS SIGNED) AS totalEarned "
+            + "FROM cf_balance WHERE family_id IN "
+            + "<foreach collection='ids' item='id' open='(' separator=',' close=')'>#{id}</foreach> "
+            + "GROUP BY family_id"
+            + "</script>")
+    List<Map<String, Object>> sumByFamilyIds(@Param("ids") List<Long> ids);
 }

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-4e8e7a26b160930d74dcbf75ca0f1491202ededd
+1e0c63059c1c7e99433874ade2795c26fd0984dc

+ 1 - 1
cfc-web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "cfc-web",
-  "version": "1.0.2297",
+  "version": "1.0.2298",
   "private": true,
   "scripts": {
     "dev": "vue-cli-service serve",

+ 6 - 0
cfc-web/public/CHANGELOG-v1.0.md

@@ -4,6 +4,12 @@
 
 ---
 
+## v1.0.2298 (2026-11-10)
+
+### 文档
+- 研发负责人闭环巡检汇报 2026-11-10-1047
+
+
 ## v1.0.2297 (2026-11-10)
 
 ### 文档

+ 7 - 1
cfc-web/public/CHANGELOG.md

@@ -1,6 +1,6 @@
 # 更新日志
 
-> 当前版本: v1.0.2297
+> 当前版本: v1.0.2298
 
 ## 历史版本
 
@@ -8,6 +8,12 @@
 
 ---
 
+## v1.0.2298 (2026-11-10)
+
+### 文档
+- 研发负责人闭环巡检汇报 2026-11-10-1047
+
+
 ## v1.0.2297 (2026-11-10)
 
 ### 文档

+ 25 - 0
cfc-web/src/api/admin.js

@@ -2233,6 +2233,31 @@ export function getCfValueAllBalances(data) {
   })
 }
 
+// ===== CF值(实时账本 cf_balance)管理 =====
+export function getCfMemberBalances(data) {
+  return request({
+    url: '/api/admin/cf-balance/members',
+    method: 'post',
+    data
+  })
+}
+
+export function getCfFamilySummary(data) {
+  return request({
+    url: '/api/admin/cf-balance/families',
+    method: 'post',
+    data
+  })
+}
+
+export function getCfAdminLogs(data) {
+  return request({
+    url: '/api/admin/cf-balance/logs',
+    method: 'post',
+    data
+  })
+}
+
 // 获取已入驻的服务商列表(用于商品编辑下拉选择)
 export function getApprovedGuides() {
   return request({

+ 90 - 1
cfc-web/src/views/Families.vue

@@ -80,6 +80,11 @@
             <el-link type="primary" :underline="false" @click.stop="goCouponManage(scope.row.id)">{{ scope.row.couponCount }}</el-link>
           </template>
         </el-table-column>
+        <el-table-column prop="cfAvailable" label="家庭CF值" width="110">
+          <template slot-scope="scope">
+            <el-link type="primary" :underline="false" @click.stop="openCfDetail(scope.row)">{{ scope.row.cfAvailable || 0 }}</el-link>
+          </template>
+        </el-table-column>
         <el-table-column label="操作" width="250" fixed="right">
           <template slot-scope="{ row }">
             <el-button size="mini" type="primary" @click="handleEdit(row)">编辑</el-button>
@@ -110,6 +115,51 @@
       ></el-pagination>
     </el-card>
 
+    <!-- 家庭CF明细弹窗 -->
+    <el-dialog
+      title="家庭CF值明细"
+      :visible.sync="cfDialogVisible"
+      width="1000px"
+    >
+      <div v-if="cfFamily">
+        <el-descriptions :column="3" border class="mb-20">
+          <el-descriptions-item label="家庭名称">{{ cfFamily.name }}</el-descriptions-item>
+          <el-descriptions-item label="家庭CF值(可用)">{{ cfFamily.cfAvailable || 0 }}</el-descriptions-item>
+          <el-descriptions-item label="累计获得">{{ cfFamily.cfTotalEarned || 0 }}</el-descriptions-item>
+        </el-descriptions>
+        <el-table :data="cfLogs" border class="full-width" max-height="400" v-loading="cfLoading">
+          <el-table-column label="成员" min-width="110" show-overflow-tooltip>
+            <template slot-scope="{ row }">{{ row.memberName || ('成员' + row.memberId) }}</template>
+          </el-table-column>
+          <el-table-column label="类型" width="110">
+            <template slot-scope="{ row }">
+              <StatusTag :type="cfTypeTag(row.type)" size="small" :text="cfTypeLabel(row.type)" />
+            </template>
+          </el-table-column>
+          <el-table-column label="数量" width="90">
+            <template slot-scope="{ row }">
+              <span :class="row.amount >= 0 ? 'num-plus' : 'num-minus'">{{ row.amount > 0 ? '+' : '' }}{{ row.amount }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column prop="balanceAfter" label="变动后余额" width="110" />
+          <el-table-column prop="refType" label="来源" width="140" show-overflow-tooltip />
+          <el-table-column prop="remark" label="备注" min-width="160" show-overflow-tooltip />
+          <el-table-column label="时间" width="160">
+            <template slot-scope="{ row }">{{ formatDate(row.createdAt) }}</template>
+          </el-table-column>
+        </el-table>
+        <el-pagination
+          class="pagination-right-mt12"
+          @current-change="loadCfLogs"
+          :current-page="cfLogPage"
+          :page-size="cfLogSize"
+          :total="cfLogTotal"
+          layout="total, prev, pager, next"
+        />
+        <el-empty v-if="!cfLoading && (!cfLogs || !cfLogs.length)" description="暂无CF流水" :image-size="60" />
+      </div>
+    </el-dialog>
+
     <!-- 编辑家庭弹窗 -->
     <el-dialog
       title="编辑家庭"
@@ -282,7 +332,7 @@
 <script>
 import SortMixin from '@/mixins/SortMixin'
 import ListStateMixin from '@/mixins/ListStateMixin'
-import { getFamilyList, getFamilyMembers, getFamilyOverview, getFamilyTasks, updateFamily, deleteFamily, setMemberAdminRole } from '@/api/admin'
+import { getFamilyList, getFamilyMembers, getFamilyOverview, getFamilyTasks, updateFamily, deleteFamily, setMemberAdminRole, getCfAdminLogs } from '@/api/admin'
 
 export default {
   name: 'Families',
@@ -325,6 +375,13 @@ export default {
         family: null,
         members: []
       },
+      cfDialogVisible: false,
+      cfFamily: null,
+      cfLogs: [],
+      cfLoading: false,
+      cfLogPage: 1,
+      cfLogSize: 20,
+      cfLogTotal: 0,
       detailDialogVisible: false,
       detailType: '',
       detailFamilyId: null,
@@ -499,6 +556,36 @@ export default {
     goCouponManage(familyId) {
       this.$router.push({ path: '/admin/family-coupon', query: { familyId } })
     },
+    openCfDetail(row) {
+      this.cfFamily = row
+      this.cfDialogVisible = true
+      this.cfLogPage = 1
+      this.loadCfLogs()
+    },
+    async loadCfLogs(page) {
+      if (!this.cfFamily) return
+      if (page) this.cfLogPage = page
+      this.cfLoading = true
+      try {
+        const res = await getCfAdminLogs({ familyId: this.cfFamily.id, page: this.cfLogPage, size: this.cfLogSize })
+        if (res.code === 200) {
+          this.cfLogs = (res.data && res.data.records) || []
+          this.cfLogTotal = (res.data && res.data.total) || 0
+        }
+      } catch (error) {
+        this.$message.error(error.message || '加载CF明细失败')
+      } finally {
+        this.cfLoading = false
+      }
+    },
+    cfTypeLabel(type) {
+      const map = { earn: '获取', spend: '消费', freeze: '冻结', unfreeze: '解冻', withdraw: '提现', adjust: '管理员调整', skip: '未发放' }
+      return map[type] || type
+    },
+    cfTypeTag(type) {
+      const map = { earn: 'success', spend: 'warning', freeze: 'info', unfreeze: 'info', withdraw: 'primary', adjust: 'danger', skip: 'info' }
+      return map[type] || 'info'
+    },
     openDetailDialog(familyId, type) {
       this.detailFamilyId = familyId
       this.detailType = type
@@ -554,6 +641,8 @@ export default {
 .full-width { width: 100%; }
 .w-120 { width: 120px; }
 .cell-zero { color: #999; }
+.num-plus { color: #67c23a; font-weight: 600; }
+.num-minus { color: #f56c6c; font-weight: 600; }
 .pagination-right { margin-top: 24px; text-align: right; }
 .pagination-right-mt12 { margin-top: 12px; text-align: right; }
 </style>

+ 294 - 192
cfc-web/src/views/admin/CfValueManage.vue

@@ -1,236 +1,333 @@
 <template>
   <div class="cf-value admin-page">
-    <PageHeader title="CF值(平台积分)管理">
-      <div class="filters">
-        <el-input v-model="searchUserId" placeholder="用户ID/用户名搜索" class="filter-input-200" clearable @keyup.enter.native="searchBalance" />
-        <el-button type="primary" @click="searchBalance">查询余额</el-button>
-      </div>
+    <PageHeader title="CF值管理">
+      <span class="tip-text">数据源:统一账本 cf_balance(实时)</span>
     </PageHeader>
 
-    <el-tabs v-model="activeTab">
-      <el-tab-pane label="余额列表" name="balances">
-                <div class="adm-table-wrap">
-<el-table :data="balanceList" v-loading="loadingBalance" border stripe height="100%">
-          <el-table-column prop="id" label="ID" width="70">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('id', $event)">ID<span v-if="sortIndex('id') !== null" class="sort-index" :class="sortClass('id') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('id') }}</span>{{ sortIcon('id') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="用户" width="140">
-            <template slot-scope="{ row }">{{ row.userName || '用户' + row.userId }}</template>
-          </el-table-column>
-          <el-table-column prop="familyId" label="家庭ID" width="100">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('familyId', $event)">家庭ID<span v-if="sortIndex('familyId') !== null" class="sort-index" :class="sortClass('familyId') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('familyId') }}</span>{{ sortIcon('familyId') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="totalEarned" label="累计获得" width="100">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('totalEarned', $event)">累计获得<span v-if="sortIndex('totalEarned') !== null" class="sort-index" :class="sortClass('totalEarned') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('totalEarned') }}</span>{{ sortIcon('totalEarned') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="available" label="可用" width="80">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('available', $event)">可用<span v-if="sortIndex('available') !== null" class="sort-index" :class="sortClass('available') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('available') }}</span>{{ sortIcon('available') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="frozen" label="冻结" width="80">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('frozen', $event)">冻结<span v-if="sortIndex('frozen') !== null" class="sort-index" :class="sortClass('frozen') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('frozen') }}</span>{{ sortIcon('frozen') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="withdrawn" label="已提现" width="80">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('withdrawn', $event)">已提现<span v-if="sortIndex('withdrawn') !== null" class="sort-index" :class="sortClass('withdrawn') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('withdrawn') }}</span>{{ sortIcon('withdrawn') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="exchanged" label="已兑换" width="80">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('exchanged', $event)">已兑换<span v-if="sortIndex('exchanged') !== null" class="sort-index" :class="sortClass('exchanged') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('exchanged') }}</span>{{ sortIcon('exchanged') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="操作" width="100">
-            <template slot-scope="{ row }">
-              <el-button type="text" size="small" @click="viewLogs(row.userId)">流水</el-button>
-            </template>
-          </el-table-column>
-        </el-table>
+    <el-tabs v-model="activeTab" @tab-click="handleTabChange">
+      <!-- 个人余额 -->
+      <el-tab-pane label="个人余额" name="members">
+        <div class="filters">
+          <el-input
+            v-model="memberFilter.keyword"
+            placeholder="成员昵称/手机/用户ID"
+            class="filter-input-200"
+            clearable
+            @keyup.enter.native="searchMembers"
+          />
+          <el-input
+            v-model="memberFilter.familyId"
+            placeholder="家庭ID"
+            class="filter-input-120"
+            clearable
+            @keyup.enter.native="searchMembers"
+          />
+          <el-button type="primary" @click="searchMembers">查询</el-button>
+          <el-button @click="resetMembers">重置</el-button>
+        </div>
+        <div class="adm-table-wrap">
+          <el-table :data="memberList" v-loading="loadingMember" border stripe height="100%">
+            <el-table-column label="成员" min-width="130" show-overflow-tooltip>
+              <template slot-scope="{ row }">{{ row.memberName || ('成员' + row.memberId) }}</template>
+            </el-table-column>
+            <el-table-column prop="userId" label="用户ID" width="90" />
+            <el-table-column label="家庭" min-width="140" show-overflow-tooltip>
+              <template slot-scope="{ row }">{{ row.familyName || ('家庭' + (row.familyId || '-')) }}</template>
+            </el-table-column>
+            <el-table-column prop="totalEarned" label="累计获得" width="100" />
+            <el-table-column prop="available" label="可用" width="90">
+              <template slot-scope="{ row }"><span class="num-strong">{{ row.available }}</span></template>
+            </el-table-column>
+            <el-table-column prop="frozen" label="冻结" width="90" />
+            <el-table-column prop="withdrawn" label="已提现" width="90" />
+            <el-table-column prop="exchanged" label="已兑换消费" width="110" />
+            <el-table-column label="更新时间" width="160">
+              <template slot-scope="{ row }">{{ fmtDate(row.updatedAt) }}</template>
+            </el-table-column>
+            <el-table-column label="操作" width="90" fixed="right">
+              <template slot-scope="{ row }">
+                <el-button type="text" size="small" @click="viewMemberLogs(row)">流水</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
         </div>
-        <el-pagination v-if="balanceTotal > 0" :current-page="balancePage" :page-size="balanceSize" :total="balanceTotal" layout="prev, pager, next" @current-change="pageBalances" />
+        <el-pagination
+          v-if="memberTotal > 0"
+          class="pagination-mt"
+          :current-page="memberPage"
+          :page-size="memberSize"
+          :total="memberTotal"
+          layout="total, prev, pager, next"
+          @current-change="pageMembers"
+        />
       </el-tab-pane>
 
-      <el-tab-pane label="流水查询" name="logs">
+      <!-- 家庭合计 -->
+      <el-tab-pane label="家庭合计" name="families">
         <div class="filters">
-          <el-input v-model="logUserId" placeholder="用户ID" class="filter-input-200" clearable @keyup.enter.native="searchLogs" />
-          <el-button type="primary" @click="searchLogs">查询流水</el-button>
+          <el-input
+            v-model="familyFilter.keyword"
+            placeholder="家庭名称"
+            class="filter-input-200"
+            clearable
+            @keyup.enter.native="searchFamilies"
+          />
+          <el-button type="primary" @click="searchFamilies">查询</el-button>
+          <el-button @click="resetFamilies">重置</el-button>
         </div>
-                <div class="adm-table-wrap">
-<el-table :data="logList" v-loading="loadingLog" border stripe height="100%">
-          <el-table-column prop="id" label="ID" width="70">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('id', $event)">ID<span v-if="sortIndex('id') !== null" class="sort-index" :class="sortClass('id') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('id') }}</span>{{ sortIcon('id') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="用户" width="120">
-            <template slot-scope="{ row }">{{ row.userName || '用户' + row.userId }}</template>
-          </el-table-column>
-          <el-table-column prop="type" label="类型" width="100">
-            <template slot-scope="{ row }">
-              <StatusTag :type="typeTag(row.type)" size="small" :text="row.type" />
-            </template>
-          </el-table-column>
-          <el-table-column prop="amount" label="数量" width="80">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('amount', $event)">数量<span v-if="sortIndex('amount') !== null" class="sort-index" :class="sortClass('amount') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('amount') }}</span>{{ sortIcon('amount') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="balanceAfter" label="变动后余额" width="100">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('balanceAfter', $event)">变动后余额<span v-if="sortIndex('balanceAfter') !== null" class="sort-index" :class="sortClass('balanceAfter') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('balanceAfter') }}</span>{{ sortIcon('balanceAfter') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="refType" label="来源" width="130">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('refType', $event)">来源<span v-if="sortIndex('refType') !== null" class="sort-index" :class="sortClass('refType') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('refType') }}</span>{{ sortIcon('refType') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="refId" label="关联ID" width="80">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('refId', $event)">关联ID<span v-if="sortIndex('refId') !== null" class="sort-index" :class="sortClass('refId') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('refId') }}</span>{{ sortIcon('refId') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="remark" label="备注" min-width="160" show-overflow-tooltip>
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('remark', $event)">备注<span v-if="sortIndex('remark') !== null" class="sort-index" :class="sortClass('remark') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('remark') }}</span>{{ sortIcon('remark') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="createdAt" label="时间" width="160">
-            <template slot="header">
-              <span class="sort-header" @click.stop="onSortClick('createdAt', $event)">时间<span v-if="sortIndex('createdAt') !== null" class="sort-index" :class="sortClass('createdAt') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('createdAt') }}</span>{{ sortIcon('createdAt') }}</span>
-            </template>
-          </el-table-column>
-        </el-table>
+        <div class="adm-table-wrap">
+          <el-table :data="familyList" v-loading="loadingFamily" border stripe height="100%">
+            <el-table-column prop="familyId" label="家庭ID" width="90" />
+            <el-table-column prop="familyName" label="家庭名称" min-width="160" show-overflow-tooltip />
+            <el-table-column prop="memberCount" label="成员数" width="90" />
+            <el-table-column prop="totalEarned" label="累计获得" width="100" />
+            <el-table-column prop="available" label="家庭CF值(可用)" width="160">
+              <template slot-scope="{ row }"><span class="num-strong">{{ row.available }}</span></template>
+            </el-table-column>
+            <el-table-column prop="frozen" label="冻结" width="90" />
+            <el-table-column prop="withdrawn" label="已提现" width="90" />
+            <el-table-column prop="exchanged" label="已兑换消费" width="110" />
+            <el-table-column label="更新时间" width="160">
+              <template slot-scope="{ row }">{{ fmtDate(row.updatedAt) }}</template>
+            </el-table-column>
+            <el-table-column label="操作" width="90" fixed="right">
+              <template slot-scope="{ row }">
+                <el-button type="text" size="small" @click="viewFamilyLogs(row)">明细</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
         </div>
-        <el-pagination v-if="logTotal > 0" :current-page="logPage" :page-size="logSize" :total="logTotal" layout="prev, pager, next" @current-change="pageLogs" />
+        <el-pagination
+          v-if="familyTotal > 0"
+          class="pagination-mt"
+          :current-page="familyPage"
+          :page-size="familySize"
+          :total="familyTotal"
+          layout="total, prev, pager, next"
+          @current-change="pageFamilies"
+        />
+      </el-tab-pane>
+
+      <!-- 流水明细 -->
+      <el-tab-pane label="流水明细" name="logs">
+        <div class="filters">
+          <el-input
+            v-model="logFilter.familyId"
+            placeholder="家庭ID"
+            class="filter-input-120"
+            clearable
+            @keyup.enter.native="searchLogs"
+          />
+          <el-input
+            v-model="logFilter.memberId"
+            placeholder="成员ID"
+            class="filter-input-120"
+            clearable
+            @keyup.enter.native="searchLogs"
+          />
+          <el-button type="primary" @click="searchLogs">查询</el-button>
+          <el-button @click="resetLogs">重置</el-button>
+          <span v-if="logFilter.familyId && currentFamilyName" class="tip-text">
+            当前家庭:{{ currentFamilyName }}
+          </span>
+        </div>
+        <div class="adm-table-wrap">
+          <el-table :data="logList" v-loading="loadingLog" border stripe height="100%">
+            <el-table-column label="成员" min-width="120" show-overflow-tooltip>
+              <template slot-scope="{ row }">{{ row.memberName || ('成员' + row.memberId) }}</template>
+            </el-table-column>
+            <el-table-column prop="familyId" label="家庭ID" width="90" />
+            <el-table-column label="类型" width="110">
+              <template slot-scope="{ row }">
+                <StatusTag :type="typeTag(row.type)" size="small" :text="typeLabel(row.type)" />
+              </template>
+            </el-table-column>
+            <el-table-column label="数量" width="90">
+              <template slot-scope="{ row }">
+                <span :class="row.amount >= 0 ? 'num-plus' : 'num-minus'">{{ row.amount > 0 ? '+' : '' }}{{ row.amount }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column prop="balanceAfter" label="变动后余额" width="110" />
+            <el-table-column prop="refType" label="来源" width="140" show-overflow-tooltip />
+            <el-table-column prop="remark" label="备注" min-width="180" show-overflow-tooltip />
+            <el-table-column label="时间" width="160">
+              <template slot-scope="{ row }">{{ fmtDate(row.createdAt) }}</template>
+            </el-table-column>
+          </el-table>
+        </div>
+        <el-pagination
+          v-if="logTotal > 0"
+          class="pagination-mt"
+          :current-page="logPage"
+          :page-size="logSize"
+          :total="logTotal"
+          layout="total, prev, pager, next"
+          @current-change="pageLogs"
+        />
       </el-tab-pane>
     </el-tabs>
   </div>
 </template>
 
 <script>
-import SortMixin from '@/mixins/SortMixin'
 import ListStateMixin from '@/mixins/ListStateMixin'
-import { getCfValueBalance, getCfValueLogs, getCfValueAllBalances, searchUsers } from '@/api/admin'
+import { getCfMemberBalances, getCfFamilySummary, getCfAdminLogs } from '@/api/admin'
 
 export default {
   name: 'CfValueManage',
-  mixins: [SortMixin, ListStateMixin],
+  mixins: [ListStateMixin],
   data() {
     return {
-      activeTab: 'balances',
-      searchUserId: '',
-      logUserId: '',
-      sortableColumns: { id: 'ID', createdAt: '时间', familyId: '家庭ID', totalEarned: '累计获得', available: '可用', frozen: '冻结', withdrawn: '已提现', exchanged: '已兑换', amount: '数量', balanceAfter: '变动后余额', refType: '来源', refId: '关联ID', remark: '备注' },
-      // Balances
-      balanceList: [],
-      loadingBalance: false,
-      balancePage: 1,
-      balanceSize: 20,
-      balanceTotal: 0,
-      // Logs
+      activeTab: 'members',
+      // 个人余额
+      memberFilter: { keyword: '', familyId: '' },
+      memberList: [],
+      loadingMember: false,
+      memberPage: 1,
+      memberSize: 20,
+      memberTotal: 0,
+      // 家庭合计
+      familyFilter: { keyword: '' },
+      familyList: [],
+      loadingFamily: false,
+      familyPage: 1,
+      familySize: 20,
+      familyTotal: 0,
+      // 流水
+      logFilter: { familyId: '', memberId: '' },
       logList: [],
       loadingLog: false,
       logPage: 1,
       logSize: 20,
-      logTotal: 0
+      logTotal: 0,
+      currentFamilyName: ''
     }
   },
   mounted() {
-    this.loadBalances()
+    this.loadMembers()
   },
   methods: {
-    resolveUserNames(items, idField) {
-      if (!items || items.length === 0) return Promise.resolve()
-      var ids = []
-      items.forEach(function(item) {
-        if (item[idField] && ids.indexOf(item[idField]) === -1) ids.push(item[idField])
-      })
-      var nameMap = {}
-      var self = this
-      return Promise.all(ids.map(function(id) {
-        return searchUsers({ keyword: String(id) })
-          .then(function(res) {
-            if (res.data && res.data.length > 0) {
-              var u = res.data[0]
-              nameMap[id] = u.nickname || u.realName || '用户' + id
-            } else {
-              nameMap[id] = '用户' + id
-            }
-          })
-          .catch(function() {
-            nameMap[id] = '用户' + id
-          })
-      })).then(function() {
-        items.forEach(function(item) {
-          item.userName = nameMap[item[idField]] || '用户' + item[idField]
-        })
-      })
+    // ListStateMixin 约定的刷新入口
+    loadList() {
+      this.handleTabChange()
+    },
+    handleTabChange() {
+      if (this.activeTab === 'families') {
+        this.loadFamilies()
+      } else if (this.activeTab === 'logs') {
+        this.loadLogs()
+      } else {
+        this.loadMembers()
+      }
+    },
+    fmtDate(v) {
+      if (!v) return '-'
+      const d = new Date(v)
+      if (isNaN(d.getTime())) return String(v)
+      const p = n => (n < 10 ? '0' + n : '' + n)
+      return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds())
+    },
+    typeLabel(type) {
+      const map = {
+        earn: '获取',
+        spend: '消费',
+        freeze: '冻结',
+        unfreeze: '解冻',
+        withdraw: '提现',
+        adjust: '管理员调整',
+        skip: '未发放'
+      }
+      return map[type] || type
     },
     typeTag(type) {
-      const map = { earn: 'success', spend: 'warning', freeze: 'info', unfreeze: 'info', withdraw: 'primary' }
+      const map = { earn: 'success', spend: 'warning', freeze: 'info', unfreeze: 'info', withdraw: 'primary', adjust: 'danger', skip: 'info' }
       return map[type] || 'info'
     },
-    loadList() { this.loadBalances() },
-    loadData() { this.searchLogs() },
-    loadBalances() {
-      this.loadingBalance = true
-      const params = { page: this.balancePage, size: this.balanceSize }
-      if (this.sortState.length > 0) params.sort = this.sortState
-      getCfValueAllBalances(params).then(async res => {
+    // ---- 个人余额 ----
+    loadMembers() {
+      this.loadingMember = true
+      const params = {
+        page: this.memberPage,
+        size: this.memberSize,
+        keyword: this.memberFilter.keyword || undefined,
+        familyId: this.memberFilter.familyId || undefined
+      }
+      getCfMemberBalances(params).then(res => {
         if (res.code === 200) {
-          this.balanceList = res.data.records || []
-          this.balanceTotal = res.data.total || 0
-          await this.resolveUserNames(this.balanceList, 'userId')
+          this.memberList = (res.data && res.data.records) || []
+          this.memberTotal = (res.data && res.data.total) || 0
         }
-      }).finally(() => { this.loadingBalance = false })
+      }).catch(e => this.$message.error(e.message || '加载个人CF失败'))
+        .finally(() => { this.loadingMember = false })
+    },
+    pageMembers(page) { this.memberPage = page; this.loadMembers() },
+    searchMembers() { this.memberPage = 1; this.loadMembers() },
+    resetMembers() {
+      this.memberFilter = { keyword: '', familyId: '' }
+      this.memberPage = 1
+      this.loadMembers()
     },
-    pageBalances(page) {
-      this.balancePage = page
-      this.loadBalances()
+    viewMemberLogs(row) {
+      this.logFilter = { familyId: '', memberId: String(row.memberId || '') }
+      this.currentFamilyName = ''
+      this.logPage = 1
+      this.activeTab = 'logs'
+      this.loadLogs()
+    },
+    // ---- 家庭合计 ----
+    loadFamilies() {
+      this.loadingFamily = true
+      const params = {
+        page: this.familyPage,
+        size: this.familySize,
+        keyword: this.familyFilter.keyword || undefined
+      }
+      getCfFamilySummary(params).then(res => {
+        if (res.code === 200) {
+          this.familyList = (res.data && res.data.records) || []
+          this.familyTotal = (res.data && res.data.total) || 0
+        }
+      }).catch(e => this.$message.error(e.message || '加载家庭CF失败'))
+        .finally(() => { this.loadingFamily = false })
     },
-    searchBalance() {
-      if (!this.searchUserId) { this.loadBalances(); return }
-      this.loadingBalance = true
-getCfValueBalance({ userId: this.searchUserId }).then(async res => {
-          if (res.code === 200) {
-            this.balanceList = [res.data]
-            this.balanceTotal = 1
-            await this.resolveUserNames(this.balanceList, 'userId')
-          }
-        }).finally(() => { this.loadingBalance = false })
+    pageFamilies(page) { this.familyPage = page; this.loadFamilies() },
+    searchFamilies() { this.familyPage = 1; this.loadFamilies() },
+    resetFamilies() {
+      this.familyFilter = { keyword: '' }
+      this.familyPage = 1
+      this.loadFamilies()
     },
-    viewLogs(userId) {
-      this.logUserId = String(userId)
+    viewFamilyLogs(row) {
+      this.logFilter = { familyId: String(row.familyId || ''), memberId: '' }
+      this.currentFamilyName = row.familyName || ('家庭' + row.familyId)
+      this.logPage = 1
       this.activeTab = 'logs'
-      this.searchLogs()
+      this.loadLogs()
     },
-    searchLogs() {
-      if (!this.logUserId) return
+    // ---- 流水 ----
+    loadLogs() {
       this.loadingLog = true
-      this.logPage = 1
-      const params = { userId: this.logUserId, page: 1, size: this.logSize }
-      if (this.sortState.length > 0) params.sort = this.sortState
-      getCfValueLogs(params).then(async res => {
-          if (res.code === 200) {
-            this.logList = res.data.records || []
-            this.logTotal = res.data.total || 0
-            await this.resolveUserNames(this.logList, 'userId')
-          }
-        }).finally(() => { this.loadingLog = false })
+      const params = {
+        page: this.logPage,
+        size: this.logSize,
+        familyId: this.logFilter.familyId || undefined,
+        memberId: this.logFilter.memberId || undefined
+      }
+      getCfAdminLogs(params).then(res => {
+        if (res.code === 200) {
+          this.logList = (res.data && res.data.records) || []
+          this.logTotal = (res.data && res.data.total) || 0
+        }
+      }).catch(e => this.$message.error(e.message || '加载CF流水失败'))
+        .finally(() => { this.loadingLog = false })
     },
-    pageLogs(page) {
-      this.logPage = page
-      this.searchLogs()
+    pageLogs(page) { this.logPage = page; this.loadLogs() },
+    searchLogs() { this.logPage = 1; this.loadLogs() },
+    resetLogs() {
+      this.logFilter = { familyId: '', memberId: '' }
+      this.currentFamilyName = ''
+      this.logPage = 1
+      this.loadLogs()
     }
   }
 }
@@ -238,7 +335,12 @@ getCfValueBalance({ userId: this.searchUserId }).then(async res => {
 
 <style scoped>
 .cf-value { padding: 24px; }
-
-/* == C 批内联清理工具类 == */
+.filters { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
 .filter-input-200 { width: 200px; }
-</style>
+.filter-input-120 { width: 120px; }
+.pagination-mt { margin-top: 12px; text-align: right; }
+.num-strong { font-weight: 600; color: #303133; }
+.num-plus { color: #67c23a; font-weight: 600; }
+.num-minus { color: #f56c6c; font-weight: 600; }
+.tip-text { font-size: 12px; color: #909399; }
+</style>