feat: 手动充值、邀请码注册与后台管理增强
新增玩家手动充值全流程(收款方式配置、充值下单/审核、钱包上分), 支持邀请码注册、邀请历史与专属返水率;完善后台代理/玩家管理与响应式操作栏, 并补充前台注册、充值页及多语言错误码。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,6 +7,15 @@ export const AGENT_SUSPEND_FREEZE_DIRECT_PLAYERS = 'agent.suspend_freeze_direct_
|
||||
export const AGENT_SUSPEND_BLOCK_PLAYER_LOGIN = 'agent.suspend_block_player_login';
|
||||
export const AGENT_MAX_LEVEL = 'agent.max_level';
|
||||
export const AGENT_DEFAULT_SUB_CREDIT_RATIO = 'agent.default_sub_credit_ratio';
|
||||
export const CASHBACK_PLATFORM_DIRECT_RATE = 'cashback.platform_direct_rate';
|
||||
export const CASHBACK_ADMIN_INVITE_RATE = 'cashback.admin_invite_rate';
|
||||
|
||||
export type PlatformDirectCashbackSettings = {
|
||||
/** 平台直属玩家默认返水比例(小数,0.01 = 1%) */
|
||||
platformDirectRate: number;
|
||||
/** 管理员邀请注册玩家返水比例;未配置时与 platformDirectRate 相同 */
|
||||
adminInviteRate: number;
|
||||
};
|
||||
|
||||
export type AgentHierarchySettings = {
|
||||
/** 最大代理层级;0 = 不限制 */
|
||||
@@ -155,4 +164,62 @@ export class SystemConfigService {
|
||||
}
|
||||
return this.getAgentHierarchySettings();
|
||||
}
|
||||
|
||||
async getDecimalRate(key: string, defaultValue = 0): Promise<number> {
|
||||
const row = await this.prisma.systemConfig.findUnique({ where: { configKey: key } });
|
||||
if (!row) return defaultValue;
|
||||
const parsed = parseFloat(row.configValue);
|
||||
return Number.isFinite(parsed) && parsed >= 0 ? parsed : defaultValue;
|
||||
}
|
||||
|
||||
async setDecimalRate(key: string, value: number, description?: string) {
|
||||
const safe = Math.max(0, value);
|
||||
await this.prisma.systemConfig.upsert({
|
||||
where: { configKey: key },
|
||||
create: {
|
||||
configKey: key,
|
||||
configValue: String(safe),
|
||||
description,
|
||||
},
|
||||
update: { configValue: String(safe) },
|
||||
});
|
||||
}
|
||||
|
||||
async getPlatformDirectCashbackSettings(): Promise<PlatformDirectCashbackSettings> {
|
||||
const platformDirectRate = await this.getDecimalRate(CASHBACK_PLATFORM_DIRECT_RATE, 0);
|
||||
const adminInviteConfigured = await this.prisma.systemConfig.findUnique({
|
||||
where: { configKey: CASHBACK_ADMIN_INVITE_RATE },
|
||||
});
|
||||
const adminInviteRate = adminInviteConfigured
|
||||
? await this.getDecimalRate(CASHBACK_ADMIN_INVITE_RATE, platformDirectRate)
|
||||
: platformDirectRate;
|
||||
return { platformDirectRate, adminInviteRate };
|
||||
}
|
||||
|
||||
async updatePlatformDirectCashbackSettings(data: {
|
||||
platformDirectRate?: number;
|
||||
adminInviteRate?: number;
|
||||
}) {
|
||||
if (data.platformDirectRate !== undefined) {
|
||||
if (!Number.isFinite(data.platformDirectRate) || data.platformDirectRate < 0) {
|
||||
throw new Error('platformDirectRate must be a non-negative number');
|
||||
}
|
||||
await this.setDecimalRate(
|
||||
CASHBACK_PLATFORM_DIRECT_RATE,
|
||||
data.platformDirectRate,
|
||||
'平台直属玩家默认返水比例(小数,如 0.01 = 1%)',
|
||||
);
|
||||
}
|
||||
if (data.adminInviteRate !== undefined) {
|
||||
if (!Number.isFinite(data.adminInviteRate) || data.adminInviteRate < 0) {
|
||||
throw new Error('adminInviteRate must be a non-negative number');
|
||||
}
|
||||
await this.setDecimalRate(
|
||||
CASHBACK_ADMIN_INVITE_RATE,
|
||||
data.adminInviteRate,
|
||||
'管理员邀请注册玩家返水比例(小数,如 0.01 = 1%)',
|
||||
);
|
||||
}
|
||||
return this.getPlatformDirectCashbackSettings();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user