From 7a3d8ab661130665178c50211ac42f6f2ed96cd1 Mon Sep 17 00:00:00 2001 From: adonis Date: Thu, 4 Jun 2026 19:09:58 +0330 Subject: [PATCH] zarbox added 9 --- .../Controllers/Customer/WalletController.php | 67 +++++++++++++------ 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/Customer/WalletController.php b/app/Http/Controllers/Customer/WalletController.php index c41e2bb..2f40f70 100644 --- a/app/Http/Controllers/Customer/WalletController.php +++ b/app/Http/Controllers/Customer/WalletController.php @@ -85,21 +85,6 @@ class WalletController extends Controller } foreach ($records['rows'] as &$record) { - - // اولویت اول: واریز توسط ادمین - // حتی اگر title قبلاً برداشت ریالی ذخیره شده باشد، باید اصلاح شود - if ( - isset($record->withdraw) && - (int) $record->withdraw->sts === 4 - ) { - $record->title = "واریز ریالی"; - - // اگر می‌خوای تو دیتابیس هم اصلاح بشه - $record->save(); - - continue; - } - // بقیه رکوردها فقط اگر title ندارند یا تعریف نشده هستند اصلاح شوند if (empty($record->title) || $record->title == "تعریف نشده") { @@ -463,16 +448,60 @@ class WalletController extends Controller } /** - * برداشت API فروشگاه (RequestsController) withdraw_id ندارد — برای UI همان withdraw.sts_str. + * متن وضعیت آبی UI — کلاینت: order.sts_str ?? withdraw.sts_str (بدون تغییر اپ). */ private function applyTransactionDisplayStatus($record): void { - if (!empty($record->withdraw) || !empty($record->order)) { + if ((int) $record->type === 4 && empty($record->withdraw_id)) { + $this->setWithdrawStsStr($record, 'برداشت ریالی توسط فروشگاه'); + return; } - if ((int) $record->type === 4 && empty($record->withdraw_id)) { - $record->setRelation('withdraw', (object) ['sts_str' => 'درخواست از فروشگاه']); + if ($this->isShopGoldTransaction($record)) { + $this->setOrderStsStr($record, 'برداشت طلایی توسط فروشگاه'); + + return; + } + } + + /** برداشت طلا از API خارجی (RequestsController::processGoldTransaction) */ + private function isShopGoldTransaction($record): bool + { + if ((int) $record->type !== 10 || empty($record->order_id) || empty($record->order)) { + return false; + } + + $order = $record->order; + if ((int) ($order->direction ?? 0) !== 2) { + return false; + } + + $montify = trim((string) $this->Config('montify_name')); + if ($montify !== '' && str_contains((string) ($order->description ?? ''), $montify)) { + return true; + } + + return (int) ($order->sts ?? 0) === 2 + && (int) ($order->payment_sts ?? 0) === 4 + && empty($record->withdraw_id); + } + + 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]); + } + + private function setOrderStsStr($record, string $label): void + { + if (!empty($record->order)) { + $record->order->setAttribute('sts_str', $label); } }