fix order error

This commit is contained in:
2026-06-03 19:41:00 +03:30
parent c40ac0a3fe
commit fe7df1b394
@@ -123,6 +123,8 @@ class SingleOrderController extends Controller
else if ($data['method'] == "gold") {
$response['buy'] = $this->processBuyTransactionProductByGold($data, $wallet, $wallet_interface);
} else {
throw new UnprocessableEntityHttpException('روش پرداخت نامعتبر است.');
}
} // Check if the user wants to sell
else if ($data['direction'] == 2) {
@@ -138,6 +140,8 @@ class SingleOrderController extends Controller
} // Check if the method is gold
else if ($data['method'] == "gold") {
$response['sell'] = $this->processSellTransactionProductByGold($data, $wallet, $wallet_interface);
} else {
throw new UnprocessableEntityHttpException('روش پرداخت نامعتبر است.');
}
}
} else {
@@ -173,7 +177,9 @@ class SingleOrderController extends Controller
}
}
// $response['reward'] = $this->give_order_reward($data, $wallet, $wallet_interface);
$response['Notifications'] = $this->sendTransactionNotifications($data, $transactionType);
if (isset($data['order'])) {
$response['Notifications'] = $this->sendTransactionNotifications($data, $transactionType);
}
return response()->json([$response, $data]);
}
@@ -461,17 +467,24 @@ class SingleOrderController extends Controller
{
$customer = Customer::findOrFail($data['customer_id']);
$companyName = $this->Config('name_fa');
$amount = $data['amount'] ?? (
isset($data['number'], $data['product']['amount'])
? $data['number'] * $data['product']['amount']
: 0
);
$totalPrice = $data['total_price'] ?? ($data['payment_amount'] ?? 0);
$productTitle = $data['product']['title'] ?? 'آبشده';
$message = "کاربر {$customer->name} با شماره موبایل {$customer->mobile} اقدام به $transactionType {$data['product']['title']} به مقدار " .
"{$data['amount']} گرم به مبلغ " . number_format($data['total_price']) .
$message = "کاربر {$customer->name} با شماره موبایل {$customer->mobile} اقدام به $transactionType {$productTitle} به مقدار " .
"{$amount} گرم به مبلغ " . number_format($totalPrice) .
" ریال کرد. با تشکر، $companyName";
User::where('send_sms', 1)->get()->each(function ($admin) use ($message, $data, $transactionType, $companyName) {
$this->send($admin->mobile, $message);
});
$wallet = Wallet::where('owner', $data['customer_id'])->whereNull('fund_id')->first();
// $pricePerGram = $data['total_price'] / $data['amount'];
$customerMessage = "$companyName\n$transactionType آبشده\nگرم: {$data['amount']}\n" .
"مبلغ کل: " . number_format($data['total_price']) . "\n\n" .
// $pricePerGram = $totalPrice / $amount;
$customerMessage = "$companyName\n$transactionType آبشده\nگرم: {$amount}\n" .
"مبلغ کل: " . number_format($totalPrice) . "\n\n" .
"موجودی طلایی: {$wallet->gold}\n" .
"مانده ریالی: " . number_format($wallet->cash) . "\n" .
$this->Config('app_url');