Fix bugs with sending money
This commit is contained in:
parent
6a54f3c822
commit
e4227dd644
@ -20,9 +20,10 @@ if ($amount > $sender["balance"]) {
|
||||
sendJsonResp($Strings->get("Insufficient funds.", false), "ERROR");
|
||||
}
|
||||
|
||||
if (($sender["type"] === 1 && $receiver["type"] === 2) || ($sender["type"] === 2 && $receiver["type"] === 3)) {
|
||||
if (($sender["type"] == 1 && $receiver["type"] == 2) || ($sender["type"] == 2 && $receiver["type"] == 3)) {
|
||||
$success = false;
|
||||
$database->action(function ($database) {
|
||||
global $VARS, $sender, $receiver, $amount;
|
||||
global $VARS, $sender, $receiver, $amount, $success;
|
||||
|
||||
$database->update("accounts", ["balance[+]" => $amount], ["accountid" => $receiver["accountid"]]);
|
||||
$database->update("accounts", ["balance[-]" => $amount], ["accountid" => $sender["accountid"]]);
|
||||
@ -33,9 +34,14 @@ if (($sender["type"] === 1 && $receiver["type"] === 2) || ($sender["type"] === 2
|
||||
"toid" => $receiver["accountid"],
|
||||
"datetime" => date("Y-m-d H:i:s")
|
||||
]);
|
||||
$success = true;
|
||||
});
|
||||
|
||||
sendJsonResp();
|
||||
if ($success) {
|
||||
sendJsonResp();
|
||||
} else {
|
||||
sendJsonResp($Strings->get("An unknown problem occurred.", false), "ERROR");
|
||||
}
|
||||
} else {
|
||||
sendJsonResp($Strings->get("Money cannot be sent from receivers to givers.", false), "ERROR");
|
||||
sendJsonResp($Strings->get("Money must be sent from givers to receivers.", false), "ERROR");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user