Comments (1)
Here is the alternative code which requires replacement of the whole function in server.lua.
Querying the accounts column requires the data to be parsed by json.
---CHECK EXPIRATION PRET ®Benourson#9496
function CheckPretExpire(d, h, m)
print(os.date ("%c") .. _U('checking_expired_deadline_loans_start'))
MySQL.Async.fetchAll('SELECT bank_lent_money.id, bank_lent_money.clientID, bank_lent_money.amount, bank_lent_money.amountNextDeadline, bank_lent_money.alreadyPaid, bank_lent_money.remainDeadlines, bank_lent_money.timeBeforeDeadline, bank_lent_money.deadlines FROM bank_lent_money WHERE bank_lent_money.status = "Ouvert" AND bank_lent_money.timeLeft = "0" AND bank_lent_money.remainDeadlines > "0"',
{}, function(result)
for i=1, #result, 1 do
MySQL.Async.fetchAll('SELECT users.accounts FROM users WHERE users.identifier = @clientID',
{['@clientID'] = result[i].clientID}, function(bankmoney)
local playerbank = json.decode(bankmoney[1].accounts)["bank"]
local playerAccounts = json.decode(bankmoney[1].accounts)
if result[i].remainDeadlines > 1 then
--User can pay
if playerbank > result[i].amountNextDeadline then
MySQL.Async.execute('UPDATE bank_lent_money SET bank_lent_money.remainDeadlines = @remainingDeadlines, bank_lent_money.alreadyPaid = @alreadyPaid, bank_lent_money.timeLeft = @timeLeft WHERE bank_lent_money.id = @identifiant',
{
['@identifiant'] = result[i].id,
['@remainingDeadlines'] = result[i].remainDeadlines - 1,
['@alreadyPaid'] = result[i].alreadyPaid + result[i].amountNextDeadline,
['@timeLeft'] = result[i].timeBeforeDeadline
})
playerAccounts["bank"] = playerAccounts["bank"] - result[i].amountNextDeadline
MySQL.Async.execute('UPDATE users SET users.accounts = @account WHERE users.identifier = @clientID',
{
['@account'] = json.encode(playerAccounts),
['@clientID'] = result[i].clientID
})
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_banker', function(account)
account.addMoney(result[i].amountNextDeadline)
end)
-- User cannot pay
else
MySQL.Async.execute('UPDATE bank_lent_money SET bank_lent_money.status = @status WHERE bank_lent_money.id = @identifiant',
{
['@identifiant'] = result[i].id,
['@status'] = _U('unpayed_freeze') .. os.date ("%c")
})
end
else
--User can pay
if playerbank > result[i].amountNextDeadline then
MySQL.Async.execute('UPDATE bank_lent_money SET bank_lent_money.remainDeadlines = 0, bank_lent_money.alreadyPaid = @alreadyPaid, bank_lent_money.timeLeft = 0, bank_lent_money.status = "Clos" WHERE bank_lent_money.id = @identifiant',
{
['@identifiant'] = result[i].id,
['@alreadyPaid'] = result[i].alreadyPaid + result[i].amountNextDeadline
})
playerAccounts["bank"] = playerAccounts["bank"] - result[i].amountNextDeadline
MySQL.Async.execute('UPDATE users SET users.accounts = @accounts WHERE users.identifier = @clientID',
{
['@accounts'] = json.encode(playerAccounts),
['@clientID'] = result[i].clientID
})
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_banker', function(account)
account.addMoney(result[i].amountNextDeadline)
end)
-- User cannot pay
else
MySQL.Async.execute('UPDATE bank_lent_money SET bank_lent_money.status = @status WHERE bank_lent_money.id = @identifiant',
{
['@identifiant'] = result[i].id,
['@status'] = _U('unpayed_freeze') .. os.date ("%c")
})
end
end
end)
end
end)
print(os.date ("%c") .. _U('checking_expired_deadline_loans_end'))
end
TriggerEvent('cron:runAt', Config.CRONLoanTime[1], Config.CRONLoanTime[2], CheckPretExpire)
from esx-banker-job-upgraded.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esx-banker-job-upgraded.