feat: enhance reconciliation job processing and reporting features

- Updated ReconcileItemIndexController to include admin user validation and improved transfer order handling.
- Refactored ReconcileJobStoreController to ensure date range handling is more precise with start and end of day adjustments.
- Enhanced various report controllers to include currency code in responses for better financial clarity.
- Introduced new methods in AdminReconcileJobService for wallet transfer job creation and improved item scanning logic.
- Added wallet lookup idempotent path configuration for integration services to enhance API interactions.
This commit is contained in:
2026-06-16 13:50:55 +08:00
parent 606ed6817e
commit 1e7b2b31ee
21 changed files with 886 additions and 71 deletions

View File

@@ -10,12 +10,17 @@ use Illuminate\Http\Request;
use App\Models\ReconcileItem;
use App\Services\AuditLogger;
use Illuminate\Support\Facades\DB;
use App\Services\Wallet\WalletTransferReconcileDetector;
/**
* 对账任务:落库 `reconcile_jobs` / `reconcile_items`(阶段 7;差异引擎可后续替换)
* 对账任务:落库 `reconcile_jobs` / `reconcile_items`
*/
final class AdminReconcileJobService
{
public function __construct(
private readonly WalletTransferReconcileDetector $detector,
) {}
/**
* @param list<array{side_a_ref?: ?string, side_b_ref?: ?string, difference_amount?: int, status?: string}>|null $items
*/
@@ -26,7 +31,12 @@ final class AdminReconcileJobService
?Carbon $periodStart,
?Carbon $periodEnd,
?array $items,
?int $playerId = null,
): ReconcileJob {
if ($reconcileType === 'wallet_transfer' && $items === null) {
return $this->createWalletTransferScanJob($admin, $request, $periodStart, $periodEnd, $playerId);
}
return DB::transaction(function () use ($admin, $request, $reconcileType, $periodStart, $periodEnd, $items): ReconcileJob {
$jobNo = 'REC'.now()->format('YmdHis').strtoupper(Str::random(4));
@@ -81,4 +91,44 @@ final class AdminReconcileJobService
return $job->fresh();
});
}
private function createWalletTransferScanJob(
AdminUser $admin,
Request $request,
?Carbon $periodStart,
?Carbon $periodEnd,
?int $playerId,
): ReconcileJob {
$periodEnd ??= now()->endOfDay();
$periodStart ??= $periodEnd->copy()->startOfDay();
[$items] = $this->detector->scanItems(
$periodStart,
$periodEnd,
limit: 1000,
staleMinutes: 15,
playerId: $playerId,
includeMainSiteCheck: true,
);
$job = $this->detector->persistJob($items, $periodStart, $periodEnd, (int) $admin->getKey());
AuditLogger::recordForAdmin(
$admin,
$request,
'reconcile_jobs',
'create',
'reconcile_job',
(string) $job->getKey(),
null,
[
'job_no' => $job->job_no,
'reconcile_type' => 'wallet_transfer',
'item_count' => count($items),
'player_id' => $playerId,
],
);
return $job->fresh();
}
}