Montify stores integration: multi-store connections, customer/order/transaction sync, webhooks

This commit is contained in:
2026-10-10 15:59:12 +03:30
parent fa3fe0d364
commit e82bd2b2df
18 changed files with 3712 additions and 0 deletions
+132
View File
@@ -134,6 +134,7 @@ export type OrgModuleKey =
| "sms_campaigns"
| "teams"
| "woocommerce"
| "montify"
| "voip"
| "reservations"
| "leads"
@@ -172,6 +173,7 @@ export const ORG_MODULE_KEYS: OrgModuleKey[] = [
"sms_campaigns",
"teams",
"woocommerce",
"montify",
"voip",
"reservations",
"conversations",
@@ -210,6 +212,7 @@ export const ORG_MODULE_LABELS: Record<OrgModuleKey, string> = {
sms_campaigns: "پیامک گروهی",
teams: "تیم‌ها و سطح دسترسی به پرونده‌ها",
woocommerce: "ووکامرس",
montify: "فروشگاه‌های مونتیفای",
voip: "تلفن سازمانی",
reservations: "رزرو و نوبت‌دهی",
conversations: "گفتگو",
@@ -254,6 +257,7 @@ export const ORG_MODULE_GROUPS: Array<{
"reports",
"saved_views",
"woocommerce",
"montify",
"voip",
"reservations",
],
@@ -803,6 +807,7 @@ export const PERSON_IMPORT_SOURCES = [
"excel",
"phone",
"lead_form",
"montify",
"other",
] as const;
export type PersonImportSource = (typeof PERSON_IMPORT_SOURCES)[number];
@@ -814,6 +819,7 @@ export const PERSON_IMPORT_SOURCE_LABELS: Record<PersonImportSource, string> = {
excel: "اکسل",
phone: "مخاطبین گوشی",
lead_form: "فرم لید",
montify: "فروشگاه مونتیفای",
other: "سایر",
};
@@ -4113,6 +4119,132 @@ export interface WooCommerceOrderLinkDto {
syncedAt: string;
}
/* ——— فروشگاه‌های Montify ——— */
export type MontifySyncStatus = "idle" | "running" | "ok" | "error";
export interface MontifySyncResultDto {
mode: "incremental" | "full";
customersFetched: number;
customersCreated: number;
customersUpdated: number;
ordersFetched: number;
transactionsFetched: number;
errors: string[];
startedAt: string;
finishedAt: string | null;
}
export interface MontifyConnectionDto {
id: string;
label: string;
baseUrl: string;
storeId: string;
tokenMasked: string;
enabled: boolean;
webhookRegistered: boolean;
webhookUrl: string;
syncStatus: MontifySyncStatus;
syncStartedAt: string | null;
lastSyncAt: string | null;
lastSyncResult: MontifySyncResultDto | null;
lastHealthAt: string | null;
lastHealthOk: boolean | null;
lastError: string | null;
lastWebhookAt: string | null;
linkedCustomers: number;
orders: number;
createdAt: string;
updatedAt: string;
}
export interface CreateMontifyConnectionRequest {
label: string;
baseUrl: string;
token: string;
storeId?: string;
enabled?: boolean;
}
export type UpdateMontifyConnectionRequest = Partial<CreateMontifyConnectionRequest>;
export interface MontifyTestResultDto {
ok: boolean;
totalCustomers: number | null;
}
export interface MontifyOrderItemDto {
productId: string | null;
productName: string | null;
qty: number | null;
price: number | null;
weight: number | null;
totalPrice: number | null;
}
/** سفارش فروشگاه — orderReference = code، orderStatus = sts */
export interface MontifyOrderDto {
id: string;
connectionId: string;
connectionLabel: string;
externalId: string;
customerExternalId: string | null;
personId: string | null;
personName: string | null;
orderReference: string | null;
orderStatus: string | null;
paymentStatus: string | null;
paymentType: string | null;
totalPrice: number | null;
discountTotalPrice: number | null;
totalDiscounts: number | null;
totalQty: number | null;
sumGold: number | null;
sumSilver: number | null;
note: string | null;
cancelReason: string | null;
cancelledAt: string | null;
closedAt: string | null;
items: MontifyOrderItemDto[];
createdAt: string | null;
updatedAt: string | null;
}
export interface MontifyTransactionDto {
id: string;
externalId: string;
type: string | null;
amount: number | null;
currency: string | null;
status: string | null;
referenceCode: string | null;
createdAt: string | null;
}
export interface MontifyEngagementDto {
saved: number;
likes: number;
comments: number;
}
/** پروفایل فروشگاهی یک شخص (wallet_balance / gold_wallet_balance طبق نگاشت مستند) */
export interface MontifyPersonStoreDto {
connectionId: string;
connectionLabel: string;
externalCustomerId: string;
fullName: string | null;
username: string | null;
customerType: string | null;
walletBalance: number | null;
goldWalletBalance: number | null;
totalOrders: number | null;
totalSpent: number | null;
engagement: MontifyEngagementDto | null;
orders: MontifyOrderDto[];
transactions: MontifyTransactionDto[];
syncedAt: string;
}
/* ——— تلفن سازمانی / VoIP ——— */
export type VoipCallDirection = "inbound" | "outbound";