Parcourir la source

feat(butler): S-cfc-355 butler.quality.qa 服务质检与满意度契约实现

能力键 butler.quality.qa · SC-H-07 服务质检与满意度(质检→满意度回访→回流改进)。
使 ButlerQualityQaContractTest 12 例全部转绿。

- 新增 ButlerQualityInspection/ButlerSatisfaction/ButlerPerformance 实体与对应 Mapper
- 新增 ButlerQualityService(inspect 质检入口 + triggerRetrospect 差评复盘入口)、
  ButlerSatisfactionService(submitSatisfaction 评分提交入口,幂等去重)、
  ButlerPerformanceService(绩效看板入口)
- schema.sql 同步 butler_quality_inspections/butler_satisfaction/butler_performance 三张表
- DatabaseInitializer 迁移474 幂等建表(与 schema.sql 保持一致)
Sisyphus Agent il y a 2 jours
Parent
commit
20c83f58f8

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

@@ -3538,6 +3538,10 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
 
         // 迁移473(FamilyWorkbench 2026-11-13): tasks 加 (family_id, created_at) 索引(工作台按家庭聚合与逐日趋势分桶)
         addTasksFamilyCreatedIndex();
+
+        // 迁移474: 创建管家服务质检/满意度/绩效三张表
+        //(butler.quality.qa · SC-H-07 服务质检与满意度:质检→满意度回访→回流改进;差评触发复盘;隐私脱敏)
+        createButlerQualityQaTables();
     }
 
     /** 迁移473(FamilyWorkbench): tasks 加家庭+时间复合索引,支撑工作台按家庭聚合计数与近 30 天逐日趋势。 */
@@ -3550,6 +3554,72 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
         }
     }
 
