feat: enhance player authentication and agent management features
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
- Updated AGENTS.md to clarify player interface bindings and agent account restrictions. - Improved PlayerAuthLoginController to include captcha verification for player login. - Enhanced AdminPlayerIndexController with permission checks for admin users. - Refactored AdminPlayerStoreController to enforce agent node restrictions for non-super admins. - Introduced new error codes for player authentication failures and updated related services. - Enhanced validation rules for agent profiles to include settlement cycle options. - Improved AdminCaptchaService to support separate scopes for admin and player captcha handling. - Updated various services to ensure proper credit management and settlement processes.
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Services\Agent;
|
||||
|
||||
use App\Models\AgentNode;
|
||||
use App\Models\AgentProfile;
|
||||
use App\Support\PlayerFundingMode;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,7 @@ final class AgentCreditAllocatedSyncService
|
||||
$playerTotal = (int) DB::table('player_credit_accounts as pca')
|
||||
->join('players as p', 'p.id', '=', 'pca.player_id')
|
||||
->where('p.agent_node_id', $agent->id)
|
||||
->where('p.funding_mode', PlayerFundingMode::CREDIT)
|
||||
->sum('pca.credit_limit');
|
||||
|
||||
$childIds = AgentNode::query()->where('parent_id', $agent->id)->pluck('id');
|
||||
|
||||
@@ -40,6 +40,12 @@ final class AgentProfileService
|
||||
$defaultRebate = array_key_exists('default_player_rebate', $payload)
|
||||
? (float) $payload['default_player_rebate'] / 100
|
||||
: (float) ($existingProfile->default_player_rebate ?? 0);
|
||||
$settlementCycle = array_key_exists('settlement_cycle', $payload)
|
||||
? (string) $payload['settlement_cycle']
|
||||
: (string) ($existingProfile->settlement_cycle ?? config('agent_line_defaults.settlement_cycle', 'weekly'));
|
||||
if ($settlementCycle === '') {
|
||||
$settlementCycle = 'weekly';
|
||||
}
|
||||
|
||||
$useRelative = $parent !== null && array_key_exists('relative_share_rate', $payload);
|
||||
|
||||
@@ -59,7 +65,7 @@ final class AgentProfileService
|
||||
);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($node, $payload, $parent, $totalShare, $creditLimit, $rebateLimit, $defaultRebate): AgentProfile {
|
||||
return DB::transaction(function () use ($node, $payload, $parent, $totalShare, $creditLimit, $rebateLimit, $defaultRebate, $settlementCycle): AgentProfile {
|
||||
$profile = AgentProfile::query()->firstOrNew(['agent_node_id' => $node->id]);
|
||||
$previousCredit = (int) $profile->credit_limit;
|
||||
$isNew = ! $profile->exists;
|
||||
@@ -104,6 +110,7 @@ final class AgentProfileService
|
||||
'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)),
|
||||
'settlement_cycle' => $settlementCycle,
|
||||
]);
|
||||
if (! $profile->exists) {
|
||||
$profile->allocated_credit = 0;
|
||||
@@ -141,6 +148,7 @@ final class AgentProfileService
|
||||
'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,
|
||||
'settlement_cycle' => (string) ($profile->settlement_cycle ?? 'weekly'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user