Browse Source

Merge remote-tracking branch 'origin/cfclub' into cfclub

E2E Test Bot 3 hours ago
parent
commit
05d21920ba

+ 1 - 0
cfc-backend/src/main/java/com/etotem/cfc/config/JwtInterceptor.java

@@ -58,6 +58,7 @@ private static final String[] PUBLIC_PATHS = {
          "/api/auth/internal/",
          "/api/product/list",
          "/api/product/detail",
+         "/api/product/review/list",          // R3 shop.review.list:商品详情页评价列表,公开只读匿名可看
          "/api/special-price/info",
          "/api/product/type-list",
          "/api/product/related-products",

+ 28 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/product/ProductReviewController.java

@@ -53,4 +53,32 @@ public class ProductReviewController {
         int size = params.get("size") instanceof Number ? ((Number) params.get("size")).intValue() : 10;
         return Result.success(reviewService.my(userId, page, size));
     }
+
+    /**
+     * R3 商品详情页评价列表(能力键 {@code shop.review.list},公开只读,匿名可看)。
+     *
+     * <p>设计 §3.1 R3:入参 {@code {productId, page, size}}(分页默认 page=1 / size=20,§9),
+     * 出参 {@code Result<Map>}:{@code {total, avgRating, records[]}}。
+     * 本接口不携带 {@code @RequestAttribute("userId")},路径已登记 {@code JwtInterceptor.PUBLIC_PATHS}。</p>
+     */
+    @PostMapping("/list")
+    public Result<Map<String, Object>> list(@RequestBody Map<String, Object> params) {
+        Long productId = params != null && params.get("productId") != null
+                ? Long.valueOf(params.get("productId").toString()) : null;
+        int page = params != null && params.get("page") instanceof Number
+                ? ((Number) params.get("page")).intValue() : 1;
+        int size = params != null && params.get("size") instanceof Number
+                ? ((Number) params.get("size")).intValue() : 20;
+        return Result.success(reviewService.listByProduct(productId, page, size));
+    }
+
+    @PostMapping("/reply")
+    public Result<String> reply(@RequestBody Map<String, Object> params,
+                                @RequestAttribute("userId") Long userId) {
+        Long reviewId = params != null && params.get("reviewId") != null
+                ? Long.valueOf(params.get("reviewId").toString()) : null;
+        String replyText = params != null && params.get("replyText") != null
+                ? params.get("replyText").toString() : null;
+        return Result.success(reviewService.reply(reviewId, replyText, userId));
+    }
 }

+ 29 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/ProductReviewService.java

@@ -48,4 +48,33 @@ public interface ProductReviewService {
      * @return Map:{reviews[], reviewableOrders[], reviewableCount}
      */
     Map<String, Object> my(Long userId, int page, int size);
+
+    /**
+     * 商品详情页评价列表(R3,能力键 {@code shop.review.list},公开只读)。
+     *
+     * <p>设计 §3.1 R3:出参 {@code {total, avgRating, records[]}}——
+     * {@code total} / {@code avgRating} 来自 {@link com.etotem.cfc.mapper.ProductReviewMapper#statsByProduct(Long)}
+     * 聚合,{@code records} 来自 {@link com.etotem.cfc.mapper.ProductReviewMapper#listByProduct(Long, int, int)}
+     * 分页(仅展示态 status=1,按 review_at DESC 倒序)。与 {@code my} 不同,本方法不依赖登录态。</p>
+     *
+     * @param productId 商品主键
+     * @param page      页码(从 1 开始)
+     * @param size      每页条数
+     * @return Map:{total, avgRating, records}
+     */
+    Map<String, Object> listByProduct(Long productId, int page, int size);
+
+    /**
+     * 商家回复商品评价(R4,能力键 {@code shop.review.reply})。
+     *
+     * <p>设计 §3.1 R4:鉴权=登录商家本人({@code product.vendorId==operatorId}),入参
+     * {@code {reviewId, replyText(≤500)}};一评一回复覆盖式写回
+     * {@code replyText/repliedAt/replyBy};无重复/多次回复历史。</p>
+     *
+     * @param reviewId   评价主键(必填)
+     * @param replyText  回复文字(≤500 字)
+     * @param operatorId 登录商家 userId(须为评价所属商品的商家)
+     * @return 成功消息;校验不通过抛 {@link RuntimeException}
+     */
+    String reply(Long reviewId, String replyText, Long operatorId);
 }

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