+    /**
+     * 迁移474: 创建管家服务质检/满意度/绩效承载表(butler.quality.qa · SC-H-07 服务质检与满意度)。
+     *
+     * <p>三张表构成「质检→满意度回访→回流改进」闭环:
+     * butler_quality_inspections(抽样/全量质检,逐项通过/不通过+依据+脱敏摘要,不展示隐私对话原文)、
+     * butler_satisfaction(家长满意度评分,差评触发复盘标记,uk_butler_user 幂等去重)、
+     * butler_performance(质检结果回流的绩效看板,uk_butler_period 唯一)。
+     * 幂等(CREATE TABLE IF NOT EXISTS)。</p>
+     */
+    private void createButlerQualityQaTables() {
+        // 迁移474: butler_quality_inspections(服务质检记录)
+        try {
+            jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS butler_quality_inspections ("
+                    + "id BIGINT AUTO_INCREMENT PRIMARY KEY, "
+                    + "butler_id BIGINT NOT NULL COMMENT '被质检管家 userId', "
+                    + "inspection_type VARCHAR(20) DEFAULT 'sampling' COMMENT '质检方式: sampling=抽样/full=全量', "
+                    + "inspection_items TEXT COMMENT '逐项质检结果JSON[{item:SLA/合规/态度,basis:依据,result:PASS/FAIL}](逐项通过/不通过+依据)', "
+                    + "desensitized_summary TEXT COMMENT '脱敏摘要(质检报告不展示家长隐私对话原文)', "
+                    + "overall_result VARCHAR(10) DEFAULT 'PASS' COMMENT '总体结论 PASS/FAIL', "
+                    + "inspected_by BIGINT COMMENT '质检操作人 userId', "
+                    + "created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', "
+                    + "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', "
+                    + "INDEX idx_butler_id (butler_id) "
+                    + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家服务质检记录'");
+            log.info("迁移474: 已创建 butler_quality_inspections 表");
+        } catch (Exception e) {
+            log.warn("迁移474: 创建 butler_quality_inspections 表失败(可能已存在): {}", e.getMessage());
+        }
+        // 迁移474: butler_satisfaction(满意度评分)
+        try {
+            jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS butler_satisfaction ("
+                    + "id BIGINT AUTO_INCREMENT PRIMARY KEY, "
+                    + "butler_id BIGINT NOT NULL COMMENT '被评价管家 userId', "
+                    + "user_id BIGINT NOT NULL COMMENT '提交评分的家长 userId', "
+                    + "rating INT NOT NULL COMMENT '满意度评分(1-5)', "
+                    + "comment VARCHAR(1000) COMMENT '回访意见', "
+                    + "bad_review_triggered TINYINT(1) DEFAULT 0 COMMENT '差评触发复盘标记(幂等: 0=未触发 1=已触发)', "
+                    + "created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', "
+                    + "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', "
+                    + "UNIQUE KEY uk_butler_user (butler_id, user_id), "
+                    + "INDEX idx_user_id (user_id) "
+                    + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家服务满意度评分'");
+            log.info("迁移474: 已创建 butler_satisfaction 表");
+        } catch (Exception e) {
+            log.warn("迁移474: 创建 butler_satisfaction 表失败(可能已存在): {}", e.getMessage());
+        }
+        // 迁移474: butler_performance(绩效看板)
+        try {
+            jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS butler_performance ("
+                    + "id BIGINT AUTO_INCREMENT PRIMARY KEY, "
+                    + "butler_id BIGINT NOT NULL COMMENT '管家 userId', "
+                    + "period VARCHAR(7) NOT NULL COMMENT '统计月份 yyyy-MM', "
+                    + "inspection_pass_rate DECIMAL(5,2) DEFAULT 0 COMMENT '质检通过率(%)', "
+                    + "satisfaction_avg DECIMAL(3,2) DEFAULT 0 COMMENT '满意度均分(1-5)', "
+                    + "weak_items TEXT COMMENT '薄弱环节JSON(回流改进)', "
+                    + "created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', "
+                    + "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', "
+                    + "UNIQUE KEY uk_butler_period (butler_id, period), "
+                    + "INDEX idx_period (period) "
+                    + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家绩效看板'");
+            log.info("迁移474: 已创建 butler_performance 表");
+        } catch (Exception e) {
+            log.warn("迁移474: 创建 butler_performance 表失败(可能已存在): {}", e.getMessage());
+        }
+    }
+
     /**
      * 迁移464: 创建 P3 跨案例聚合承载表(T15 跨案例聚合,S-cfc-119 guhe.p3.lowSideAggregate)。
      *

+ 43 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/ButlerPerformance.java

@@ -0,0 +1,43 @@
+package com.etotem.cfc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 管家绩效看板数据(能力键 {@code butler.quality.qa} · SC-H-07 服务质检与满意度)。
+ *
+ * <p>承载质检结果回流至管家绩效看板的聚合数据(质检通过率 / 满意度均分 / 薄弱环节),
+ * 仅授权角色可见(权限校验在 Controller 层按角色手动执行)。</p>
+ */
+@Data
+@TableName("butler_performance")
+public class ButlerPerformance implements Serializable {
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /** 管家 userId */
+    private Long butlerId;
+
+    /** 统计月份 yyyy-MM */
+    private String period;
+
+    /** 质检通过率(%) */
+    private BigDecimal inspectionPassRate;
+
+    /** 满意度均分(1-5) */
+    private BigDecimal satisfactionAvg;
+
+    /** 薄弱环节 JSON(回流改进) */
+    private String weakItems;
+
+    private Date createdAt;
+
+    private Date updatedAt;
+}

+ 46 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/ButlerQualityInspection.java

@@ -0,0 +1,46 @@
+package com.etotem.cfc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 管家服务质检记录(能力键 {@code butler.quality.qa} · SC-H-07 服务质检与满意度)。
+ *
+ * <p>承载抽样/全量质检真人管家会话与工单(SLA、合规、态度),逐项给出通过/不通过与依据
+ * ({@code inspectionItems});质检报告不展示家长隐私对话原文,仅展示脱敏摘要与判定依据
+ * ({@code desensitizedSummary},边界约束)。</p>
+ */
+@Data
+@TableName("butler_quality_inspections")
+public class ButlerQualityInspection implements Serializable {
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /** 被质检管家 userId */
+    private Long butlerId;
+
+    /** 质检方式: sampling=抽样 / full=全量 */
+    private String inspectionType;
+
+    /** 逐项质检结果 JSON(SC-H-07:SLA/合规/态度逐项通过/不通过+依据,如 [{item:SLA,basis:依据,result:PASS}]) */
+    private String inspectionItems;
+
+    /** 脱敏摘要(边界:不展示家长隐私对话原文,仅展示脱敏摘要与判定依据) */
+    private String desensitizedSummary;
+
+    /** 总体结论: PASS / FAIL */
+    private String overallResult;
+
+    /** 质检操作人 userId */
+    private Long inspectedBy;
+
+    private Date createdAt;
+
+    private Date updatedAt;
+}

+ 43 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/ButlerSatisfaction.java

@@ -0,0 +1,43 @@
+package com.etotem.cfc.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 管家服务满意度评分(能力键 {@code butler.quality.qa} · SC-H-07 服务质检与满意度)。
+ *
+ * <p>承载家长对真人管家服务的满意度评分({@code rating});低分差评自动触发复盘标记
+ * ({@code badReviewTriggered},幂等:同一差评只触发一次)。同一家长重复提交评分以
+ * 最后一次为准(不重复计数)。</p>
+ */
+@Data
+@TableName("butler_satisfaction")
+public class ButlerSatisfaction implements Serializable {
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /** 被评价管家 userId */
+    private Long butlerId;
+
+    /** 提交评分的家长 userId */
+    private Long userId;
+
+    /** 满意度评分(1-5) */
+    private Integer rating;
+
+    /** 回访意见 */
+    private String comment;
+
+    /** 差评是否已触发复盘(幂等:0=未触发 1=已触发,关联 SC-H-04 升级应急流程) */
+    private Integer badReviewTriggered;
+
+    private Date createdAt;
+
+    private Date updatedAt;
+}

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/ButlerPerformanceMapper.java

@@ -0,0 +1,9 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.ButlerPerformance;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ButlerPerformanceMapper extends BaseMapper<ButlerPerformance> {
+}

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/ButlerQualityInspectionMapper.java

@@ -0,0 +1,9 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.ButlerQualityInspection;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ButlerQualityInspectionMapper extends BaseMapper<ButlerQualityInspection> {
+}

+ 9 - 0
cfc-backend/src/main/java/com/etotem/cfc/mapper/ButlerSatisfactionMapper.java

@@ -0,0 +1,9 @@
+package com.etotem.cfc.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.etotem.cfc.entity.ButlerSatisfaction;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ButlerSatisfactionMapper extends BaseMapper<ButlerSatisfaction> {
+}

+ 35 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/ButlerPerformanceService.java

@@ -0,0 +1,35 @@
+package com.etotem.cfc.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.etotem.cfc.entity.ButlerPerformance;
+import com.etotem.cfc.mapper.ButlerPerformanceMapper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 真人管家绩效看板(能力键 {@code butler.quality.qa} · SC-H-07 服务质检与满意度)。
+ *
+ * <p>质检结果回流至真人管家绩效看板,仅授权角色可见(权限校验在 Controller 层按角色
+ * 手动执行,本服务只做数据查询)。</p>
+ */
+@Service
+public class ButlerPerformanceService {
+
+    @Resource
+    private ButlerPerformanceMapper butlerPerformanceMapper;
+
+    /**
+     * 绩效看板入口:按管家 + 可选月份查询质检/满意度回流聚合结果。
+     *
+     * @param butlerId 管家 userId
+     * @param period   统计月份 yyyy-MM(可空,空则返回该管家全部分期)
+     */
+    public List<ButlerPerformance> listButlerPerformance(Long butlerId, String period) {
+        return butlerPerformanceMapper.selectList(new LambdaQueryWrapper<ButlerPerformance>()
+                .eq(ButlerPerformance::getButlerId, butlerId)
+                .eq(period != null && !period.isEmpty(), ButlerPerformance::getPeriod, period)
+                .orderByDesc(ButlerPerformance::getPeriod));
+    }
+}

+ 89 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/ButlerQualityService.java

@@ -0,0 +1,89 @@
+package com.etotem.cfc.service;
+
+import com.etotem.cfc.entity.ButlerQualityInspection;
+import com.etotem.cfc.entity.ButlerSatisfaction;
+import com.etotem.cfc.mapper.ButlerQualityInspectionMapper;
+import com.etotem.cfc.mapper.ButlerSatisfactionMapper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+/**
+ * 真人管家服务质检(能力键 {@code butler.quality.qa} · SC-H-07 服务质检与满意度)。
+ *
+ * <p>质检→满意度回访→回流改进:抽样/全量质检真人管家会话与工单(SLA、合规、态度),
+ * 逐项给出通过/不通过与依据;质检报告不展示家长隐私对话原文,仅展示脱敏摘要与判定依据
+ * (脱敏边界)。低分差评自动触发复盘并关联 SC-H-04 升级应急流程(幂等)。</p>
+ */
+@Service
+public class ButlerQualityService {
+
+    /** 差评阈值(满意度评分 <= 该值视为差评,自动触发复盘) */
+    private static final int LOW_RATING = 2;
+
+    @Resource
+    private ButlerQualityInspectionMapper butlerQualityInspectionMapper;
+
+    @Resource
+    private ButlerSatisfactionMapper butlerSatisfactionMapper;
+
+    /**
+     * 质检执行入口:保存抽样/全量质检记录(逐项通过/不通过与依据 + 脱敏摘要,不展示隐私对话原文)。
+     */
+    public ButlerQualityInspection inspect(ButlerQualityInspection inspection) {
+        Date now = new Date();
+        inspection.setCreatedAt(now);
+        inspection.setUpdatedAt(now);
+        butlerQualityInspectionMapper.insert(inspection);
+        return inspection;
+    }
+
+    /**
+     * 质检执行入口(便捷重载):按明细构建质检记录并落库。
+     *
+     * @param butlerId            被质检管家 userId
+     * @param inspectionType      质检方式: sampling=抽样 / full=全量
+     * @param inspectionItems     逐项质检结果 JSON(SLA/合规/态度,逐项通过/不通过与依据)
+     * @param desensitizedSummary 脱敏摘要(不展示家长隐私对话原文)
+     * @param overallResult       总体结论 PASS / FAIL
+     */
+    public ButlerQualityInspection inspect(Long butlerId, String inspectionType, String inspectionItems,
+                                           String desensitizedSummary, String overallResult) {
+        ButlerQualityInspection inspection = new ButlerQualityInspection();
+        inspection.setButlerId(butlerId);
+        inspection.setInspectionType(inspectionType);
+        inspection.setInspectionItems(inspectionItems);
+        inspection.setDesensitizedSummary(desensitizedSummary);
+        inspection.setOverallResult(overallResult);
+        return inspect(inspection);
+    }
+
+    /**
+     * 差评触发复盘入口(SC-H-07 异常流):差评自动触发复盘并关联 SC-H-04 升级应急流程。
+     * 幂等:同一差评只触发一次(已触发或非差评直接返回,不重复)。
+     *
+     * @param satisfactionId 满意度记录ID
+     * @return 是否本次新触发复盘
+     */
+    public boolean triggerRetrospect(Long satisfactionId) {
+        if (satisfactionId == null) {
+            return false;
+        }
+        ButlerSatisfaction satisfaction = butlerSatisfactionMapper.selectById(satisfactionId);
+        if (satisfaction == null) {
+            return false;
+        }
+        Integer rating = satisfaction.getRating();
+        if (rating == null || rating > LOW_RATING) {
+            return false;
+        }
+        if (satisfaction.getBadReviewTriggered() != null && satisfaction.getBadReviewTriggered() == 1) {
+            return false;
+        }
+        satisfaction.setBadReviewTriggered(1);
+        satisfaction.setUpdatedAt(new Date());
+        butlerSatisfactionMapper.updateById(satisfaction);
+        return true;
+    }
+}

+ 80 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/ButlerSatisfactionService.java

@@ -0,0 +1,80 @@
+package com.etotem.cfc.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.etotem.cfc.entity.ButlerSatisfaction;
+import com.etotem.cfc.mapper.ButlerSatisfactionMapper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+/**
+ * 真人管家服务满意度(能力键 {@code butler.quality.qa} · SC-H-07 服务质检与满意度)。
+ *
+ * <p>向家长发起满意度回访(问卷/评分),家长提交评分并成功;同一家长重复提交评分以
+ * 最后一次为准(幂等,不重复计数);低分差评自动标记触发复盘。</p>
+ */
+@Service
+public class ButlerSatisfactionService {
+
+    /** 差评阈值(满意度评分 <= 该值自动触发复盘) */
+    private static final int LOW_RATING = 2;
+
+    @Resource
+    private ButlerSatisfactionMapper butlerSatisfactionMapper;
+
+    /**
+     * 满意度评分提交入口(SC-H-07):同一家长对同一管家重复提交以最后一次为准(幂等)。
+     *
+     * @param butlerId 被评价管家 userId
+     * @param userId   提交评分的家长 userId
+     * @param rating   满意度评分(1-5)
+     * @param comment  回访意见(可空)
+     * @return 落库后的满意度记录(重复提交返回更新后的记录)
+     */
+    public ButlerSatisfaction submitSatisfaction(Long butlerId, Long userId, Integer rating, String comment) {
+        Date now = new Date();
+        ButlerSatisfaction existing = butlerSatisfactionMapper.selectOne(
+                new LambdaQueryWrapper<ButlerSatisfaction>()
+                        .eq(ButlerSatisfaction::getButlerId, butlerId)
+                        .eq(ButlerSatisfaction::getUserId, userId));
+        if (existing != null) {
+            existing.setRating(rating);
+            existing.setComment(comment);
+            if (isBadReview(rating) && !isTriggered(existing.getBadReviewTriggered())) {
+                existing.setBadReviewTriggered(1);
+            }
+            existing.setUpdatedAt(now);
+            butlerSatisfactionMapper.updateById(existing);
+            return existing;
+        }
+        ButlerSatisfaction satisfaction = new ButlerSatisfaction();
+        satisfaction.setButlerId(butlerId);
+        satisfaction.setUserId(userId);
+        satisfaction.setRating(rating);
+        satisfaction.setComment(comment);
+        satisfaction.setBadReviewTriggered(isBadReview(rating) ? 1 : 0);
+        satisfaction.setCreatedAt(now);
+        satisfaction.setUpdatedAt(now);
+        butlerSatisfactionMapper.insert(satisfaction);
+        return satisfaction;
+    }
+
+    /**
+     * 查询家长对指定管家的满意度记录(回访时校验是否已提交)。
+     */
+    public ButlerSatisfaction getSatisfaction(Long butlerId, Long userId) {
+        return butlerSatisfactionMapper.selectOne(
+                new LambdaQueryWrapper<ButlerSatisfaction>()
+                        .eq(ButlerSatisfaction::getButlerId, butlerId)
+                        .eq(ButlerSatisfaction::getUserId, userId));
+    }
+
+    private boolean isBadReview(Integer rating) {
+        return rating != null && rating <= LOW_RATING;
+    }
+
+    private boolean isTriggered(Integer badReviewTriggered) {
+        return badReviewTriggered != null && badReviewTriggered == 1;
+    }
+}

+ 42 - 0
cfc-backend/src/main/resources/schema.sql

@@ -2990,6 +2990,48 @@ CREATE TABLE IF NOT EXISTS butler_assignments (
     INDEX idx_subscription_id (subscription_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员 - 管家分配记录';
 
+-- 管家服务质检记录(SC-H-07 服务质检与满意度 · butler.quality.qa)
+CREATE TABLE IF NOT EXISTS butler_quality_inspections (
+    id BIGINT AUTO_INCREMENT PRIMARY KEY,
+    butler_id BIGINT NOT NULL COMMENT '被质检管家 userId',
+    inspection_type VARCHAR(20) DEFAULT 'sampling' COMMENT '质检方式: sampling=抽样/full=全量',
+    inspection_items TEXT COMMENT '逐项质检结果JSON[{item:SLA/合规/态度,basis:依据,result:PASS/FAIL}](逐项通过/不通过+依据)',
+    desensitized_summary TEXT COMMENT '脱敏摘要(质检报告不展示家长隐私对话原文)',
+    overall_result VARCHAR(10) DEFAULT 'PASS' COMMENT '总体结论 PASS/FAIL',
+    inspected_by BIGINT COMMENT '质检操作人 userId',
+    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+    INDEX idx_butler_id (butler_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家服务质检记录';
+
+-- 管家服务满意度评分(SC-H-07 服务质检与满意度 · butler.quality.qa)
+CREATE TABLE IF NOT EXISTS butler_satisfaction (
+    id BIGINT AUTO_INCREMENT PRIMARY KEY,
+    butler_id BIGINT NOT NULL COMMENT '被评价管家 userId',
+    user_id BIGINT NOT NULL COMMENT '提交评分的家长 userId',
+    rating INT NOT NULL COMMENT '满意度评分(1-5)',
+    comment VARCHAR(1000) COMMENT '回访意见',
+    bad_review_triggered TINYINT(1) DEFAULT 0 COMMENT '差评触发复盘标记(幂等: 0=未触发 1=已触发)',
+    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+    UNIQUE KEY uk_butler_user (butler_id, user_id),
+    INDEX idx_user_id (user_id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家服务满意度评分';
+
+-- 管家绩效看板(SC-H-07 质检结果回流 · butler.quality.qa;仅授权角色可见)
+CREATE TABLE IF NOT EXISTS butler_performance (
+    id BIGINT AUTO_INCREMENT PRIMARY KEY,
+    butler_id BIGINT NOT NULL COMMENT '管家 userId',
+    period VARCHAR(7) NOT NULL COMMENT '统计月份 yyyy-MM',
+    inspection_pass_rate DECIMAL(5,2) DEFAULT 0 COMMENT '质检通过率(%)',
+    satisfaction_avg DECIMAL(3,2) DEFAULT 0 COMMENT '满意度均分(1-5)',
+    weak_items TEXT COMMENT '薄弱环节JSON(回流改进)',
+    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+    UNIQUE KEY uk_butler_period (butler_id, period),
+    INDEX idx_period (period)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管家绩效看板';
+
 -- 家庭订阅记录
 CREATE TABLE IF NOT EXISTS member_subscription (
     id BIGINT AUTO_INCREMENT PRIMARY KEY,