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:
47
app/Support/AdminTransferOrderCapabilities.php
Normal file
47
app/Support/AdminTransferOrderCapabilities.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\TransferOrder;
|
||||
use App\Services\Wallet\LotteryTransferService;
|
||||
|
||||
/** 后台转账单可执行的对账/补单动作(列表与对账明细共用)。 */
|
||||
final class AdminTransferOrderCapabilities
|
||||
{
|
||||
public static function canWriteWallet(?AdminUser $admin): bool
|
||||
{
|
||||
if ($admin === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $admin->hasPermissionCode('service.wallet.adjust')
|
||||
|| $admin->hasPermissionCode('service.reconcile.manage')
|
||||
|| $admin->hasPermissionCode('service.wallet.manage');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* can_reverse: bool,
|
||||
* can_complete_credit: bool,
|
||||
* can_manually_process: bool
|
||||
* }
|
||||
*/
|
||||
public static function forOrder(TransferOrder $order, ?AdminUser $admin, LotteryTransferService $transferService): array
|
||||
{
|
||||
$canWrite = self::canWriteWallet($admin);
|
||||
|
||||
return [
|
||||
'can_reverse' => $canWrite
|
||||
&& $order->status === 'pending_reconcile'
|
||||
&& ($order->direction === 'out' || $transferService->isEligibleForTransferInReverse($order)),
|
||||
'can_complete_credit' => $canWrite
|
||||
&& $order->direction === 'in'
|
||||
&& $order->status === 'pending_reconcile'
|
||||
&& $order->fail_reason === 'lottery_credit_failed'
|
||||
&& trim((string) $order->external_ref_no) !== '',
|
||||
'can_manually_process' => $canWrite
|
||||
&& $transferService->isEligibleForManualProcess($order),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user