forked from wangziqi/gongxue-base
feat: add tenant crm commission console
This commit is contained in:
@@ -234,6 +234,101 @@ export interface CodeBatchItem {
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface CrmConfigItem {
|
||||
id?: string;
|
||||
enabled?: boolean;
|
||||
url?: string | null;
|
||||
secretRef?: string | null;
|
||||
formName?: string | null;
|
||||
examType?: string | null;
|
||||
timeoutSec?: number;
|
||||
delaySec?: number;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface CrmQueueItem {
|
||||
id: string;
|
||||
recordId?: string | null;
|
||||
status?: string;
|
||||
scheduledAt?: string | null;
|
||||
attempts?: number;
|
||||
nextAttemptAt?: string | null;
|
||||
lastError?: string | null;
|
||||
lastHttpCode?: number | null;
|
||||
leadId?: string | null;
|
||||
sentAt?: string | null;
|
||||
source?: string | null;
|
||||
targetUrl?: string | null;
|
||||
payload?: Record<string, unknown>;
|
||||
createdAt?: string;
|
||||
}
|
||||
|
||||
export interface CommissionSettingsItem {
|
||||
defaultRate?: number | string;
|
||||
minSettlementCents?: number;
|
||||
settlementCycle?: string;
|
||||
config?: Record<string, unknown>;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface CommissionSummaryItem {
|
||||
tenantId?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
referrerUserId?: string | null;
|
||||
defaultRate?: number | string;
|
||||
minSettlementCents?: number;
|
||||
sourceCount?: number;
|
||||
paidUserCount?: number;
|
||||
grossAmountCents?: number;
|
||||
commissionAmountCents?: number;
|
||||
byReferrer?: Record<string, unknown>[];
|
||||
}
|
||||
|
||||
export interface CommissionOrderItem {
|
||||
sourceType?: string;
|
||||
sourceId?: string;
|
||||
sourceNo?: string | null;
|
||||
referrerUserId?: string;
|
||||
referrerName?: string | null;
|
||||
referrerPhone?: string | null;
|
||||
studentUserId?: string | null;
|
||||
studentName?: string | null;
|
||||
grossAmountCents?: number;
|
||||
commissionRate?: number | string;
|
||||
commissionAmountCents?: number;
|
||||
rateSource?: string;
|
||||
settlementId?: string | null;
|
||||
sourcePaidAt?: string | null;
|
||||
}
|
||||
|
||||
export interface CommissionSettlementItem {
|
||||
id: string;
|
||||
settlementNo?: string;
|
||||
referrerUserId?: string;
|
||||
referrerName?: string | null;
|
||||
referrerPhone?: string | null;
|
||||
status?: string;
|
||||
periodStart?: string;
|
||||
periodEnd?: string;
|
||||
sourceCount?: number;
|
||||
paidUserCount?: number;
|
||||
grossAmountCents?: number;
|
||||
commissionAmountCents?: number;
|
||||
defaultRate?: number | string;
|
||||
effectiveRate?: number | string;
|
||||
reviewedBy?: string | null;
|
||||
reviewedAt?: string | null;
|
||||
paidBy?: string | null;
|
||||
paidAt?: string | null;
|
||||
paymentMethod?: string | null;
|
||||
paymentAccount?: string | null;
|
||||
remark?: string | null;
|
||||
metadata?: Record<string, unknown>;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface TenantOverview {
|
||||
id?: string;
|
||||
name?: string;
|
||||
@@ -518,10 +613,95 @@ export async function disableTenantMember(membershipId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadCrmQueue(limit = 20) {
|
||||
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/crm/queue', { query: { limit } });
|
||||
export async function loadCrmConfig() {
|
||||
return apiRequest<{ item?: CrmConfigItem | null }>('/api/crm/config');
|
||||
}
|
||||
|
||||
export async function loadCommissionSummary() {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/commission/summary');
|
||||
export async function upsertCrmConfig(input: {
|
||||
enabled?: boolean;
|
||||
url?: string | null;
|
||||
secretRef?: string | null;
|
||||
formName?: string | null;
|
||||
examType?: string | null;
|
||||
timeoutSec?: number;
|
||||
delaySec?: number;
|
||||
}) {
|
||||
return apiRequest<{ item?: CrmConfigItem }>('/api/crm/config', {
|
||||
method: 'PUT',
|
||||
body: input,
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadCrmQueue(limit = 20, status?: string) {
|
||||
return apiRequest<{ items?: CrmQueueItem[] }>('/api/crm/queue', { query: { limit, status } });
|
||||
}
|
||||
|
||||
export async function loadCommissionSettings() {
|
||||
return apiRequest<{ item?: CommissionSettingsItem }>('/api/commission/settings');
|
||||
}
|
||||
|
||||
export async function updateCommissionSettings(input: {
|
||||
defaultRate: number;
|
||||
minSettlementCents?: number;
|
||||
settlementCycle?: string;
|
||||
config?: Record<string, unknown>;
|
||||
}) {
|
||||
return apiRequest<{ item?: CommissionSettingsItem }>('/api/commission/settings', {
|
||||
method: 'PUT',
|
||||
body: input,
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateMemberCommissionRate(input: {
|
||||
userId: string;
|
||||
commissionRate?: number | null;
|
||||
commissionConfig?: Record<string, unknown>;
|
||||
}) {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/commission/member-rate', {
|
||||
method: 'PUT',
|
||||
body: input,
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadCommissionSummary(query: { startDate?: string; endDate?: string; referrerUserId?: string } = {}) {
|
||||
return apiRequest<{ item?: CommissionSummaryItem }>('/api/commission/summary', { query });
|
||||
}
|
||||
|
||||
export async function loadCommissionOrders(query: { startDate?: string; endDate?: string; referrerUserId?: string; limit?: number } = {}) {
|
||||
return apiRequest<{ items?: CommissionOrderItem[]; scope?: Record<string, unknown> }>('/api/commission/orders', {
|
||||
query: { ...query, limit: query.limit || 50 },
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadCommissionSettlements(query: { status?: string; referrerUserId?: string; limit?: number } = {}) {
|
||||
return apiRequest<{ items?: CommissionSettlementItem[] }>('/api/commission/settlements', {
|
||||
query: { ...query, limit: query.limit || 50 },
|
||||
});
|
||||
}
|
||||
|
||||
export async function generateCommissionSettlement(input: {
|
||||
referrerUserId: string;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
status?: string;
|
||||
remark?: string | null;
|
||||
}) {
|
||||
return apiRequest<{ item?: CommissionSettlementItem & { items?: CommissionOrderItem[] } }>('/api/commission/settlements/generate', {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateCommissionSettlementStatus(input: {
|
||||
settlementId: string;
|
||||
status: string;
|
||||
paymentMethod?: string | null;
|
||||
paymentAccount?: string | null;
|
||||
remark?: string | null;
|
||||
metadata?: Record<string, unknown>;
|
||||
}) {
|
||||
return apiRequest<{ item?: CommissionSettlementItem }>('/api/commission/settlements/status', {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user