@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.etotem.cfc.dto.ProductReviewRequest;
 import com.etotem.cfc.dto.ProductReviewResponse;
+import com.etotem.cfc.entity.Product;
 import com.etotem.cfc.entity.ProductOrder;
 import com.etotem.cfc.entity.ProductReview;
+import com.etotem.cfc.mapper.ProductMapper;
 import com.etotem.cfc.mapper.ProductOrderMapper;
 import com.etotem.cfc.mapper.ProductReviewMapper;
 import org.springframework.stereotype.Service;
@@ -43,6 +45,9 @@ public class ProductReviewServiceImpl extends ServiceImpl<ProductReviewMapper, P
     @Resource
     private ProductOrderMapper orderMapper;
 
+    @Resource
+    private ProductMapper productMapper;
+
     @Override
     @Transactional
     public String createReview(ProductReviewRequest request, Long reviewerId) {
@@ -198,6 +203,81 @@ public class ProductReviewServiceImpl extends ServiceImpl<ProductReviewMapper, P
         return result;
     }
 
+    @Override
+    @Transactional
+    public String reply(Long reviewId, String replyText, Long operatorId) {
+        // 入参守卫(顺序:先校验,再查库,避免无效请求触达 DB)
+        if (reviewId == null) {
+            throw new RuntimeException("评价ID不能为空");
+        }
+        if (replyText == null || replyText.trim().isEmpty()) {
+            throw new RuntimeException("回复内容不能为空");
+        }
+        if (replyText.length() > 500) {
+            throw new RuntimeException("商家回复不能超过500字");
+        }
+        if (operatorId == null) {
+            throw new RuntimeException("登录商家身份缺失");
+        }
+
+        // 评价存在性:不存在直接拒绝,不写库
+        ProductReview review = reviewMapper.selectById(reviewId);
+        if (review == null) {
+            throw new RuntimeException("评价不存在");
+        }
+
+        // 鉴权:评价对应商品须属于当前登录商家(product.vendorId == operatorId)
+        Long productId = review.getProductId();
+        if (productId == null) {
+            throw new RuntimeException("评价未关联商品,无法回复");
+        }
+        Product product = productMapper.selectById(productId);
+        if (product == null || product.getVendorId() == null
+                || !product.getVendorId().equals(operatorId)) {
+            throw new RuntimeException("无权回复非本人商品的评价");
+        }
+
+        // 一评一回复覆盖式更新(P2 再议多次回复)
+        Date now = new Date();
+        review.setReplyText(replyText);
+        review.setRepliedAt(now);
+        review.setReplyBy(operatorId);
+        review.setUpdatedAt(now);
+        reviewMapper.updateById(review);
+        return "回复成功";
+    }
+
+    /**
+     * 商品详情页评价列表(R3,能力键 {@code shop.review.list},公开只读)。
+     *
+     * <p>读 {@link ProductReviewMapper#statsByProduct} 聚合 total + avgRating,
+     * 读 {@link ProductReviewMapper#listByProduct} 分页 records,组装只读视图
+     * {@code {total, avgRating, records}}。仅展示态 status=1、按 review_at DESC 倒序由 Mapper XML 保证。</p>
+     */
+    @Override
+    public Map<String, Object> listByProduct(Long productId, int page, int size) {
+        int pageNum = Math.max(page, 1);
+        int pageSize = Math.max(size, 1);
+        int offset = (pageNum - 1) * pageSize;
+
+        Map<String, Object> result = new HashMap<>();
+
+        // 1) 星级聚合:total + avgRating(Mapper XML 已限定 status=1 且 AVG(rating))
+        Map<String, Object> stats = reviewMapper.statsByProduct(productId);
+        if (stats != null) {
+            result.put("total", stats.get("total"));
+            result.put("avgRating", stats.get("avgRating"));
+        } else {
+            result.put("total", 0L);
+            result.put("avgRating", null);
+        }
+
+        // 2) 评价记录分页(含商家回复,按 review_at DESC 倒序)
+        List<ProductReview> records = reviewMapper.listByProduct(productId, offset, pageSize);
+        result.put("records", records == null ? Collections.emptyList() : records);
+        return result;
+    }
+
     /**
      * 90 天评价窗口判定:confirmTime 存在且 >= now - 90d。
      */

