- 将 rebate_limit 和 default_player_rebate 的校验范围从 0-1 改为 0-100 - 在服务层进行百分比与小数的转换(输入除以100,输出乘以100) - 更新相关测试用例以匹配新的百分比格式 - 新增 admin/docs/integration-guide 路由用于集成文档展示
38 lines
1.3 KiB
PHP
38 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Concerns;
|
|
|
|
use App\Support\AgentSettlementCycle;
|
|
|
|
trait AgentProfileFieldRules
|
|
{
|
|
/** @return array<string, mixed> */
|
|
protected function agentProfileFieldRules(): array
|
|
{
|
|
return [
|
|
'total_share_rate' => ['sometimes', 'numeric', 'min:0', 'max:100'],
|
|
'relative_share_rate' => ['sometimes', 'numeric', 'min:0', 'max:100'],
|
|
'credit_limit' => ['sometimes', 'integer', 'min:0'],
|
|
'rebate_limit' => ['sometimes', 'numeric', 'min:0', 'max:100'],
|
|
'default_player_rebate' => ['sometimes', 'numeric', 'min:0', 'max:100'],
|
|
'settlement_cycle' => ['sometimes', 'string', 'in:'.implode(',', AgentSettlementCycle::VALUES)],
|
|
'can_grant_extra_rebate' => ['sometimes', 'boolean'],
|
|
'can_create_child_agent' => ['sometimes', 'boolean'],
|
|
'can_create_player' => ['sometimes', 'boolean'],
|
|
'risk_tags' => ['sometimes', 'array'],
|
|
'risk_tags.*' => ['string', 'max:64'],
|
|
];
|
|
}
|
|
|
|
protected function prepareAgentProfileFieldsForValidation(): void
|
|
{
|
|
if (! $this->has('settlement_cycle')) {
|
|
return;
|
|
}
|
|
|
|
$this->merge([
|
|
'settlement_cycle' => AgentSettlementCycle::normalize($this->input('settlement_cycle')),
|
|
]);
|
|
}
|
|
}
|