feat(fulfillment): 增加统一结算与多渠道人工履约

This commit is contained in:
yml2213
2026-11-05 16:14:56 +08:00
parent 548070c2ad
commit 4e83dbb84c
43 changed files with 1582 additions and 334 deletions
@@ -37,6 +37,7 @@ import type {
MissingCostItem,
OrderItemCostContext,
} from './cost-center-shared.js'
import { calculateManualCostFen, parseManualChannelQuantity } from './manual-credit-quantity.js'
export async function previewAdminCost(payload: JsonObject = {}) {
const context = await resolveCostContext(payload)
@@ -138,14 +139,14 @@ async function resolveManualCostHint(orderItemId: number | null) {
)
const row = result.rows[0]
if (!row) return null
const creditQuantity = Number(row.credit_quantity || 0)
const creditQuantity = parseManualChannelQuantity(row.credit_quantity, row.platform_key) ?? 0
const unitPriceFen = Number(row.unit_price_fen || 1)
return {
platformKey: row.platform_key,
creditQuantity,
unitPriceFen,
costMode: row.cost_mode === 'fixed' ? ('fixed' as const) : ('variable' as const),
costFen: creditQuantity > 0 ? creditQuantity * unitPriceFen : null,
costFen: creditQuantity > 0 ? calculateManualCostFen(creditQuantity, unitPriceFen) : null,
}
}