From c13222055b1f72f039c801c78350c3030c0a4547 Mon Sep 17 00:00:00 2001 From: adonis Date: Thu, 4 Jun 2026 19:16:37 +0330 Subject: [PATCH] zarbox added 10 --- .../Controllers/Customer/WalletController.php | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Customer/WalletController.php b/app/Http/Controllers/Customer/WalletController.php index 2f40f70..8c9bb81 100644 --- a/app/Http/Controllers/Customer/WalletController.php +++ b/app/Http/Controllers/Customer/WalletController.php @@ -452,7 +452,7 @@ class WalletController extends Controller */ private function applyTransactionDisplayStatus($record): void { - if ((int) $record->type === 4 && empty($record->withdraw_id)) { + if ($this->isShopRialTransaction($record)) { $this->setWithdrawStsStr($record, 'برداشت ریالی توسط فروشگاه'); return; @@ -465,6 +465,20 @@ class WalletController extends Controller } } + /** برداشت ریال از API خارجی — بدون رکورد withdraw در DB */ + private function isShopRialTransaction($record): bool + { + if ((int) $record->type !== 4) { + return false; + } + + if (!empty($record->withdraw_id) || !empty($record->withdraw)) { + return false; + } + + return true; + } + /** برداشت طلا از API خارجی (RequestsController::processGoldTransaction) */ private function isShopGoldTransaction($record): bool { @@ -489,20 +503,21 @@ class WalletController extends Controller private function setWithdrawStsStr($record, string $label): void { - if ($record->withdraw instanceof Withdraw) { - $record->withdraw->setAttribute('sts_str', $label); - - return; - } - - $record->setRelation('withdraw', (object) ['sts_str' => $label]); + // آرایه — stdClass در toArray()/JSON نمی‌آید و UI خالی می‌ماند + $record->setRelation('withdraw', ['sts_str' => $label]); } private function setOrderStsStr($record, string $label): void { - if (!empty($record->order)) { - $record->order->setAttribute('sts_str', $label); + if (empty($record->order)) { + return; } + + $order = $record->order instanceof Order + ? $record->order->toArray() + : (array) $record->order; + $order['sts_str'] = $label; + $record->setRelation('order', $order); } private function resolveMainWalletBalanceCashForOrder($record): ?int