- 在多个控制器中更新权限检查逻辑,确保管理员能够更灵活地管理代理和玩家。 - 在 AdminPlayerStoreController 中引入对玩家创建能力的验证,确保只有具备相应权限的管理员能够创建玩家。 - 更新请求验证逻辑,新增 credit_limit、rebate_rate 和 extra_rebate_rate 字段,以支持更细粒度的玩家管理。 - 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。 - 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义,提升代码复用性。
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services\AgentSettlement;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
final class AgentSettlementBillGuard
|
|
{
|
|
private const LOCKED_STATUSES = ['confirmed', 'partial_paid', 'settled', 'overdue', 'reversed'];
|
|
|
|
public function __construct(
|
|
private readonly AgentSettlementPeriodCompletionService $periodCompletion,
|
|
) {}
|
|
|
|
public function assertPeriodMutable(int $billId): void
|
|
{
|
|
$periodId = (int) DB::table('settlement_bills')->where('id', $billId)->value('settlement_period_id');
|
|
if ($this->periodCompletion->isPeriodReadOnly($periodId)) {
|
|
throw ValidationException::withMessages([
|
|
'period' => ['completed'],
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function assertNetAmountMutable(int $billId): void
|
|
{
|
|
$bill = DB::table('settlement_bills')->where('id', $billId)->first();
|
|
if ($bill === null) {
|
|
return;
|
|
}
|
|
|
|
if (in_array((string) $bill->status, self::LOCKED_STATUSES, true) || $bill->locked_at !== null) {
|
|
throw ValidationException::withMessages([
|
|
'bill' => ['locked'],
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function markConfirmed(int $billId): void
|
|
{
|
|
$this->assertPeriodMutable($billId);
|
|
|
|
DB::table('settlement_bills')->where('id', $billId)->update([
|
|
'status' => 'confirmed',
|
|
'locked_at' => now(),
|
|
'confirmed_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
}
|
|
}
|