<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\V1\Admin\Wallet\TransferOrderListController;
use App\Http\Controllers\Api\V1\Admin\Wallet\TransferOrderReconcileController;
use App\Http\Controllers\Api\V1\Admin\Reconcile\ReconcileJobShowController;
use App\Http\Controllers\Api\V1\Admin\Reconcile\ReconcileJobIndexController;
use App\Http\Controllers\Api\V1\Admin\Reconcile\ReconcileJobStoreController;
use App\Http\Controllers\Api\V1\Admin\Reconcile\ReconcileItemIndexController;
use App\Http\Controllers\Api\V1\Admin\Wallet\WalletTransactionListController;

/**
 * 管理员钱包/对账路由。
 */

// 钱包对账查看
Route::middleware('admin.api-resource')
    ->group(function (): void {
        Route::get('wallet/transfer-orders', TransferOrderListController::class)
            ->name('api.v1.admin.wallet.transfer-orders');
        Route::get('wallet/transactions', WalletTransactionListController::class)
            ->name('api.v1.admin.wallet.transactions');

        Route::get('reconcile-jobs', ReconcileJobIndexController::class)
            ->name('api.v1.admin.reconcile-jobs.index');
        Route::get('reconcile-jobs/{reconcile_job}', ReconcileJobShowController::class)
            ->name('api.v1.admin.reconcile-jobs.show');
        Route::get('reconcile-jobs/{reconcile_job}/items', ReconcileItemIndexController::class)
            ->name('api.v1.admin.reconcile-jobs.items.index');
    });

// 对账操作（仅管理权限）
Route::middleware('admin.api-resource')
    ->group(function (): void {
        Route::post('wallet/transfer-orders/{transfer_no}/reverse', [TransferOrderReconcileController::class, 'reverse'])
            ->name('api.v1.admin.wallet.transfer-orders.reverse');
        Route::post('wallet/transfer-orders/{transfer_no}/manually-process', [TransferOrderReconcileController::class, 'manuallyProcess'])
            ->name('api.v1.admin.wallet.transfer-orders.manually-process');
        Route::post('wallet/transfer-orders/{transfer_no}/complete-credit', [TransferOrderReconcileController::class, 'completeCredit'])
            ->name('api.v1.admin.wallet.transfer-orders.complete-credit');
    });

// 对账任务创建（仅管理权限）
Route::middleware('admin.api-resource')
    ->post('reconcile-jobs', ReconcileJobStoreController::class)
    ->name('api.v1.admin.reconcile-jobs.store');
