handle katod show insted of gold

This commit is contained in:
2026-06-03 20:24:07 +03:30
parent 4dc6b80ba4
commit 2d4656ed9c
3 changed files with 33 additions and 10 deletions
+7
View File
@@ -155,6 +155,13 @@ class Controller extends BaseController
return Setting::where('key',$name)->first()->value ?? false; 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) public static function jibit($method, $p1 = null, $p2 = null, $p3 = null)
{ {
$counter = Cnt::where('key', 'jibit_counter')->first(); $counter = Cnt::where('key', 'jibit_counter')->first();
@@ -123,6 +123,8 @@ class WalletController extends Controller
$record->save(); $record->save();
} }
$this->applyMetalTypeTransactionTitle($record);
} }
return response()->json($records); return response()->json($records);
@@ -340,4 +342,17 @@ class WalletController extends Controller
return response()->json(true); 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}";
}
}
} }
@@ -285,7 +285,7 @@ class SingleOrderController extends Controller
'expire_at' => now(), 'expire_at' => now(),
'active' => true, 'active' => true,
'order_id' => $order->id, 'order_id' => $order->id,
'title' => "برداشت طلای ابشده" 'title' => $this->goldWithdrawTitle()
], 12, false, true); ], 12, false, true);
$wallet_interface_product = new WalletInterface(auth('customer')->id(), auth('customer')->user()->type, null, $data["product_id"]); $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); $wallet_interface_product->wallet->gold = intval($wallet_interface_product->wallet->gold);
@@ -393,7 +393,7 @@ class SingleOrderController extends Controller
'expire_at' => now(), 'expire_at' => now(),
'active' => true, 'active' => true,
'order_id' => $order->id, 'order_id' => $order->id,
'title' => "واریز طلای ابشده" 'title' => $this->goldDepositTitle()
], 12, true, false); ], 12, true, false);
$wallet_interface_product->wallet->gold = intval($wallet_interface_product->wallet->gold); $wallet_interface_product->wallet->gold = intval($wallet_interface_product->wallet->gold);
$wallet_interface_product->wallet->save(); $wallet_interface_product->wallet->save();
@@ -477,7 +477,7 @@ class SingleOrderController extends Controller
: 0 : 0
); );
$totalPrice = $data['total_price'] ?? ($data['payment_amount'] ?? 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} به مقدار " . $message = "کاربر {$customer->name} با شماره موبایل {$customer->mobile} اقدام به $transactionType {$productTitle} به مقدار " .
"{$amount} گرم به مبلغ " . number_format($totalPrice) . "{$amount} گرم به مبلغ " . number_format($totalPrice) .
@@ -486,10 +486,11 @@ class SingleOrderController extends Controller
$this->send($admin->mobile, $message); $this->send($admin->mobile, $message);
}); });
$wallet = Wallet::where('owner', $data['customer_id'])->whereNull('fund_id')->first(); $wallet = Wallet::where('owner', $data['customer_id'])->whereNull('fund_id')->first();
$metalLabel = self::metalTypeLabel();
// $pricePerGram = $totalPrice / $amount; // $pricePerGram = $totalPrice / $amount;
$customerMessage = "$companyName\n$transactionType آبشده\nگرم: {$amount}\n" . $customerMessage = "$companyName\n$transactionType {$metalLabel}\nگرم: {$amount}\n" .
"مبلغ کل: " . number_format($totalPrice) . "\n\n" . "مبلغ کل: " . number_format($totalPrice) . "\n\n" .
"موجودی {$this->goldBalanceLabel($data)}: {$wallet->gold}\n" . "موجودی {$metalLabel}: {$wallet->gold}\n" .
"مانده ریالی: " . number_format($wallet->cash) . "\n" . "مانده ریالی: " . number_format($wallet->cash) . "\n" .
$this->Config('app_url'); $this->Config('app_url');
@@ -671,18 +672,18 @@ class SingleOrderController extends Controller
->count() < (int)$count; ->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 private function insufficientGoldBalanceMessage(array $data): string
{ {
return 'موجودی ' . $this->goldBalanceLabel($data) . ' شما کمتر از میزان سفارش است'; return 'موجودی ' . self::metalTypeLabel() . ' شما کمتر از میزان سفارش است';
} }
} }