handle katod error
This commit is contained in:
@@ -32,7 +32,8 @@ class SingleOrderController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
if (($data['method'] ?? null) === 'katod') {
|
||||
$data['is_katod'] = ($data['method'] ?? null) === 'katod';
|
||||
if ($data['is_katod']) {
|
||||
$data['method'] = 'gold';
|
||||
}
|
||||
$config = app(ConfigService::class);
|
||||
@@ -271,7 +272,7 @@ class SingleOrderController extends Controller
|
||||
$data['service_charge_price'] = $data['service_charge'] * $data['price_original'];
|
||||
$data['wallet'] = $wallet;
|
||||
if ($wallet->gold < $data['total_amount']) {
|
||||
throw new UnprocessableEntityHttpException('موجودی طلایی شما کمتر از میزان سفارش است');
|
||||
throw new UnprocessableEntityHttpException($this->insufficientGoldBalanceMessage($data));
|
||||
}
|
||||
if (!$data['product']['open_buy']) {
|
||||
throw new UnprocessableEntityHttpException('خرید این محصول در این لحظه مقدور نمیباشد');
|
||||
@@ -310,7 +311,7 @@ class SingleOrderController extends Controller
|
||||
$data['payment_amount'] = $data['total_price'];
|
||||
$data['payment_amount'] -= $data['service_charge_price'];
|
||||
if ($wallet->gold < $data['amount']) {
|
||||
throw new UnprocessableEntityHttpException('موجودی شما کمتر از میزان سفارش است');
|
||||
throw new UnprocessableEntityHttpException($this->insufficientGoldBalanceMessage($data));
|
||||
}
|
||||
$data['order'] = $order = Order::create($data);
|
||||
new TransactionInterface($wallet_interface, [
|
||||
@@ -488,7 +489,7 @@ class SingleOrderController extends Controller
|
||||
// $pricePerGram = $totalPrice / $amount;
|
||||
$customerMessage = "$companyName\n$transactionType آبشده\nگرم: {$amount}\n" .
|
||||
"مبلغ کل: " . number_format($totalPrice) . "\n\n" .
|
||||
"موجودی طلایی: {$wallet->gold}\n" .
|
||||
"موجودی {$this->goldBalanceLabel($data)}: {$wallet->gold}\n" .
|
||||
"مانده ریالی: " . number_format($wallet->cash) . "\n" .
|
||||
$this->Config('app_url');
|
||||
|
||||
@@ -669,4 +670,19 @@ class SingleOrderController extends Controller
|
||||
->where('payment_sts', 4)
|
||||
->count() < (int)$count;
|
||||
}
|
||||
|
||||
private function isKatodPayment(array $data): bool
|
||||
{
|
||||
return ($data['is_katod'] ?? false) === true;
|
||||
}
|
||||
|
||||
private function goldBalanceLabel(array $data): string
|
||||
{
|
||||
return $this->isKatodPayment($data) ? 'کاتد' : 'طلایی';
|
||||
}
|
||||
|
||||
private function insufficientGoldBalanceMessage(array $data): string
|
||||
{
|
||||
return 'موجودی ' . $this->goldBalanceLabel($data) . ' شما کمتر از میزان سفارش است';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user