feat(fulfillment): 增加统一结算与多渠道人工履约
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user