handle katod show insted of gold
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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() . ' شما کمتر از میزان سفارش است';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user