Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 5x 5x 7x 7x 7x | import type { Statement, StatementDetail, StatementItem } from '../types'
import { get } from '../http'
import { formatYearMonth } from '@/utils/date'
import { toNumber } from '@/utils/number'
// 后端 /c/statement 返回体(com.yd.csf.service.vo.ReferrerStatement*)
interface StatementDTO {
salaryBizId: string
month: string // yyyyMM
salaryNo: string
grossAmount: number
mpfAmount: number
otherAmount: number
paidAmount: number
payoutDate?: string | null
}
interface StatementItemDTO {
policyNo: string
policyHolder: string
insuranceCompany: string
productName: string
fortunePeriod: number
fortuneName: string
brokerRatio: string | null
originalCurrency: string
originalAmount: number
originalToHkdRate: number
hkdAmount: number
}
interface StatementDetailDTO extends StatementDTO {
bankName?: string | null
accountEndNo?: string | null
items: StatementItemDTO[]
}
export async function fetchStatements(): Promise<Statement[]> {
const list = await get<StatementDTO[]>('/c/statement/list')
// 后端某月无数据时会下发 data: null,不能直接 .map
return (list ?? []).map((dto) => ({
id: dto.salaryBizId,
month: formatYearMonth(dto.month),
grossAmount: dto.grossAmount,
currency: 'HKD',
netAmount: dto.paidAmount,
payDate: dto.payoutDate ?? '',
bankTail: ''
}))
}
export async function fetchStatementDetail(id: string): Promise<StatementDetail> {
const dto = await get<StatementDetailDTO>(`/c/statement/${id}`)
// 同一保单同一年度可能有多条(不同产品/币种/调整项),仅用 policyNo-period 拼 key 会重复,
// 导致 v-for 复用错误 DOM;补下标保证唯一。
const items: StatementItem[] = (dto.items ?? []).map((it, index) => ({
id: `${it.policyNo}-${it.fortunePeriod}-${index}`,
customerName: it.policyHolder,
policyNo: it.policyNo,
companyName: it.insuranceCompany,
productName: it.productName,
commissionYearType: it.fortuneName || `Y${it.fortunePeriod}`,
originalAmount: it.originalAmount,
originalCurrency: it.originalCurrency,
exchangeRate: it.originalToHkdRate,
hkdAmount: it.hkdAmount,
// brokerRatio 为字符串,'0.35%'/'abc' 会被 Number() 转成 NaN 并渲染上屏
myRatio: toNumber(it.brokerRatio)
}))
return {
id: dto.salaryBizId,
month: formatYearMonth(dto.month),
grossAmount: dto.grossAmount,
currency: 'HKD',
netAmount: dto.paidAmount,
payDate: dto.payoutDate ?? '',
bankTail: dto.accountEndNo ?? '',
mpfAmount: dto.mpfAmount,
adjustmentAmount: dto.otherAmount,
items
}
}
|