物流对账单

This commit is contained in:
2026-07-26 09:51:33 +08:00
parent 2b7ef65cce
commit 19cb312465
21 changed files with 1909 additions and 27 deletions
+90 -10
View File
@@ -226,6 +226,18 @@ enum FinancePayStatus {
PAID
}
// 物流承运商结算方式:前期充值,后期挂账月结
enum LogisticsSettlementMethod {
PREPAID
MONTHLY_CREDIT
}
enum LogisticsPrepaidLedgerType {
RECHARGE
DEDUCT
ADJUST
}
enum StoreStatus {
OPEN
PAUSED
@@ -674,22 +686,90 @@ model CommonCity {
}
model FulfillmentProvider {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
code String @unique @db.VarChar(32)
name String @db.VarChar(128)
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
code String @unique @db.VarChar(32)
name String @db.VarChar(128)
type FulfillmentProviderType
status FulfillmentProviderStatus @default(ACTIVE)
configJson String? @map("config_json") @db.Text
capabilitiesJson String? @map("capabilities_json") @db.Text
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
status FulfillmentProviderStatus @default(ACTIVE)
configJson String? @map("config_json") @db.Text
capabilitiesJson String? @map("capabilities_json") @db.Text
bankAccountName String? @map("bank_account_name") @db.VarChar(64)
bankName String? @map("bank_name") @db.VarChar(64)
bankBranch String? @map("bank_branch") @db.VarChar(128)
bankAccountNo String? @map("bank_account_no") @db.VarChar(64)
settlementMethod LogisticsSettlementMethod @default(PREPAID) @map("settlement_method")
pricingRulesJson String? @map("pricing_rules_json") @db.Text
prepaidBalance Decimal @default(0) @map("prepaid_balance") @db.Decimal(12, 2)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
warehouses CityWarehouse[]
deliveries OrderDelivery[]
warehouses CityWarehouse[]
deliveries OrderDelivery[]
logisticsBills LogisticsBill[]
prepaidLedgers LogisticsPrepaidLedger[]
@@map("common_fulfillment_provider")
}
// 物流对账月账单(按承运商汇总)
model LogisticsBill {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
billNo String @unique @map("bill_no") @db.VarChar(32)
fulfillmentProviderId BigInt @map("fulfillment_provider_id") @db.UnsignedBigInt
periodStart DateTime @map("period_start") @db.DateTime(3)
periodEnd DateTime @map("period_end") @db.DateTime(3)
orderCount Int @default(0) @map("order_count")
bottleCount Int @default(0) @map("bottle_count")
logisticsAmount Decimal @map("logistics_amount") @db.Decimal(12, 2)
settlementMethod LogisticsSettlementMethod @map("settlement_method")
pricingSnapshotJson String? @map("pricing_snapshot_json") @db.Text
status FinancePayStatus @default(UNPAID)
paidAt DateTime? @map("paid_at") @db.DateTime(3)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
fulfillmentProvider FulfillmentProvider @relation(fields: [fulfillmentProviderId], references: [id], onDelete: Restrict)
items LogisticsBillItem[]
prepaidLedgers LogisticsPrepaidLedger[]
@@unique([fulfillmentProviderId, periodStart])
@@index([status, periodStart])
@@map("logistics_bill")
}
model LogisticsBillItem {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
logisticsBillId BigInt @map("logistics_bill_id") @db.UnsignedBigInt
orderId BigInt @map("order_id") @db.UnsignedBigInt
orderNo String @map("order_no") @db.VarChar(32)
quantity Int
logisticsAmount Decimal @map("logistics_amount") @db.Decimal(10, 2)
shippedAt DateTime @map("shipped_at") @db.DateTime(3)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
logisticsBill LogisticsBill @relation(fields: [logisticsBillId], references: [id], onDelete: Cascade)
@@unique([logisticsBillId, orderId])
@@index([logisticsBillId])
@@map("logistics_bill_item")
}
model LogisticsPrepaidLedger {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
fulfillmentProviderId BigInt @map("fulfillment_provider_id") @db.UnsignedBigInt
type LogisticsPrepaidLedgerType
amount Decimal @db.Decimal(12, 2)
balanceAfter Decimal @map("balance_after") @db.Decimal(12, 2)
logisticsBillId BigInt? @map("logistics_bill_id") @db.UnsignedBigInt
remark String? @db.VarChar(256)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
fulfillmentProvider FulfillmentProvider @relation(fields: [fulfillmentProviderId], references: [id], onDelete: Restrict)
logisticsBill LogisticsBill? @relation(fields: [logisticsBillId], references: [id], onDelete: SetNull)
@@index([fulfillmentProviderId, createdAt])
@@map("logistics_prepaid_ledger")
}
model CityWarehouse {
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
cityId BigInt @map("city_id") @db.UnsignedBigInt