feat(fulfillment): 渠道联动与管道兜底
- 人工配置保存/删除同步渠道规则,人工确认写 channel/status - 按 SKU 指定渠道默认同时落规则 - 管道补充:载体缺失、人工成本未记录、事实与总账按水位追赶
This commit is contained in:
@@ -371,7 +371,8 @@ export async function assignChannelBySku(input: {
|
||||
channel: string
|
||||
adminUserId: number | null
|
||||
note?: string
|
||||
}): Promise<{ updated: number }> {
|
||||
createRule?: boolean
|
||||
}): Promise<{ updated: number; ruleCreated: boolean }> {
|
||||
if (!isFulfillmentChannel(input.channel)) {
|
||||
throw createHttpError('渠道无效', { statusCode: 400, errorCode: 'invalid_channel' })
|
||||
}
|
||||
@@ -395,7 +396,26 @@ export async function assignChannelBySku(input: {
|
||||
`,
|
||||
[input.provider, input.shopId, input.skuCode, input.channel, input.adminUserId],
|
||||
)
|
||||
return { updated: result.rowCount || 0 }
|
||||
|
||||
// 默认同时落一条渠道规则:否则同 SKU 的下一单还是会进待分类。
|
||||
let ruleCreated = false
|
||||
if (input.createRule !== false) {
|
||||
const rule = await upsertChannelRule({
|
||||
provider: input.provider,
|
||||
shopId: input.shopId,
|
||||
matchKeyType: 'sku_code',
|
||||
matchKey: input.skuCode,
|
||||
channel: input.channel,
|
||||
priority: 10,
|
||||
source: 'operator',
|
||||
enabled: true,
|
||||
note: `运营在待分类队列指定:${String(input.note || '').slice(0, 120)}`,
|
||||
adminUserId: input.adminUserId,
|
||||
})
|
||||
ruleCreated = rule.id > 0
|
||||
}
|
||||
|
||||
return { updated: result.rowCount || 0, ruleCreated }
|
||||
}
|
||||
|
||||
export async function listChannelRules(
|
||||
|
||||
Reference in New Issue
Block a user