Новый способ запрашивать константы.

This commit is contained in:
lopar 2020-10-28 01:52:53 +02:00
parent c05c3298f1
commit 0e73bcb1ae
1 changed files with 21 additions and 20 deletions

View File

@ -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)
{
@ -69,17 +72,14 @@ class Bank
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;
}
}