locations-bugs #17
@ -15,10 +15,13 @@ class Bank
|
||||
const ERROR_NO_BANK_ACCOUNT = "Ошибка! Счёта не существует!";
|
||||
const ERROR_NO_MONEY_IN_BANK_ACCOUNT = "Ошибка! Нет денег на счету!";
|
||||
const ERROR_WRONG_AMOUNT = "Ошибка! Сумма должна быть положительной!";
|
||||
const LOG_SEND = "Банк: Перевод средств на другой счёт.";
|
||||
const LOG_RECEIVE = "Банк: Получение средств.";
|
||||
const LOG_DEPOSIT = "Пополнение счёта.";
|
||||
const LOG_WITHDRAW = "Снятие денег со счёта.";
|
||||
const LOG = [
|
||||
'sendMoney' => 'Банк: Перевод средств на другой счёт.',
|
||||
'receiveMoney' => 'Банк: Получение средств.',
|
||||
'depositMoney' => 'Пополнение счёта.',
|
||||
'withdrawMoney' => 'Снятие денег со счёта.',
|
||||
'clanRegister' => 'Оплата стоимости регистрации клана.',
|
||||
];
|
||||
|
||||
public function __construct($row)
|
||||
{
|
||||
@ -43,7 +46,7 @@ class Bank
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function bankCommission(int $amount):int
|
||||
private function bankCommission(int $amount): int
|
||||
{
|
||||
$bankCommission = round($amount * Config::$bank_commission);
|
||||
if ($bankCommission < 1) {
|
||||
@ -64,22 +67,19 @@ class Bank
|
||||
* @return void
|
||||
* @throws \Krugozor\Database\Mysql\Exception
|
||||
*/
|
||||
private function bankLogs(int $receiverId, int $amount, string $operationType, int $senderId = 0):void
|
||||
private function bankLogs(int $receiverId, int $amount, string $operationType, int $senderId = 0): void
|
||||
{
|
||||
if (!$senderId) {
|
||||
$senderId = $this->user_id;
|
||||
}
|
||||
$text = '';
|
||||
$text = self::LOG[$operationType];
|
||||
if ($operationType == "sendMoney") {
|
||||
$text = self::LOG_SEND . " Комиссия: " . $this->bankCommission($amount);
|
||||
$text .= " Комиссия: " . $this->bankCommission($amount);
|
||||
} elseif ($operationType == "depositMoney") {
|
||||
$receiverId = $this->user_id;
|
||||
$text = self::LOG_DEPOSIT;
|
||||
} elseif ($operationType == "withdrawMoney") {
|
||||
$receiverId = $this->user_id;
|
||||
$text = self::LOG_WITHDRAW . " Комиссия: " . $this->bankCommission($amount);
|
||||
} elseif ($operationType == "receiveMoney") {
|
||||
$text = self::LOG_RECEIVE;
|
||||
$text .= " Комиссия: " . $this->bankCommission($amount);
|
||||
}
|
||||
|
||||
db::c()->query('INSERT INTO `bank_logs` (sender_id, receiver_id, amount_result, type, text)
|
||||
@ -204,7 +204,8 @@ class Bank
|
||||
db::c()->query('UPDATE users SET money = ?i WHERE `id` = ?i', $amount, $user_id);
|
||||
}
|
||||
|
||||
public function getBankMoney() {
|
||||
public function getBankMoney()
|
||||
{
|
||||
return $this->money;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user