Add WooCommerce integration: sync orders to invoices/people with webhook, cron, and settings UI.
This commit is contained in:
@@ -198,6 +198,7 @@ model Organization {
|
||||
apiKeys OrganizationApiKey[]
|
||||
webhookEndpoints WebhookEndpoint[]
|
||||
smsCampaigns SmsCampaign[]
|
||||
wooCommerceConnections WooCommerceConnection[]
|
||||
}
|
||||
|
||||
model User {
|
||||
@@ -1729,3 +1730,53 @@ model SmsCampaignRecipient {
|
||||
|
||||
@@index([campaignId, status])
|
||||
}
|
||||
|
||||
/// اتصال فروشگاه ووکامرس
|
||||
model WooCommerceConnection {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
label String
|
||||
storeUrl String
|
||||
consumerKeyCiphertext String
|
||||
consumerKeyIv String
|
||||
consumerKeyTag String
|
||||
consumerKeyLast4 String @default("")
|
||||
consumerSecretCiphertext String
|
||||
consumerSecretIv String
|
||||
consumerSecretTag String
|
||||
webhookSecretCiphertext String?
|
||||
webhookSecretIv String?
|
||||
webhookSecretTag String?
|
||||
enabled Boolean @default(true)
|
||||
lastSyncAt DateTime?
|
||||
lastHealthAt DateTime?
|
||||
lastHealthOk Boolean?
|
||||
lastError String?
|
||||
orders WooCommerceOrderLink[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([organizationId, enabled])
|
||||
}
|
||||
|
||||
model WooCommerceOrderLink {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
connectionId String
|
||||
connection WooCommerceConnection @relation(fields: [connectionId], references: [id], onDelete: Cascade)
|
||||
wooOrderId String
|
||||
wooOrderNumber String?
|
||||
invoiceId String
|
||||
status String @default("")
|
||||
total Decimal @default(0) @db.Decimal(18, 2)
|
||||
currency String @default("IRR")
|
||||
rawPayload Json?
|
||||
syncedAt DateTime @default(now())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([connectionId, wooOrderId])
|
||||
@@index([organizationId, syncedAt])
|
||||
@@index([invoiceId])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user