feat(agents, i18n): enhance agent management and settlement features with new translations and UI updates
Added new translations for agent management and settlement features in English, Nepali, and Chinese, improving multi-language support. Updated the agents console to reflect changes in funding modes and player details, enhancing user experience. Refactored the admin permission gate to include new logic for handling bound line agents, ensuring better permission management. Additionally, streamlined the UI for agent-related pages and improved navigation to the settlement center, consolidating related functionalities for better accessibility.
This commit is contained in:
287
src/api/admin-agent-settlement.ts
Normal file
287
src/api/admin-agent-settlement.ts
Normal file
@@ -0,0 +1,287 @@
|
||||
import { adminRequest } from "@/lib/admin-http";
|
||||
|
||||
const A = `/admin`;
|
||||
|
||||
export type SettlementPeriodSummary = {
|
||||
player_bills: number;
|
||||
agent_bills: number;
|
||||
adjustment_bills: number;
|
||||
pending_confirm: number;
|
||||
awaiting_payment: number;
|
||||
settled: number;
|
||||
total_unpaid: number;
|
||||
};
|
||||
|
||||
export type SettlementPeriodPipeline = {
|
||||
credit_ledger_count: number;
|
||||
share_ledger_count: number;
|
||||
};
|
||||
|
||||
export type SettlementPeriodRow = {
|
||||
id: number;
|
||||
admin_site_id: number;
|
||||
period_start: string;
|
||||
period_end: string;
|
||||
status: string;
|
||||
summary?: SettlementPeriodSummary;
|
||||
pipeline?: SettlementPeriodPipeline;
|
||||
};
|
||||
|
||||
export type AgentSettlementReportType =
|
||||
| "summary"
|
||||
| "player_win_loss"
|
||||
| "agent_share"
|
||||
| "rebate"
|
||||
| "credit"
|
||||
| "unpaid_bills"
|
||||
| "overdue"
|
||||
| "platform_pnl"
|
||||
| "draw_period";
|
||||
|
||||
export type SettlementBillRow = {
|
||||
id: number;
|
||||
settlement_period_id: number;
|
||||
bill_type: string;
|
||||
owner_type: string;
|
||||
owner_id: number;
|
||||
counterparty_type: string;
|
||||
counterparty_id: number;
|
||||
gross_win_loss?: number;
|
||||
rebate_amount?: number;
|
||||
platform_rounding_adjustment?: number;
|
||||
net_amount: number;
|
||||
unpaid_amount: number;
|
||||
paid_amount: number;
|
||||
status: string;
|
||||
owner_label?: string;
|
||||
counterparty_label?: string;
|
||||
owner_funding_mode?: string | null;
|
||||
owner_auth_source?: string | null;
|
||||
period_start?: string;
|
||||
period_end?: string;
|
||||
admin_site_id?: number;
|
||||
meta_json?: string | Record<string, unknown> | null;
|
||||
};
|
||||
|
||||
export async function getSettlementPeriods(params?: {
|
||||
admin_site_id?: number;
|
||||
}): Promise<{ items: SettlementPeriodRow[] }> {
|
||||
return adminRequest.get(`${A}/settlement-periods`, { params });
|
||||
}
|
||||
|
||||
export async function postSettlementPeriod(body: {
|
||||
admin_site_id: number;
|
||||
period_start: string;
|
||||
period_end: string;
|
||||
}): Promise<SettlementPeriodRow> {
|
||||
return adminRequest.post(`${A}/settlement-periods`, body);
|
||||
}
|
||||
|
||||
export type SettlementPeriodCloseResult = {
|
||||
period_id: number;
|
||||
unsettled_ticket_count?: number;
|
||||
player_count?: number;
|
||||
};
|
||||
|
||||
export async function postSettlementPeriodClose(
|
||||
periodId: number,
|
||||
): Promise<SettlementPeriodCloseResult> {
|
||||
return adminRequest.post(`${A}/settlement-periods/${periodId}/close`);
|
||||
}
|
||||
|
||||
export async function postSettlementBillBadDebtWriteOff(
|
||||
billId: number,
|
||||
body?: { reason?: string },
|
||||
): Promise<{ original_bill_id: number; bad_debt_bill_id: number; bill: SettlementBillRow }> {
|
||||
return adminRequest.post(`${A}/settlement-bills/${billId}/bad-debt-write-off`, body ?? {});
|
||||
}
|
||||
|
||||
export type SettlementBillListScope =
|
||||
| "pending_confirm"
|
||||
| "awaiting_payment"
|
||||
| "settled"
|
||||
| "adjustment";
|
||||
|
||||
export async function getSettlementBills(params?: {
|
||||
settlement_period_id?: number;
|
||||
admin_site_id?: number;
|
||||
bill_type?: string;
|
||||
scope?: SettlementBillListScope;
|
||||
}): Promise<{ items: SettlementBillRow[] }> {
|
||||
return adminRequest.get(`${A}/settlement-bills`, { params });
|
||||
}
|
||||
|
||||
export type SettlementPaymentRow = {
|
||||
id: number;
|
||||
settlement_bill_id: number;
|
||||
payer_type: string;
|
||||
payer_id: number;
|
||||
payee_type: string;
|
||||
payee_id: number;
|
||||
amount: number;
|
||||
method: string | null;
|
||||
proof?: string | null;
|
||||
remark?: string | null;
|
||||
status: string;
|
||||
bill_type: string;
|
||||
owner_type: string;
|
||||
owner_id: number;
|
||||
period_start?: string;
|
||||
period_end?: string;
|
||||
confirmed_at?: string | null;
|
||||
created_at?: string;
|
||||
};
|
||||
|
||||
export async function getSettlementPayments(params?: {
|
||||
settlement_period_id?: number;
|
||||
admin_site_id?: number;
|
||||
}): Promise<{ items: SettlementPaymentRow[] }> {
|
||||
return adminRequest.get(`${A}/settlement-payments`, { params });
|
||||
}
|
||||
|
||||
export type SettlementAdjustmentRow = {
|
||||
id: number;
|
||||
settlement_period_id: number | null;
|
||||
original_bill_id: number | null;
|
||||
adjustment_type: string;
|
||||
amount: number;
|
||||
reason: string | null;
|
||||
created_by: number | null;
|
||||
period_start?: string;
|
||||
period_end?: string;
|
||||
original_bill_type?: string | null;
|
||||
original_owner_type?: string | null;
|
||||
original_owner_id?: number | null;
|
||||
created_at?: string;
|
||||
};
|
||||
|
||||
export async function getSettlementAdjustments(params?: {
|
||||
settlement_period_id?: number;
|
||||
admin_site_id?: number;
|
||||
adjustment_type?: string;
|
||||
}): Promise<{ items: SettlementAdjustmentRow[] }> {
|
||||
return adminRequest.get(`${A}/settlement-adjustments`, { params });
|
||||
}
|
||||
|
||||
export type SettlementLedgerRow = {
|
||||
entry_kind: "credit" | "payment" | "adjustment";
|
||||
id: number;
|
||||
row_key?: string;
|
||||
txn_no: string;
|
||||
player_id: number;
|
||||
site_code?: string;
|
||||
site_player_id?: string | null;
|
||||
username?: string | null;
|
||||
nickname?: string | null;
|
||||
biz_type: string;
|
||||
type?: string;
|
||||
biz_no?: string | null;
|
||||
direction: number;
|
||||
amount: number;
|
||||
amount_formatted?: string;
|
||||
signed_amount?: number;
|
||||
currency_code?: string;
|
||||
status: string;
|
||||
created_at?: string | null;
|
||||
ledger_source: string;
|
||||
funding_mode?: string;
|
||||
auth_source?: string | null;
|
||||
settlement_bill_id?: number | null;
|
||||
bill_status?: string | null;
|
||||
bill_type?: string | null;
|
||||
bill_unpaid_amount?: number | null;
|
||||
available_actions?: string[];
|
||||
};
|
||||
|
||||
/** @deprecated Use {@link SettlementLedgerRow} */
|
||||
export type CreditLedgerRow = SettlementLedgerRow;
|
||||
|
||||
export async function getCreditLedger(params?: {
|
||||
admin_site_id?: number;
|
||||
settlement_period_id?: number;
|
||||
player_id?: number;
|
||||
player_account?: string;
|
||||
txn_no?: string;
|
||||
reason?: string;
|
||||
biz_type?: string;
|
||||
entry_kind?: string;
|
||||
bill_status?: string;
|
||||
actionable_only?: boolean;
|
||||
bad_debt_only?: boolean;
|
||||
created_from?: string;
|
||||
created_to?: string;
|
||||
page?: number;
|
||||
per_page?: number;
|
||||
}): Promise<{
|
||||
items: SettlementLedgerRow[];
|
||||
total: number;
|
||||
page: number;
|
||||
per_page: number;
|
||||
ledger_source: string;
|
||||
}> {
|
||||
return adminRequest.get(`${A}/credit-ledger`, { params });
|
||||
}
|
||||
|
||||
export type RebateAllocationRow = {
|
||||
id: number;
|
||||
rebate_record_id: number;
|
||||
participant_type: string;
|
||||
participant_id: number;
|
||||
actual_share_rate: number;
|
||||
allocated_amount: number;
|
||||
allocation_rule: string;
|
||||
};
|
||||
|
||||
export type SettlementPaymentRow = {
|
||||
id: number;
|
||||
amount: number;
|
||||
status: string;
|
||||
method?: string | null;
|
||||
proof?: string | null;
|
||||
remark?: string | null;
|
||||
};
|
||||
|
||||
export async function getSettlementBill(billId: number): Promise<{
|
||||
bill: SettlementBillRow;
|
||||
payments: SettlementPaymentRow[];
|
||||
rebate_allocations: RebateAllocationRow[];
|
||||
adjustments: Array<{ id: number; amount: number; adjustment_type: string; reason: string | null }>;
|
||||
tier_edge?: string | null;
|
||||
}> {
|
||||
return adminRequest.get(`${A}/settlement-bills/${billId}`);
|
||||
}
|
||||
|
||||
export async function postSettlementBillConfirm(billId: number): Promise<{ bill_id: number; status: string }> {
|
||||
return adminRequest.post(`${A}/settlement-bills/${billId}/confirm`);
|
||||
}
|
||||
|
||||
export async function postSettlementBillPayment(
|
||||
billId: number,
|
||||
body: { amount: number; method?: string; proof?: string; remark?: string },
|
||||
): Promise<{ bill: SettlementBillRow }> {
|
||||
return adminRequest.post(`${A}/settlement-bills/${billId}/payments`, body);
|
||||
}
|
||||
|
||||
export type AgentSettlementReportResponse = {
|
||||
type: string;
|
||||
settlement_period_id: number | null;
|
||||
period_start: string;
|
||||
period_end: string;
|
||||
data: unknown;
|
||||
footnote: string | null;
|
||||
};
|
||||
|
||||
export async function getAgentSettlementReport(params: {
|
||||
type: AgentSettlementReportType;
|
||||
settlement_period_id?: number;
|
||||
admin_site_id?: number;
|
||||
}): Promise<AgentSettlementReportResponse> {
|
||||
return adminRequest.get<AgentSettlementReportResponse>(`${A}/settlement-reports`, { params });
|
||||
}
|
||||
|
||||
export async function postSettlementBillAdjustment(
|
||||
billId: number,
|
||||
body: { amount: number; adjustment_type?: "adjustment" | "reversal"; reason?: string },
|
||||
): Promise<{ adjustment_bill_id: number; bill: SettlementBillRow }> {
|
||||
return adminRequest.post(`${A}/settlement-bills/${billId}/adjustments`, body);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import type {
|
||||
AdminIntegrationSiteListData,
|
||||
AdminIntegrationSiteParameterSheet,
|
||||
AdminIntegrationSiteUpdatePayload,
|
||||
AdminIntegrationSiteSecrets,
|
||||
AdminIntegrationSiteWithSecrets,
|
||||
} from "@/types/api/admin-integration-site";
|
||||
|
||||
@@ -63,3 +64,9 @@ export async function getAdminIntegrationSiteExport(
|
||||
);
|
||||
}
|
||||
|
||||
export async function getAdminIntegrationSiteSecrets(
|
||||
id: number,
|
||||
): Promise<AdminIntegrationSiteSecrets> {
|
||||
return adminRequest.get<AdminIntegrationSiteSecrets>(`${A}/integration-sites/${id}/secrets`);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
AdminUserPermissionListData,
|
||||
AdminUserPermissionRow,
|
||||
AdminUserRoleSyncData,
|
||||
AdminUserRoleSyncPayload,
|
||||
AdminUserUpdatePayload,
|
||||
} from "@/types/api/admin-user";
|
||||
|
||||
@@ -81,9 +82,7 @@ export async function putAdminRolePermissions(
|
||||
|
||||
export async function putAdminUserRoles(
|
||||
adminUserId: number,
|
||||
roleSlugs: string[],
|
||||
body: AdminUserRoleSyncPayload,
|
||||
): Promise<AdminUserRoleSyncData> {
|
||||
return adminRequest.put<AdminUserRoleSyncData>(`${A}/admin-users/${adminUserId}/roles`, {
|
||||
role_slugs: roleSlugs,
|
||||
});
|
||||
return adminRequest.put<AdminUserRoleSyncData>(`${A}/admin-users/${adminUserId}/roles`, body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user