feat: add reconciliation and quality reporting
This commit is contained in:
@@ -261,6 +261,7 @@ model DrainageField {
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
channelReportFields ChannelReportField[]
|
||||
commonReportFields CommonReportField[]
|
||||
}
|
||||
|
||||
model TenantAccount {
|
||||
@@ -449,6 +450,7 @@ model SmsDrainageInfo {
|
||||
signature SmsSignature @relation(fields: [signatureId], references: [id], onDelete: Cascade)
|
||||
application SmsApplication? @relation(fields: [applicationId], references: [id])
|
||||
reportTasks ChannelSignatureReportTask[]
|
||||
messageRecords SmsMessageRecord[]
|
||||
|
||||
@@index([tenantId, auditStatus, updatedAt])
|
||||
@@index([signatureId, auditStatus])
|
||||
@@ -716,6 +718,22 @@ model ChannelReportField {
|
||||
@@index([drainageFieldId, reportType])
|
||||
}
|
||||
|
||||
model CommonReportField {
|
||||
id String @id @default(cuid())
|
||||
drainageFieldId String
|
||||
reportType String
|
||||
required Boolean @default(false)
|
||||
sortOrder Int @default(100)
|
||||
status String @default("active")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
drainageField DrainageField @relation(fields: [drainageFieldId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@unique([drainageFieldId, reportType])
|
||||
@@index([reportType, status, sortOrder])
|
||||
}
|
||||
|
||||
model SignatureReportMaterial {
|
||||
id String @id @default(cuid())
|
||||
signatureId String
|
||||
@@ -974,6 +992,7 @@ model SmsMessageRecord {
|
||||
applicationId String?
|
||||
templateId String?
|
||||
signatureId String?
|
||||
drainageInfoId String?
|
||||
reviewTaskId String?
|
||||
messageId String @unique
|
||||
phoneNumber String
|
||||
@@ -1004,6 +1023,7 @@ model SmsMessageRecord {
|
||||
application SmsApplication? @relation(fields: [applicationId], references: [id])
|
||||
template SmsTemplate? @relation(fields: [templateId], references: [id])
|
||||
signature SmsSignature? @relation(fields: [signatureId], references: [id])
|
||||
drainageInfo SmsDrainageInfo? @relation(fields: [drainageInfoId], references: [id])
|
||||
reviewTask SmsSendTask? @relation(fields: [reviewTaskId], references: [id])
|
||||
channel SmsChannel? @relation(fields: [channelId], references: [id])
|
||||
submitRecords SmsSubmitRecord[]
|
||||
@@ -1018,6 +1038,7 @@ model SmsMessageRecord {
|
||||
@@index([reviewTaskId, status])
|
||||
@@index([phoneNumber])
|
||||
@@index([gatewayMessageId])
|
||||
@@index([drainageInfoId, queuedAt])
|
||||
}
|
||||
|
||||
model CmppSubmitSession {
|
||||
@@ -1048,6 +1069,8 @@ model SmsSubmitRecord {
|
||||
sequenceId Int?
|
||||
gatewayMessageId String?
|
||||
submitStatus String @default("queued")
|
||||
costUnitPrice Int @default(0)
|
||||
costAmountCents Int @default(0)
|
||||
errorCode String?
|
||||
errorMessage String?
|
||||
submittedAt DateTime?
|
||||
@@ -1066,6 +1089,78 @@ model SmsSubmitRecord {
|
||||
@@index([gatewayMessageId])
|
||||
}
|
||||
|
||||
model DailyReconciliationReport {
|
||||
id String @id @default(cuid())
|
||||
reportDate DateTime @db.Date
|
||||
tenantId String
|
||||
tenantName String
|
||||
applicationId String
|
||||
applicationName String
|
||||
sentUnits Int @default(0)
|
||||
successUnits Int @default(0)
|
||||
generatedAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([reportDate, tenantId, applicationId])
|
||||
@@index([reportDate])
|
||||
@@index([tenantId, reportDate])
|
||||
@@index([applicationId, reportDate])
|
||||
}
|
||||
|
||||
model DailyProfitReport {
|
||||
id String @id @default(cuid())
|
||||
reportDate DateTime @db.Date
|
||||
dimensionType String
|
||||
dimensionId String
|
||||
dimensionName String
|
||||
tenantId String?
|
||||
tenantName String?
|
||||
applicationId String?
|
||||
channelId String?
|
||||
sentUnits Int @default(0)
|
||||
successUnits Int @default(0)
|
||||
revenueCents Int @default(0)
|
||||
costCents Int @default(0)
|
||||
profitCents Int @default(0)
|
||||
profitRateBps Int @default(0)
|
||||
generatedAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([reportDate, dimensionType, dimensionId])
|
||||
@@index([dimensionType, reportDate])
|
||||
@@index([tenantId, reportDate])
|
||||
@@index([applicationId, reportDate])
|
||||
@@index([channelId, reportDate])
|
||||
}
|
||||
|
||||
model DailyQualityReport {
|
||||
id String @id @default(cuid())
|
||||
reportDate DateTime @db.Date
|
||||
dimensionType String
|
||||
dimensionId String
|
||||
dimensionName String
|
||||
tenantId String?
|
||||
tenantName String?
|
||||
applicationId String?
|
||||
channelId String?
|
||||
signatureId String?
|
||||
drainageInfoId String?
|
||||
sentUnits Int @default(0)
|
||||
successUnits Int @default(0)
|
||||
successRateBps Int @default(0)
|
||||
avgArrivalMs Int?
|
||||
generatedAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([reportDate, dimensionType, dimensionId])
|
||||
@@index([dimensionType, reportDate, sentUnits])
|
||||
@@index([tenantId, reportDate])
|
||||
@@index([applicationId, reportDate])
|
||||
@@index([channelId, reportDate])
|
||||
@@index([signatureId, reportDate])
|
||||
@@index([drainageInfoId, reportDate])
|
||||
}
|
||||
|
||||
model SmsMessageSegmentAudit {
|
||||
id String @id @default(cuid())
|
||||
tenantId String?
|
||||
|
||||
Reference in New Issue
Block a user