refactor: 调整返点字段为百分比格式并新增集成指南路由

- 将 rebate_limit 和 default_player_rebate 的校验范围从 0-1 改为 0-100
- 在服务层进行百分比与小数的转换(输入除以100,输出乘以100)
- 更新相关测试用例以匹配新的百分比格式
- 新增 admin/docs/integration-guide 路由用于集成文档展示
This commit is contained in:
2026-06-11 09:23:16 +08:00
parent 1d13d19b65
commit 4d1c2b3d63
5 changed files with 457 additions and 11 deletions

View File

@@ -29,8 +29,8 @@ final class AgentProfileService
$totalShare = (float) ($payload['total_share_rate'] ?? 0);
$creditLimit = (int) ($payload['credit_limit'] ?? 0);
$rebateLimit = (float) ($payload['rebate_limit'] ?? 0);
$defaultRebate = (float) ($payload['default_player_rebate'] ?? 0);
$rebateLimit = (float) ($payload['rebate_limit'] ?? 0) / 100;
$defaultRebate = (float) ($payload['default_player_rebate'] ?? 0) / 100;
$useRelative = $parent !== null && array_key_exists('relative_share_rate', $payload);
@@ -124,8 +124,8 @@ final class AgentProfileService
'allocated_credit' => (int) $profile->allocated_credit,
'used_credit' => (int) $profile->used_credit,
'available_credit' => $available,
'rebate_limit' => (float) $profile->rebate_limit,
'default_player_rebate' => (float) $profile->default_player_rebate,
'rebate_limit' => round((float) $profile->rebate_limit * 100, 4),
'default_player_rebate' => round((float) $profile->default_player_rebate * 100, 4),
'settlement_cycle' => AgentSettlementCycle::normalize($profile->settlement_cycle),
'can_grant_extra_rebate' => (bool) $profile->can_grant_extra_rebate,
'can_create_child_agent' => (bool) $profile->can_create_child_agent,
@@ -157,7 +157,7 @@ final class AgentProfileService
return [
'agent_node_id' => (int) $parent->id,
'total_share_rate' => (float) $profile->total_share_rate,
'rebate_limit' => (float) $profile->rebate_limit,
'rebate_limit' => round((float) $profile->rebate_limit * 100, 4),
'available_credit' => max(0, (int) $profile->credit_limit - (int) $profile->allocated_credit),
];
}