+ 125 - 0
docs/tdd/orchestration/report-dev-2026-11-28-0410.md

@@ -0,0 +1,125 @@
+# 研发负责人工作汇报
+
+> 轮次:CF 21分错峰档收割(2026-11-28 04:10 触发)|第 R534 轮
+
+## 基本信息
+
+| 项目 | 内容 |
+|------|------|
+| 汇报人 | 研发负责人(无人值守错峰轮,纯调度角色) |
+| 汇报周期 | 2026-11-28 04:10 ~ 04:24(第 21 分错峰档) |
+| 负责模块/单元范围 | 全量(研发负责人纯调度角色,不写业务代码/不改设计/不修缺陷本体) |
+
+> 本档为**错峰档**:跳过 S2 失败补跑(由 01 分标准档承担);S3 走**精简盘点**(跳过 `--changes`/`--clean-check`,由标准轮承接);S5 心跳/S6 填充 config enabled=false 跳过。**派发保底已兑现**:`--auto` 成功 4 / 失败 0(verified)。
+
+---
+
+## 一、本轮工作数据汇总
+
+### 1.0 场景覆盖矩阵(硬职责增列)
+
+> 单一计数源:`docs/tdd/orchestration/sc-key-map.md`(origin/cfclub 正本,严格表格行去重)。「跑通」三判据:① 三类流执行证据;② 实现/用例已 push `origin/cfclub`;③ `--clean-check` 退出码 0。
+
+| 指标 | 值 | 说明 |
+|------|-----|------|
+| 场景总数 | 243 | origin 正本严格表格行去重:A27/B10/C26/G12/H7/P96/S11/T32/X22 |
+| 累计已跑通 | 27 | 沿承 R529(含 2026-11-27 测试侧转正 C-07/T-03/X-02/X-13 等 4 个) |
+| 本轮新增跑通 | 0 | 本轮零源码提交;backfill/`--auto` 推进均为能力键级,无新转正 SC |
+| 失败 | 0 | 无实测失败转正项 |
+| 阻塞 | 0 | 无已登记阻塞(`--inspect` 当前无) |
+| 未跟踪 | 216 | = 243 − 27 − 0 − 0 |
+
+> **铁律**:能力键 DONE ≠ SC 跑通。本轮 `--auto` 推进的 ai.aiyunyi.* 族多为**历史已推远端提交**的幂等重认(RED→YELLOW),无任何可转正 SC。SC 口径沿承 R529(243/27),零新增。
+
+### 1.1 问题接收与处置
+
+| 指标 | 数量 | 填写说明 |
+|------|------|----------|
+| 收到的测试反馈问题数 | 0 个 | 本轮测试渠道无新问题上报 |
+| 已解决问题数 | 0 个 | 本轮零研发闭环 |
+| 待解决研发问题数 | 0 个 | 无登记阻塞项 |
+
+### 1.2 任务分发与会话管理
+
+| 指标 | 数量 | 填写说明 |
+|------|------|----------|
+| 分派任务数 | 4 个 | `--auto` 成功 4/失败 0:S-cfc-444(food.frontend.adjustmentDisplay)→lan-189、S-cfc-445(food.ops.ruleManagement)→lan-204、S-cfc-499→local-lan-4090、S-cfc-500→pub-iwintrue,全部 verified 会话 |
+| 恢复智能体会话数 | 1 个 | `--resume` 实际恢复 mes-local-45278「TDD RED S-be-947: ems.oee.r11BoardQuery」(mid-work,末尾含延续语) |
+| 当前在用会话数 | 中 | 本轮新增 4 verified + 恢复 1;backfill 后 dispatched 收敛 |
+| 会话平均利用率 | 低 | 各节点配额占用:lan-189 0/4、lan-204 0/10、local-lan-4090 0/6、mes-local 6/6 超限、prod-etotem 1/10、pub-iwintrue 0/6(派发前快照,派发后各 +1) |
+
+### 1.2b 各会话当前工作状态列表
+
+| 会话标签 | 会话 ID | 当前状态 | 当前任务 | 静默/空闲时长 | 工作目录 | 备注 |
+|----------|---------|----------|----------|---------------|----------|------|
+| lan-189 | ses_de152c433ffe1sFOUNZJEB1iEW | running | S-cfc-444 food.frontend.adjustmentDisplay(本轮新增) | 0 | .worktrees/task_S-cfc-444 | 配额 1/上限 4 |
+| lan-204 | ses_de1520bb6ffevmA73c53Gjut3l | running | S-cfc-445 food.ops.ruleManagement(本轮新增) | 0 | .worktrees/task_S-cfc-445 | 配额 1/上限 10 |
+| local-lan-4090 | ses_de151dd45ffe8adjYA9eiF7yE0 | running | S-cfc-499(本轮新增) | 0 | .worktrees/task_S-cfc-499 | 配额 1/上限 6 |
+| pub-iwintrue | ses_de151bb09ffeR5AgBrtiDrEAp0 | running | S-cfc-500(本轮新增) | 0 | .worktrees/task_S-cfc-500 | 配额 1/上限 6 |
+| mes-local-45278 | ses_de1d1502dffeKdVeKO752D0J7p | resumed | S-be-947 ems.oee.r11BoardQuery(本轮恢复) | 0 | — | 配额 6/6 超限剩余 0;busy=6 |
+| prod-etotem | — | idle | — | 空闲池 49 | — | busy=1,配额 1/上限 10(生产实例默认跳过派发) |
+| wb-cloud | — | unknown | — | — | — | `--inspect` list_sessions 401 Authorization Required(沿承) |
+
+> 派发保底已兑现:`--auto` 4 条全部 verified(dispatch.py 回执 verified=true),非"调用了 --auto 但未送达"。零派发不适用。
+
+### 1.3 变更感知与新任务建立
+
+| 指标 | 数量 | 填写说明 |
+|------|------|----------|
+| 感知需求/设计变更数 | 未检 | 错峰档精简盘点**跳过 `--changes`**(由 01 分标准档承接),如实留痕 |
+| 新增入池任务数 | 0 个 | S8 池非空(RED 6)→ 不建单;无四类溯源建单型 |
+| 既有键状态流转数 | 多次 | backfill 幂等回收 ~31 键 done + `--auto` 自动推进 ai.aiyunyi.* 族 RED→YELLOW(证据 sha 见 1.4) |
+
+### 1.4 本轮 git 提交与推送证据(真理证据)
+
+| 提交 sha | 关联任务/能力键 | 阶段 | 触及文件类型 | 目标分支 | 已推送远端 | 备注 |
+|----------|-----------------|------|--------------|----------|------------|------|
+| (本轮无源码实现提交) | — | — | — | — | — | 本轮 `--auto` 推进的 ai.aiyunyi.* 为**历史已推远端提交**的幂等重认,非新增实现;仅本汇报文件单文件入库,见 S10 |
+
+> 近期主线 tip:`bbe6866b6`(chore auto bump,前置 ebdffcdb7 test(S-be-3) RED、2793f250b test(shop.review.reply) RED)。backfill 回填的 done 卡(爱云医族 450~457/468~478/489、coach/butler/diet/membership/health/food/family/auth/activity/admin 等 ~31 键)为**历史已推远端提交**幂等重认。`--auto` 自动推进的证据 sha:9f543ccfa7d8/410ae449b0f3/c07e63b5e982/9b69a41f82fa/3a521e6ad3dc/6996fd0069ed/45fa9ed714e9(均待测试校验/部署验证)。
+
+### 1.5 状态机阶段分布与部署状态
+
+| 阶段 | 键数 | 备注 |
+|------|------|------|
+| UNTRACKED | — | 目标池 ⏳ 键 0(用例驱动池为空) |
+| RED | 6 | 本轮 8→6(contact.card.manage、food.rule.pairingMatrix、privacy.setting.config、tongue.emotion.capture 等;ai.aiyunyi 族转出) |
+| YELLOW | 133 | 本轮 131→133,ai.aiyunyi.* 族 RED→YELLOW 推进 |
+| GREEN | 10 | 待部署验证 |
+| DONE | 113 | 闭环归档(backfill 幂等回填) |
+
+| 部署项 | 值 | 说明 |
+|--------|-----|------|
+| 本轮部署次数 | 0 次 | ai.aiyunyi.* 转 YELLOW 自动待部署验证(已派发,待编排侧 `--deploy-done`),未实际部署 |
+| 最新 `last_deployed` | (未读) | 部署在途 pending 123 / confirmed 80 |
+| GREEN 部署链验证 | 不通过(本轮未触发) | 无本轮 GREEN 闭环 |
+
+### 1.6 数据源健康度
+
+| 数据源 | 读取键数 | 是否正常 | 备注 |
+|--------|----------|----------|------|
+| 需求侧(⏳ wish) | 0 | 正常 | 用例驱动池为空 |
+| 契约常量(contract) | 0 | 正常 | 无未契约化新增 |
+| 测试用例引用(test_case_map) | 0 | 正常 | 全部已入池 |
+| 执行结果回填(case_results) | 0 | 正常 | 无未实现键执行结果 |
+
+---
+
+## 二、下一步需要研发处理的事项
+
+| 序号 | 事项描述 | 依赖/前置条件 | 预估完成时间 | 优先级 | 状态 |
+|------|----------|---------------|--------------|--------|------|
+| 1 | 本轮新增 4 条 verified dispatched 卡(S-cfc-444/445/499/500)跟踪实现+push 证据 | 会话运行中 | 持续 | P1 | 进行中 |
+| 2 | REQUEUE-EXHAUSTED 多条(S-cfc-455/457/476/489 等)人工核对(YELLOW done 但 3 次 requeue 无 git 证据) | 需人工核对键级实现定论 | 下一标准轮 | P1 | 待启动 |
+| 3 | ai.aiyunyi.* 转 YELLOW 后的部署验证收口(`--deploy-done`) | 部署链路 | 持续 | P1 | 进行中 |
+
+---
+
+## 三、阻塞与风险
+
+| 阻塞项 | 影响范围 | 阻塞类型 | 处置进展 | 需要协调 |
+|--------|----------|----------|----------|----------|
+| 平台触发停摆(worklog.last_entry 断档 1032.7min / monitor.log 162.5min,S0 检出) | 全部档位 | 测试 | S0 已留痕(无残骸、仅断档信号);非本机问题 | 平台侧观察 |
+| 主工作树 353 处他人 WIP | 本机 main 工作树 | 研发 | 只报不动(AGENTS.md/健康调研前端等,属他会话推进中) | 无(他会话自收口) |
+| wb-cloud 401(`--inspect` list_sessions) | wb-cloud 节点 | 环境 | 沿承多轮,本轮未修复 | 运维侧 |
+| mes-local-45278 配额超限(busy=6/上限 6) | MES 节点 | 环境 | 沿承,本轮未新派发至该节点 | 无 |