From 2d4656ed9cebdc7cb57139370e16f0dc1290155f Mon Sep 17 00:00:00 2001 From: adonis Date: Wed, 3 Jun 2026 20:24:07 +0330 Subject: [PATCH] handle katod show insted of gold --- app/Http/Controllers/Controller.php | 7 +++++++ .../Controllers/Customer/WalletController.php | 15 +++++++++++++ .../Single/SingleOrderController.php | 21 ++++++++++--------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 44c6171..25f722c 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -155,6 +155,13 @@ class Controller extends BaseController return Setting::where('key',$name)->first()->value ?? false; } + public static function metalTypeLabel(): string + { + $metalType = Setting::where('key', 'metal_type')->value('value'); + + return ($metalType !== null && trim((string) $metalType) !== '') ? trim((string) $metalType) : 'طلا'; + } + public static function jibit($method, $p1 = null, $p2 = null, $p3 = null) { $counter = Cnt::where('key', 'jibit_counter')->first(); diff --git a/app/Http/Controllers/Customer/WalletController.php b/app/Http/Controllers/Customer/WalletController.php index 09a0a8a..6ccd710 100644 --- a/app/Http/Controllers/Customer/WalletController.php +++ b/app/Http/Controllers/Customer/WalletController.php @@ -123,6 +123,8 @@ class WalletController extends Controller $record->save(); } + + $this->applyMetalTypeTransactionTitle($record); } return response()->json($records); @@ -340,4 +342,17 @@ class WalletController extends Controller return response()->json(true); } + private function applyMetalTypeTransactionTitle($record): void + { + $metalLabel = self::metalTypeLabel(); + $legacyDepositTitles = ['واریز طلای ابشده', 'واریز طلای آبشده']; + $legacyWithdrawTitles = ['برداشت طلای ابشده', 'برداشت طلای آبشده']; + + if (in_array($record->title, $legacyDepositTitles, true)) { + $record->title = "موجودی {$metalLabel}"; + } elseif (in_array($record->title, $legacyWithdrawTitles, true)) { + $record->title = "برداشت {$metalLabel}"; + } + } + } diff --git a/app/Http/Controllers/Single/SingleOrderController.php b/app/Http/Controllers/Single/SingleOrderController.php index feff3e7..4653845 100644 --- a/app/Http/Controllers/Single/SingleOrderController.php +++ b/app/Http/Controllers/Single/SingleOrderController.php @@ -285,7 +285,7 @@ class SingleOrderController extends Controller 'expire_at' => now(), 'active' => true, 'order_id' => $order->id, - 'title' => "برداشت طلای ابشده" + 'title' => $this->goldWithdrawTitle() ], 12, false, true); $wallet_interface_product = new WalletInterface(auth('customer')->id(), auth('customer')->user()->type, null, $data["product_id"]); $wallet_interface_product->wallet->gold = intval($wallet_interface_product->wallet->gold); @@ -393,7 +393,7 @@ class SingleOrderController extends Controller 'expire_at' => now(), 'active' => true, 'order_id' => $order->id, - 'title' => "واریز طلای ابشده" + 'title' => $this->goldDepositTitle() ], 12, true, false); $wallet_interface_product->wallet->gold = intval($wallet_interface_product->wallet->gold); $wallet_interface_product->wallet->save(); @@ -477,7 +477,7 @@ class SingleOrderController extends Controller : 0 ); $totalPrice = $data['total_price'] ?? ($data['payment_amount'] ?? 0); - $productTitle = $data['product']['title'] ?? 'آبشده'; + $productTitle = $data['product']['title'] ?? self::metalTypeLabel(); $message = "کاربر {$customer->name} با شماره موبایل {$customer->mobile} اقدام به $transactionType {$productTitle} به مقدار " . "{$amount} گرم به مبلغ " . number_format($totalPrice) . @@ -486,10 +486,11 @@ class SingleOrderController extends Controller $this->send($admin->mobile, $message); }); $wallet = Wallet::where('owner', $data['customer_id'])->whereNull('fund_id')->first(); + $metalLabel = self::metalTypeLabel(); // $pricePerGram = $totalPrice / $amount; - $customerMessage = "$companyName\n$transactionType آبشده\nگرم: {$amount}\n" . + $customerMessage = "$companyName\n$transactionType {$metalLabel}\nگرم: {$amount}\n" . "مبلغ کل: " . number_format($totalPrice) . "\n\n" . - "موجودی {$this->goldBalanceLabel($data)}: {$wallet->gold}\n" . + "موجودی {$metalLabel}: {$wallet->gold}\n" . "مانده ریالی: " . number_format($wallet->cash) . "\n" . $this->Config('app_url'); @@ -671,18 +672,18 @@ class SingleOrderController extends Controller ->count() < (int)$count; } - private function isKatodPayment(array $data): bool + private function goldDepositTitle(): string { - return ($data['is_katod'] ?? false) === true; + return 'موجودی ' . self::metalTypeLabel(); } - private function goldBalanceLabel(array $data): string + private function goldWithdrawTitle(): string { - return $this->isKatodPayment($data) ? 'کاتد' : 'طلایی'; + return 'برداشت ' . self::metalTypeLabel(); } private function insufficientGoldBalanceMessage(array $data): string { - return 'موجودی ' . $this->goldBalanceLabel($data) . ' شما کمتر از میزان سفارش است'; + return 'موجودی ' . self::metalTypeLabel() . ' شما کمتر از میزان سفارش است'; } }