feat(finance): 商品渠道能力、自动发货转人工与成本异常收口
- 商品可同时支持自动发货/人工,新增渠道能力与成本冲销字段 - 卡券缺商品时按内部中文 SKU 自动建 tpv: 商品并补渠道规则 - 自动发货失败转人工并冲销原渠道成本 - 配置成本后按最早缺失订单生效并立即补算、关闭异常 - tpv: 商品来源计入第三方卡券
This commit is contained in:
@@ -134,7 +134,7 @@ export async function listManualFulfillmentPending(
|
||||
cs.order_item_id,
|
||||
MAX(cs.created_at) AS fulfilled_at
|
||||
FROM cost_snapshots cs
|
||||
WHERE cs.subject_type = 'manual_case' AND cs.superseded_at IS NULL
|
||||
WHERE cs.subject_type = 'manual_case' AND cs.superseded_at IS NULL AND reversed_at IS NULL
|
||||
GROUP BY cs.order_item_id
|
||||
)
|
||||
`
|
||||
@@ -294,7 +294,7 @@ export async function confirmManualFulfillment(payload: JsonObject, session: Adm
|
||||
// 锁内复查:并发/双击的第二个请求会等锁,醒来后看到快照直接拒绝,不会重复扣款。
|
||||
const existing = await client.query<{ id: number }>(
|
||||
`SELECT id FROM cost_snapshots
|
||||
WHERE subject_type = 'manual_case' AND order_item_id = $1 AND superseded_at IS NULL
|
||||
WHERE subject_type = 'manual_case' AND order_item_id = $1 AND superseded_at IS NULL AND reversed_at IS NULL
|
||||
LIMIT 1`,
|
||||
[orderItemId],
|
||||
)
|
||||
@@ -874,7 +874,7 @@ export async function getManualFulfillmentCountsByOrderIds(
|
||||
WITH fulfilled AS (
|
||||
SELECT order_item_id, MAX(created_at) AS fulfilled_at
|
||||
FROM cost_snapshots
|
||||
WHERE subject_type = 'manual_case' AND superseded_at IS NULL
|
||||
WHERE subject_type = 'manual_case' AND superseded_at IS NULL AND reversed_at IS NULL
|
||||
GROUP BY order_item_id
|
||||
)
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user