refactor(distribution): 重写分销迁移并落地利润百分比分成与货架比例

将 000064-000078 合并为 064/065/066,默认规则改为收号 35%、卖出 40%、服务费 25%。
货架调价改为增加分站 1 元兑换哈夫币比例。sql-guard 仅保护 main 已发布迁移。
This commit is contained in:
yml2213
2026-09-08 19:02:58 +08:00
parent 48a2961245
commit d762b33f54
48 changed files with 745 additions and 1073 deletions
+12 -3
View File
@@ -63,12 +63,21 @@ require_pattern "backend/internal/modules/chat/support.go" "renter.phone = ? OR
# 禁止核心列表重新引入跨表 6~10 路全扫描反模式
forbid_pattern "backend/internal/modules/dispute/query.go" "o.order_no LIKE ? OR l.listing_no LIKE ? OR a.title LIKE ? OR owner.phone LIKE ? OR renter.phone LIKE ? OR d.id = ?" "纠纷列表禁止6表无意图全表扫描"
# 已发布迁移只允许新增,不允许修改或删除历史文件。
if changed_migrations="$(git -C "${ROOT_DIR}" diff --name-status HEAD -- backend/migrations)"; then
# 已合入 main 的迁移只允许新增,不允许修改或删除。
# 当前分支尚未合入 main 的迁移可以整段重写。
published_ref=""
if git -C "${ROOT_DIR}" rev-parse --verify main >/dev/null 2>&1; then
published_ref="main"
elif git -C "${ROOT_DIR}" rev-parse --verify origin/main >/dev/null 2>&1; then
published_ref="origin/main"
fi
if [[ -z "${published_ref}" ]]; then
failures+=("无法确定 main 分支,无法检查已发布迁移")
elif changed_migrations="$(git -C "${ROOT_DIR}" diff --name-status "${published_ref}" -- backend/migrations)"; then
while read -r status file _; do
[[ -z "${status:-}" ]] && continue
if [[ "${status}" != "A" ]]; then
failures+=("历史迁移文件不可修改或删除: ${status} ${file}")
failures+=("已发布迁移文件不可修改或删除: ${status} ${file}")
fi
done <<< "${changed_migrations}"
else