feat(consignment): 接单模板反推规格字段,打手端大批量选项改下拉
- 新增 consignment-template-spec-service:按「分类 + 子树」解析接单模板商品名, 全部可拆成统一维度且无组合碰撞时生成多字段矩阵,否则整类降级为商品名下拉; 选项只存 ruleKey,取价时实时回查模板,模板停用/删除即无价(missingPricePolicy=block)。 - 匹配引擎:模板驱动配置强制使用 profile specs(不再回退库存旧快照),订单侧按 product_rule_id 反解规格;解析失败按 unknown 处理,不参与自动匹配。 - 管理端:寄卖配置新增「从接单模板生成」,弹窗给出推荐模式(规格字段 / 商品名下拉)、 降级原因与组合→模板价覆盖矩阵。 - 打手端:选项超过 8 个改用带搜索的下拉(地铁逃生 100 个商品),规格网格按字段数 自适应铺满;物品名改用商品名,去掉硬编码「苏尔南」后缀。 - 迁移重编号:合并 main 后寄卖线顺延为 147–151,migrate.ts 保留 legacy→new 幂等映射。 - 同工作区的拼单份额报酬口径、超时重匹配兜底、整单/拼单匹配弹窗调整一并提交。 验证:前端 254/254、后端寄卖相关 41/41、双端 tsc 通过;开发库已实跑 发布→审核入库→自动匹配(模板价 1200 → 匹配报酬 1200)。
This commit is contained in:
@@ -29,34 +29,58 @@ const MIGRATION_FILE_PATTERN = /^(\d{3})_.+\.sql$/i
|
||||
* 129-131 -> 135-137(main 占用 129-134)
|
||||
* 135-137 -> 142-144(main 又占用 135-141)
|
||||
* 142-148 -> 142_consignment_platform(2026-11-06 合并为单文件)
|
||||
* 2026-11-07 二次撞号:main 又占用 142-146,寄卖线整体顺延为 147-151
|
||||
* 已跑过旧编号的环境要清掉旧记录,让新编号按正常顺序重跑(迁移本身幂等)。
|
||||
*/
|
||||
const RENAMED_MIGRATIONS: Array<{ legacyName: string; currentName: string }> = [
|
||||
{ legacyName: '129_consignment_matching', currentName: '142_consignment_platform' },
|
||||
{ legacyName: '135_consignment_matching', currentName: '142_consignment_platform' },
|
||||
{ legacyName: '130_consignment_dynamic_specs', currentName: '142_consignment_platform' },
|
||||
{ legacyName: '136_consignment_dynamic_specs', currentName: '142_consignment_platform' },
|
||||
{ legacyName: '129_consignment_matching', currentName: '147_consignment_platform' },
|
||||
{ legacyName: '135_consignment_matching', currentName: '147_consignment_platform' },
|
||||
{ legacyName: '130_consignment_dynamic_specs', currentName: '147_consignment_platform' },
|
||||
{ legacyName: '136_consignment_dynamic_specs', currentName: '147_consignment_platform' },
|
||||
{
|
||||
legacyName: '131_consignment_surnan_default_profile',
|
||||
currentName: '142_consignment_platform',
|
||||
currentName: '147_consignment_platform',
|
||||
},
|
||||
{
|
||||
legacyName: '137_consignment_surnan_default_profile',
|
||||
currentName: '142_consignment_platform',
|
||||
currentName: '147_consignment_platform',
|
||||
},
|
||||
{ legacyName: '142_consignment_matching', currentName: '142_consignment_platform' },
|
||||
{ legacyName: '143_consignment_dynamic_specs', currentName: '142_consignment_platform' },
|
||||
{ legacyName: '142_consignment_matching', currentName: '147_consignment_platform' },
|
||||
{ legacyName: '143_consignment_dynamic_specs', currentName: '147_consignment_platform' },
|
||||
{
|
||||
legacyName: '144_consignment_surnan_default_profile',
|
||||
currentName: '142_consignment_platform',
|
||||
currentName: '147_consignment_platform',
|
||||
},
|
||||
{
|
||||
legacyName: '145_consignment_inventory_multi_binding',
|
||||
currentName: '142_consignment_platform',
|
||||
currentName: '147_consignment_platform',
|
||||
},
|
||||
{ legacyName: '146_consignment_share_gift', currentName: '147_consignment_platform' },
|
||||
{ legacyName: '147_consignment_match_and_rematch', currentName: '147_consignment_platform' },
|
||||
{ legacyName: '148_consignment_remove_zone_help_text', currentName: '147_consignment_platform' },
|
||||
/*
|
||||
* 2026-11-07 二次撞号:合并 main 后 main 又占用 142-146(voucher/fulfillment 系列)。
|
||||
* 寄卖迁移整体顺延:142→147、143→148、144→149、145/146→150、147(截止时间约束)→151。
|
||||
* 旧库记录按下面的映射清掉后按新编号重跑,全部迁移均为幂等脚本。
|
||||
*/
|
||||
{ legacyName: '142_consignment_platform', currentName: '147_consignment_platform' },
|
||||
{ legacyName: '143_consignment_sms_logs', currentName: '148_consignment_sms_logs' },
|
||||
{
|
||||
legacyName: '144_consignment_inventory_category_backfill',
|
||||
currentName: '149_consignment_inventory_category_backfill',
|
||||
},
|
||||
{
|
||||
legacyName: '145_work_order_consignment_original_reward',
|
||||
currentName: '150_work_order_consignment_original_reward',
|
||||
},
|
||||
{
|
||||
legacyName: '146_work_order_consignment_original_reward',
|
||||
currentName: '150_work_order_consignment_original_reward',
|
||||
},
|
||||
{
|
||||
legacyName: '147_work_order_internal_matching_deadline_guard',
|
||||
currentName: '151_work_order_internal_matching_deadline_guard',
|
||||
},
|
||||
{ legacyName: '146_consignment_share_gift', currentName: '142_consignment_platform' },
|
||||
{ legacyName: '147_consignment_match_and_rematch', currentName: '142_consignment_platform' },
|
||||
{ legacyName: '148_consignment_remove_zone_help_text', currentName: '142_consignment_platform' },
|
||||
]
|
||||
|
||||
export async function runDatabaseMigrations() {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
-- 142_consignment_platform.sql
|
||||
-- 寄卖平台完整迁移(由 142–148 收敛,2026-11-06)
|
||||
-- 147_consignment_platform.sql(原 142_consignment_platform,合并 main 后顺延)
|
||||
-- 寄卖平台完整迁移(原 142–148 收敛为一个文件,2026-11-06)
|
||||
-- 142 寄卖配置/库存/内部匹配
|
||||
-- 143 动态规格
|
||||
-- 144 苏尔南默认寄卖配置
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
-- 143_consignment_sms_logs.sql
|
||||
-- 148_consignment_sms_logs.sql(原 143_consignment_sms_logs,合并 main 后顺延)
|
||||
-- 寄卖匹配成功短信发送记录:用于幂等、审计与 Mock 联调验证。
|
||||
-- 同一工单 + 同一库存只允许一条记录,避免重试/重复调度重复发短信。
|
||||
CREATE TABLE IF NOT EXISTS consignment_sms_logs (
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
-- 144_consignment_inventory_category_backfill.sql
|
||||
-- 149_consignment_inventory_category_backfill.sql(原 144_consignment_inventory_category_backfill,合并 main 后顺延)
|
||||
-- 寄售仓库按「寄卖配置分类」筛选的前置数据修复。
|
||||
--
|
||||
-- 背景:分类级寄卖配置(142)上线前入库的提报与库存没有写 category_id/profile_id,
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
-- 145_work_order_consignment_original_reward.sql
|
||||
-- 150_work_order_consignment_original_reward.sql(原 145→146→150,合并 main 后顺延)
|
||||
-- 寄卖内部匹配会改写 work_orders.reward_amount(按库存售价-服务费结算)。
|
||||
-- 这里固化“匹配前的原始工单报酬”,所有释放库存的路径恢复它,避免超时/取消/退款后
|
||||
-- 大厅继续展示寄卖结算价、或二次匹配在已被改写的金额上继续扣服务费。
|
||||
@@ -0,0 +1,34 @@
|
||||
-- 151_work_order_internal_matching_deadline_guard.sql(原 147,合并 main 后顺延)
|
||||
-- 工单状态不变量:internal_matching 必须有内部匹配截止时间。
|
||||
--
|
||||
-- 背景:手动匹配/重新匹配曾先把工单改成 internal_matching,再补截止时间;
|
||||
-- 中途失败会留下「internal_matching 且 deadline 为空」的工单,
|
||||
-- 既不在大厅,也不会被超时任务处理。这里先修复存量,再用 CHECK 约束兜底。
|
||||
|
||||
-- 1. 修复存量:给缺失截止时间的内部匹配工单补 30 分钟等待窗口。
|
||||
UPDATE work_orders
|
||||
SET
|
||||
internal_match_deadline_at = NOW() + INTERVAL '30 minutes',
|
||||
hall_visible_at = COALESCE(hall_visible_at, NOW() + INTERVAL '30 minutes'),
|
||||
updated_at = NOW()
|
||||
WHERE status = 'internal_matching'
|
||||
AND internal_match_deadline_at IS NULL;
|
||||
|
||||
-- 2. 新写入保护:internal_matching 不允许 deadline 为空。
|
||||
-- 使用 NOT VALID + VALIDATE:先约束新写入,再校验存量(若并发写入异常会在此暴露)。
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM pg_constraint
|
||||
WHERE conname = 'work_orders_internal_matching_deadline_check'
|
||||
) THEN
|
||||
ALTER TABLE work_orders
|
||||
ADD CONSTRAINT work_orders_internal_matching_deadline_check
|
||||
CHECK (status <> 'internal_matching' OR internal_match_deadline_at IS NOT NULL)
|
||||
NOT VALID;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
ALTER TABLE work_orders
|
||||
VALIDATE CONSTRAINT work_orders_internal_matching_deadline_check;
|
||||
Reference in New Issue
Block a user