feat(core): harden sessions settlement and credit activity
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
|
||||
use App\Models\AuditLog;
|
||||
use App\Models\AdminUser;
|
||||
use App\Support\AuditLogApiPresenter;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Services\AuditLogger;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Services\AuditLogger;
|
||||
use App\Support\AuditLogApiPresenter;
|
||||
use App\Services\Agent\AgentNodeService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
@@ -36,6 +37,24 @@ test('audit log presenter maps business action and entity target', function ():
|
||||
->and($payload['summary_label'])->toBe('代理管理 · 同步代理角色权限(角色 #5)');
|
||||
});
|
||||
|
||||
test('audit log presenter translates automatic payout failures', function (): void {
|
||||
$row = new AuditLog([
|
||||
'operator_type' => 'system',
|
||||
'operator_id' => 0,
|
||||
'module_code' => 'settlement',
|
||||
'action_code' => 'auto_payout_failed',
|
||||
'target_type' => 'settlement_batch',
|
||||
'target_id' => '1107',
|
||||
]);
|
||||
$row->id = 2;
|
||||
|
||||
$payload = AuditLogApiPresenter::row($row);
|
||||
|
||||
expect($payload['action_label'])->toBe('自动派彩失败')
|
||||
->and($payload['target_label'])->toBe('结算批次 #1107')
|
||||
->and($payload['summary_label'])->toBe('派彩结算 · 自动派彩失败(结算批次 #1107)');
|
||||
});
|
||||
|
||||
test('audit log presenter uses admin api resource name for middleware style rows', function (): void {
|
||||
$resourceName = (string) DB::table('admin_api_resources')
|
||||
->where('code', 'admin.agent-roles.permissions.sync')
|
||||
@@ -63,7 +82,7 @@ test('audit log presenter uses admin api resource name for middleware style rows
|
||||
test('agent role permission sync records one business audit and skips middleware duplicate', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
|
||||
$service = app(\App\Services\Agent\AgentNodeService::class);
|
||||
$service = app(AgentNodeService::class);
|
||||
|
||||
$super = AdminUser::query()->create([
|
||||
'username' => 'audit_dedup_super',
|
||||
|
||||
Reference in New Issue
Block a user