Skip to content

Commit

Permalink
fix: fix setMoney and reduceMoney
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Aug 10, 2024
1 parent f151463 commit aaae397
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool LLMoney_Trans(std::string from, std::string to, long long val, std::string
return false;
}
}
if (val < 0 || from == to || to.empty()) {
if (val < 0 || from == to) {
return false;
}
try {
Expand All @@ -123,22 +123,24 @@ bool LLMoney_Trans(std::string from, std::string to, long long val, std::string
set.clearBindings();
}
}
auto tmoney = LLMoney_Get(to);
if (from.empty()) {
tmoney += val;
} else {
tmoney += val - val * legacy_money::getConfig().pay_tax;
}
if (tmoney < 0) {
db->exec("rollback");
return false;
}
{
set.bindNoCopy(2, to);
set.bind(1, tmoney);
set.exec();
set.reset();
set.clearBindings();
if (!to.empty()) {
auto tmoney = LLMoney_Get(to);
if (from.empty()) {
tmoney += val;
} else {
tmoney += val - val * legacy_money::getConfig().pay_tax;
}
if (tmoney < 0) {
db->exec("rollback");
return false;
}
{
set.bindNoCopy(2, to);
set.bind(1, tmoney);
set.exec();
set.reset();
set.clearBindings();
}
}

{
Expand Down

0 comments on commit aaae397

Please sign in to comment.