feat: 细胞存储缴费催缴、统一样本信息与协议支付能力增强
汇总近期业务改动:催缴菜单与后端、样本信息快捷登记与进度、运费关联、客户档案扩展、协议优惠/期次与押金划转,并同步 SQL 迁移与管理端页面收敛。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2d3472f5c4
commit
db31990ebe
235 files changed
+14898
-10196
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import type { CollectionProtocolRow } from '../api/collection-protocol'
|
||||
import type { QcProtocolPaymentSummary } from '../api/qc-work-order'
|
||||
|
||||
/** 细胞存储协议 / 科研捐赠列表行(均为 Record) */
|
||||
export type ProtocolAuditSourceRow = Record<string, unknown>
|
||||
|
||||
export type ProtocolAuditSampleTransport = {
|
||||
transportType?: string
|
||||
destSiteName?: string
|
||||
@@ -14,13 +16,14 @@ export type ProtocolAuditSampleTransport = {
|
||||
export type ProtocolAuditFlatRow = {
|
||||
rowKey: string
|
||||
protocolId: string
|
||||
protocol: CollectionProtocolRow
|
||||
protocol: ProtocolAuditSourceRow
|
||||
sampleCount: number
|
||||
sampleIndex: number
|
||||
isCoStored: boolean
|
||||
collectDate: string
|
||||
sampleCollectTime: string
|
||||
motherName: string
|
||||
/** 协议编号或捐赠单号 */
|
||||
protocolNo: string
|
||||
regionName: string
|
||||
hospitalName: string
|
||||
@@ -49,7 +52,7 @@ export function extractCollectDate(raw?: string | null): string {
|
||||
return m ? m[1] : ''
|
||||
}
|
||||
|
||||
function readSampleItems(protocol: CollectionProtocolRow): Record<string, unknown>[] {
|
||||
function readSampleItems(protocol: ProtocolAuditSourceRow): Record<string, unknown>[] {
|
||||
const raw = protocol.sampleItems
|
||||
if (Array.isArray(raw) && raw.length) {
|
||||
return raw.map((x) => asRecord(x) || {})
|
||||
@@ -58,7 +61,7 @@ function readSampleItems(protocol: CollectionProtocolRow): Record<string, unknow
|
||||
}
|
||||
|
||||
export function flattenProtocolAuditRows(
|
||||
list: CollectionProtocolRow[]
|
||||
list: ProtocolAuditSourceRow[]
|
||||
): ProtocolAuditFlatRow[] {
|
||||
const out: ProtocolAuditFlatRow[] = []
|
||||
for (const protocol of list || []) {
|
||||
@@ -81,7 +84,7 @@ export function flattenProtocolAuditRows(
|
||||
collectDate: extractCollectDate(str(protocol.sampleCollectTime)),
|
||||
sampleCollectTime: str(protocol.sampleCollectTime),
|
||||
motherName: str(protocol.motherName),
|
||||
protocolNo: str(protocol.protocolNo),
|
||||
protocolNo: str(protocol.protocolNo) || str(protocol.donationNo),
|
||||
regionName: str(protocol.regionName),
|
||||
hospitalName: str(protocol.hospitalName),
|
||||
salesUserName: str(protocol.salesUserName),
|
||||
@@ -103,9 +106,9 @@ export function flattenProtocolAuditRows(
|
||||
|
||||
export function uniqueProtocolsFromFlatRows(
|
||||
rows: ProtocolAuditFlatRow[]
|
||||
): CollectionProtocolRow[] {
|
||||
): ProtocolAuditSourceRow[] {
|
||||
const seen = new Set<string>()
|
||||
const out: CollectionProtocolRow[] = []
|
||||
const out: ProtocolAuditSourceRow[] = []
|
||||
for (const r of rows) {
|
||||
if (!r.protocolId || seen.has(r.protocolId)) continue
|
||||
seen.add(r.protocolId)
|
||||
@@ -114,22 +117,37 @@ export function uniqueProtocolsFromFlatRows(
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* 首期缴费时间:优先用后端 firstPayTransferTime(第 1 期转账最后一笔);
|
||||
* 否则从 paymentDetails 中取第 1 期 transferTime 最晚的一笔。
|
||||
* 无转账时间时返回空(不回退应缴日)。
|
||||
*/
|
||||
export function firstPayTimeLines(
|
||||
summary: QcProtocolPaymentSummary | null | undefined
|
||||
): string[] {
|
||||
const preferred = str(summary?.firstPayTransferTime)
|
||||
if (preferred) return [preferred]
|
||||
|
||||
const details = summary?.paymentDetails
|
||||
if (!Array.isArray(details) || !details.length) return []
|
||||
const sorted = [...details].sort((a, b) => {
|
||||
const na = a.installmentNo == null ? 10_000 : Number(a.installmentNo)
|
||||
const nb = b.installmentNo == null ? 10_000 : Number(b.installmentNo)
|
||||
return na - nb
|
||||
})
|
||||
const lines: string[] = []
|
||||
for (const d of sorted) {
|
||||
const t = str((d as { transferTime?: string }).transferTime)
|
||||
const due = str(d.installmentDueDate)
|
||||
const pick = t || due
|
||||
if (pick) lines.push(pick)
|
||||
|
||||
const numbered = details.filter(
|
||||
(d) => d.installmentNo != null && String(d.installmentNo).trim() !== ''
|
||||
)
|
||||
let periodRows = details
|
||||
if (numbered.some((d) => Number(d.installmentNo) === 1)) {
|
||||
periodRows = details.filter((d) => Number(d.installmentNo) === 1)
|
||||
} else if (numbered.length) {
|
||||
const minNo = Math.min(...numbered.map((d) => Number(d.installmentNo)))
|
||||
periodRows = details.filter((d) => Number(d.installmentNo) === minNo)
|
||||
} else {
|
||||
periodRows = [details[0]]
|
||||
}
|
||||
return lines
|
||||
|
||||
const times = periodRows
|
||||
.map((d) => str(d.transferTime))
|
||||
.filter(Boolean)
|
||||
.sort()
|
||||
if (!times.length) return []
|
||||
return [times[times.length - 1]]
|
||||
}
|
||||
Reference in new issue
Block a user