fix order error
This commit is contained in:
@@ -123,6 +123,8 @@ class SingleOrderController extends Controller
|
|||||||
else if ($data['method'] == "gold") {
|
else if ($data['method'] == "gold") {
|
||||||
|
|
||||||
$response['buy'] = $this->processBuyTransactionProductByGold($data, $wallet, $wallet_interface);
|
$response['buy'] = $this->processBuyTransactionProductByGold($data, $wallet, $wallet_interface);
|
||||||
|
} else {
|
||||||
|
throw new UnprocessableEntityHttpException('روش پرداخت نامعتبر است.');
|
||||||
}
|
}
|
||||||
} // Check if the user wants to sell
|
} // Check if the user wants to sell
|
||||||
else if ($data['direction'] == 2) {
|
else if ($data['direction'] == 2) {
|
||||||
@@ -138,6 +140,8 @@ class SingleOrderController extends Controller
|
|||||||
} // Check if the method is gold
|
} // Check if the method is gold
|
||||||
else if ($data['method'] == "gold") {
|
else if ($data['method'] == "gold") {
|
||||||
$response['sell'] = $this->processSellTransactionProductByGold($data, $wallet, $wallet_interface);
|
$response['sell'] = $this->processSellTransactionProductByGold($data, $wallet, $wallet_interface);
|
||||||
|
} else {
|
||||||
|
throw new UnprocessableEntityHttpException('روش پرداخت نامعتبر است.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -173,7 +177,9 @@ class SingleOrderController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// $response['reward'] = $this->give_order_reward($data, $wallet, $wallet_interface);
|
// $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]);
|
return response()->json([$response, $data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,17 +467,24 @@ class SingleOrderController extends Controller
|
|||||||
{
|
{
|
||||||
$customer = Customer::findOrFail($data['customer_id']);
|
$customer = Customer::findOrFail($data['customer_id']);
|
||||||
$companyName = $this->Config('name_fa');
|
$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']} به مقدار " .
|
$message = "کاربر {$customer->name} با شماره موبایل {$customer->mobile} اقدام به $transactionType {$productTitle} به مقدار " .
|
||||||
"{$data['amount']} گرم به مبلغ " . number_format($data['total_price']) .
|
"{$amount} گرم به مبلغ " . number_format($totalPrice) .
|
||||||
" ریال کرد. با تشکر، $companyName";
|
" ریال کرد. با تشکر، $companyName";
|
||||||
User::where('send_sms', 1)->get()->each(function ($admin) use ($message, $data, $transactionType, $companyName) {
|
User::where('send_sms', 1)->get()->each(function ($admin) use ($message, $data, $transactionType, $companyName) {
|
||||||
$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();
|
||||||
// $pricePerGram = $data['total_price'] / $data['amount'];
|
// $pricePerGram = $totalPrice / $amount;
|
||||||
$customerMessage = "$companyName\n$transactionType آبشده\nگرم: {$data['amount']}\n" .
|
$customerMessage = "$companyName\n$transactionType آبشده\nگرم: {$amount}\n" .
|
||||||
"مبلغ کل: " . number_format($data['total_price']) . "\n\n" .
|
"مبلغ کل: " . number_format($totalPrice) . "\n\n" .
|
||||||
"موجودی طلایی: {$wallet->gold}\n" .
|
"موجودی طلایی: {$wallet->gold}\n" .
|
||||||
"مانده ریالی: " . number_format($wallet->cash) . "\n" .
|
"مانده ریالی: " . number_format($wallet->cash) . "\n" .
|
||||||
$this->Config('app_url');
|
$this->Config('app_url');
|
||||||
|
|||||||
Reference in New Issue
Block a user