feat: 增强代理节点和代理资料管理功能
- 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。 - 更新多个请求类,统一代理资料字段的验证逻辑,提升代码复用性。 - 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义。 - 在 AgentProfile 模型中设置主键为 agent_node_id,确保与代理节点的关联性。 - 更新错误信息,增加对授信额度和占成比例的验证,确保数据一致性。
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\AdminUser;
|
||||
use App\Models\AgentNode;
|
||||
use App\Models\AgentProfile;
|
||||
use App\Support\AdminAgentScope;
|
||||
use App\Support\AgentSettlementCycle;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
@@ -38,6 +39,12 @@ final class AgentProfileService
|
||||
$previousCredit = (int) $profile->credit_limit;
|
||||
$isNew = ! $profile->exists;
|
||||
|
||||
if (! $isNew && $creditLimit < (int) $profile->allocated_credit) {
|
||||
throw ValidationException::withMessages([
|
||||
'credit_limit' => ['below_allocated'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($parent !== null) {
|
||||
$delta = $isNew ? $creditLimit : max(0, $creditLimit - $previousCredit);
|
||||
if ($delta > 0) {
|
||||
@@ -56,7 +63,9 @@ final class AgentProfileService
|
||||
'credit_limit' => $creditLimit,
|
||||
'rebate_limit' => $rebateLimit,
|
||||
'default_player_rebate' => $defaultRebate,
|
||||
'settlement_cycle' => (string) ($payload['settlement_cycle'] ?? $profile->settlement_cycle ?? 'weekly'),
|
||||
'settlement_cycle' => AgentSettlementCycle::normalize(
|
||||
$payload['settlement_cycle'] ?? $profile->settlement_cycle ?? 'weekly',
|
||||
),
|
||||
'can_grant_extra_rebate' => (bool) ($payload['can_grant_extra_rebate'] ?? $profile->can_grant_extra_rebate ?? false),
|
||||
'can_create_child_agent' => (bool) ($payload['can_create_child_agent'] ?? ($isNew ? false : $profile->can_create_child_agent)),
|
||||
'can_create_player' => (bool) ($payload['can_create_player'] ?? ($isNew ? true : $profile->can_create_player ?? true)),
|
||||
@@ -98,7 +107,7 @@ final class AgentProfileService
|
||||
'available_credit' => $available,
|
||||
'rebate_limit' => (float) $profile->rebate_limit,
|
||||
'default_player_rebate' => (float) $profile->default_player_rebate,
|
||||
'settlement_cycle' => (string) $profile->settlement_cycle,
|
||||
'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,
|
||||
'can_create_player' => (bool) $profile->can_create_player,
|
||||
|
||||
Reference in New Issue
Block a user