59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
/** 采集协议单 · 缴费默认定价表(样本数 × 缴费模式) */
|
|
|
|
export type PayMode = 'dj' | 'fq' | 'djfq'
|
|
|
|
export type PaymentPreset = {
|
|
contractAmount: number
|
|
installmentCount?: number
|
|
installmentAmounts?: number[]
|
|
}
|
|
|
|
const PRESETS: Record<1 | 2, Partial<Record<PayMode, PaymentPreset>>> = {
|
|
1: {
|
|
dj: { contractAmount: 22880 },
|
|
fq: {
|
|
contractAmount: 25880,
|
|
installmentCount: 6,
|
|
installmentAmounts: [6480, 3880, 3880, 3880, 3880, 3880]
|
|
}
|
|
},
|
|
2: {
|
|
dj: { contractAmount: 37880 },
|
|
djfq: {
|
|
contractAmount: 41000,
|
|
installmentCount: 4,
|
|
installmentAmounts: [29360, 3880, 3880, 3880]
|
|
},
|
|
fq: {
|
|
contractAmount: 44000,
|
|
installmentCount: 5,
|
|
installmentAmounts: [12960, 7760, 7760, 7760, 7760]
|
|
}
|
|
}
|
|
}
|
|
|
|
export function getActiveSampleCount(samples: Array<{ sampleStatus?: string }>): 1 | 2 {
|
|
const n = samples.filter((s) => String(s.sampleStatus || '') !== 'yzf').length
|
|
return (n >= 2 ? 2 : 1) as 1 | 2
|
|
}
|
|
|
|
export function resolvePaymentPreset(
|
|
sampleCount: 1 | 2,
|
|
payMode: PayMode
|
|
): PaymentPreset | null {
|
|
return PRESETS[sampleCount]?.[payMode] ?? null
|
|
}
|
|
|
|
export function isInstallmentPayMode(payMode: string): boolean {
|
|
return payMode === 'fq' || payMode === 'djfq'
|
|
}
|
|
|
|
export function availablePayModes(sampleCount: 1 | 2): PayMode[] {
|
|
return sampleCount === 2 ? ['dj', 'djfq', 'fq'] : ['dj', 'fq']
|
|
}
|
|
|
|
/** 校验缴费模式与样本数是否匹配(如 djfq 仅双样本) */
|
|
export function isPayModeValidForSampleCount(payMode: PayMode, sampleCount: 1 | 2): boolean {
|
|
return availablePayModes(sampleCount).includes(payMode)
|
|
}
|