# 移除闪送运价专用锁表实施计划 > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** 删除闪送运价专用数据库锁表及调用,同时保留事务、重叠校验、配置版本校验和读取侧异常保护。 **Architecture:** 平台运价增删改直接在现有 Spring 事务中执行,新增和修改先调用 `countOverlapping(...)` 校验;修改继续以 `config_version` 为条件更新。数据库迁移仅追加删表 SQL,不直接执行。 **Tech Stack:** JDK 21、Spring Boot、MyBatis-Plus/MyBatis、MySQL、JUnit 5、Mockito。 ## Global Constraints - 默认分支为 `test`,提交标题和正文使用中文,不使用英文 Conventional Commits 前缀。 - 只修改闪送运价锁相关代码、测试、规格和 SQL,不暂存工作区原有注释及 observations 文件。 - 不直接执行数据库 SQL;所有迁移仅追加到 `updatesql/sql.md`。 - 保留 `@Transactional`、`countOverlapping(...)`、`config_version` 更新条件和读取侧多时段异常检查。 --- ### Task 1: 删除闪送运价专用数据库锁 **Files:** - Modify: `ruoyi-system/src/test/java/com/ruoyi/system/mapper/flash/FlashDeliveryPricingMapperContractTest.java` - Modify: `ruoyi-admin/src/test/java/com/ruoyi/app/flashdelivery/service/FlashDeliveryApplicationServiceTest.java` - Modify: `ruoyi-system/src/main/java/com/ruoyi/system/mapper/flash/FlashDeliveryPricingMapper.java` - Modify: `ruoyi-admin/src/main/java/com/ruoyi/app/flashdelivery/service/FlashDeliveryApplicationService.java` - Modify: `specs/024-flash-delivery/spec.md` - Modify: `specs/024-flash-delivery/design.md` - Modify: `specs/024-flash-delivery/data-model.md` - Modify: `specs/024-flash-delivery/plan.md` - Modify: `specs/024-flash-delivery/tasks.md` - Modify: `updatesql/sql.md` **Interfaces:** - Consumes: `FlashDeliveryPricingMapper.countOverlapping(String, String, Long)`、`BaseMapper` CRUD 和 `FlashDeliveryPricing.configVersion`。 - Produces: 不再暴露 `FlashDeliveryPricingMapper.lockPricing()`;运价接口和请求响应契约保持不变。 - [x] **Step 1: 先让新增运价不依赖专用锁行的行为测试红灯** 删除 `FlashDeliveryApplicationServiceTest.Fixture` 中的以下默认模拟,让既有 `createPricingPersistsImmediatelyActiveTimePeriod` 测试表达“数据库没有专用锁行时仍可新增运价”的目标行为: ```java when(pricingMapper.lockPricing()).thenReturn("GLOBAL"); ``` - [x] **Step 2: 运行测试确认旧实现红灯** ```powershell $env:JAVA_HOME='C:\Users\qmj\.jdks\graalvm-jdk-21.0.7' $env:PATH="$env:JAVA_HOME\bin;$env:PATH" mvn -pl ruoyi-admin -am "-Dtest=FlashDeliveryApplicationServiceTest#createPricingPersistsImmediatelyActiveTimePeriod" "-Dsurefire.failIfNoSpecifiedTests=false" test ``` 预期:`createPricingPersistsImmediatelyActiveTimePeriod` 因旧实现读取不到 `GLOBAL` 锁行而抛出 `ServiceException`。 - [x] **Step 3: 删除最小生产锁逻辑并修正既有测试** 从 Mapper 删除: ```java @Select(""" select lock_key from flash_delivery_pricing_lock where lock_key = 'GLOBAL' for update """) String lockPricing(); ``` 从 `createPricing`、`updatePricing`、`deletePricing` 删除 `lockPricing();`,并删除服务层私有 `lockPricing()` 方法。Mapper 契约测试删除仅验证专用锁 SQL 的测试;应用服务测试删除 `lockPricing()` 的调用顺序断言,但继续验证重叠查询、插入、版本更新和删除行为。 - [x] **Step 4: 同步规格和迁移 SQL** 删除当前数据模型中的 `flash_delivery_pricing_lock`,在规格中明确低频管理场景接受并发新增的极低概率重叠风险;修改仍使用版本校验,读取仍拒绝多条匹配。在 `updatesql/sql.md` 末尾追加: ```markdown ## 2026-09-07 移除闪送运价专用锁表 \`\`\`sql DROP TABLE IF EXISTS flash_delivery_pricing_lock; \`\`\` ``` 更新 `tasks.md` 增加并完成本次规格、红灯、实现、验证任务。 - [x] **Step 5: 运行定向测试和模块构建** ```powershell $env:JAVA_HOME='C:\Users\qmj\.jdks\graalvm-jdk-21.0.7' $env:PATH="$env:JAVA_HOME\bin;$env:PATH" mvn -pl ruoyi-admin -am "-Dtest=FlashDeliveryPricingMapperContractTest,FlashDeliveryApplicationServiceTest,FlashDeliveryControllerContractTest" "-Dsurefire.failIfNoSpecifiedTests=false" test mvn -pl ruoyi-admin -am -DskipTests package ``` 预期:定向测试与七模块构建均为 `BUILD SUCCESS`。 - [x] **Step 6: 核对范围、中文提交并推送** ```powershell git diff --check git status --short git add -- docs/superpowers/plans/2026-09-07-remove-flash-pricing-lock.md ruoyi-system/src/test/java/com/ruoyi/system/mapper/flash/FlashDeliveryPricingMapperContractTest.java ruoyi-admin/src/test/java/com/ruoyi/app/flashdelivery/service/FlashDeliveryApplicationServiceTest.java ruoyi-system/src/main/java/com/ruoyi/system/mapper/flash/FlashDeliveryPricingMapper.java ruoyi-admin/src/main/java/com/ruoyi/app/flashdelivery/service/FlashDeliveryApplicationService.java specs/024-flash-delivery/spec.md specs/024-flash-delivery/design.md specs/024-flash-delivery/data-model.md specs/024-flash-delivery/plan.md specs/024-flash-delivery/tasks.md updatesql/sql.md git diff --cached --name-only git diff --cached --check git commit -m "移除闪送运价专用锁表" -m "保留事务、时段重叠和版本校验,删除低频后台配置不需要的全局数据库行锁及迁移表。" git push origin test ``` 预期:暂存清单不包含工作区原有注释文件和 `.claude/homunculus/observations.jsonl`。