fix(consignment): 下线 H5 收集链接渠道并封闭寄卖履约状态机

下线定向收集链接(H5 填报)整条线,提报统一走接单平台打手端:
- 删除前端 ConsignmentCollectPage、consignment-public 服务与 /consignment-collect/:token 路由
- 删除后端公开路由 routes/consignment.ts、consignment-public-service 与管理端 /consignment/links 三接口
- 迁移 079 删表 consignment_collect_links、删列 consignment_submissions.link_id,
  source_type 的 collection_link 归并为 worker_portal 并替换 CHECK

修复手工入库/编辑的凭据与截图静默丢失:后端统一按 credentialsJson ?? credentials、
screenshotsJson ?? screenshots 读取(入库/编辑/审核入库三个入口)。

按"已验收一律禁止撤销"封闭状态机:
- 撤销寄售履约加状态白名单(in_progress|pending_acceptance|problem)+ 事务内 FOR UPDATE
  锁单 + UPDATE 带 status 条件(0 行 409)+ 原因必填 + 清空指派/时限/验收草稿痕迹
- 库存改状态一律带条件:撤销要求 bound_work_order_id 命中本工单;作废/回库要求未被
  进行中工单占用(被挡时提示具体工单号);079 加部分唯一索引并清理历史重复绑定
- 工单终止统一解绑回库:打手撤单/取消指派/退回大厅/撤单/打手退单申请/超时处置接入
  releaseConsignmentInventoryBindingForWorkOrderWithClient(售后不改工单状态,无需接入)
- 回库路径保留运营的 allow_matching 开关设置(不再强制开启),前端文案同步更正

顺带修掉资金与归属的同源缺陷:
- 押金归属与重冻金额改取不可变的冻结核销行,审核改派不再"退给错人/向错人扣款"
- 新增 assigned_worker_id 拆开"卖家"与"被指派履约人",占库不再覆盖卖家
- PUT /inventories/:id 禁止直接改 status;发布接口补 requireActiveWorker
- 押金冻结/释放后补推钱包实时事件;迁移 079 给发布冻结加台账幂等唯一索引

验证:后端 401 测试/398 通过/3 skip(新增 5 例回归),前端 16 通过;
两侧 typecheck、lint:check、format:check 与 check:sql、build 全绿。
迁移 079 未经真实数据库执行(本环境无 Postgres),上库前请先 dry-run。
This commit is contained in:
yml2213
2026-09-16 20:05:49 +08:00
parent e828e677a5
commit 632dddc4c3
25 changed files with 960 additions and 1363 deletions
@@ -1,6 +1,5 @@
import { apiGet, apiPatch, apiPost, apiPut } from '@/lib/http'
import type {
ConsignmentCollectLink,
ConsignmentInventory,
ConsignmentStatsSummary,
ConsignmentSubmission,
@@ -62,25 +61,6 @@ export function returnAdminConsignmentInventory(id: number | string, payload: {
)
}
// --- 收集链接 ---
export function fetchAdminConsignmentLinks() {
return apiGet<{ items: ConsignmentCollectLink[] }>(
'/api/v1/admin/worker-platform/consignment/links',
)
}
export function createAdminConsignmentLink(payload: Record<string, unknown>) {
return apiPost<ConsignmentCollectLink>('/api/v1/admin/worker-platform/consignment/links', payload)
}
export function updateAdminConsignmentLink(id: number | string, payload: Record<string, unknown>) {
return apiPut<ConsignmentCollectLink>(
`/api/v1/admin/worker-platform/consignment/links/${id}`,
payload,
)
}
// --- 提报审核 ---
export function fetchAdminConsignmentSubmissions(params?: Record<string, unknown>) {
@@ -1,34 +0,0 @@
import { apiGet, apiPost } from '@/lib/http'
import type { ConsignmentCollectLink, ConsignmentSubmission } from '@/types/consignment'
export function fetchPublicConsignmentLink(token: string) {
return apiGet<ConsignmentCollectLink>(`/api/v1/consignment/${encodeURIComponent(token)}`)
}
export function submitPublicConsignment(token: string, payload: Record<string, unknown>) {
return apiPost<ConsignmentSubmission>(
`/api/v1/consignment/${encodeURIComponent(token)}/submit`,
payload,
)
}
export async function uploadConsignmentImage(
file: File,
): Promise<{ url: string; assetId?: string }> {
const formData = new FormData()
formData.append('file', file)
formData.append('scene', 'consignment-material')
const response = await fetch('/api/v1/consignment/upload', {
method: 'POST',
body: formData,
})
if (!response.ok) {
const errJson = await response.json().catch(() => ({}))
throw new Error(errJson?.message || '图片上传失败')
}
const result = await response.json()
return result?.data || result
}