forked from Simnation/Main
Update billing_server.lua
This commit is contained in:
parent
a9c685ddf4
commit
693bd8b898
1 changed files with 36 additions and 16 deletions
|
@ -316,22 +316,39 @@ end
|
||||||
|
|
||||||
-- Create the necessary database tables if they don't exist
|
-- Create the necessary database tables if they don't exist
|
||||||
MySQL.ready(function()
|
MySQL.ready(function()
|
||||||
MySQL.query.await([[
|
-- First check if the billing_accounts table exists
|
||||||
CREATE TABLE IF NOT EXISTS billing_accounts (
|
local tableExists = MySQL.query.await("SHOW TABLES LIKE 'billing_accounts'")
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
bill_id INT,
|
|
||||||
bill_description VARCHAR(255),
|
|
||||||
sender_id VARCHAR(50),
|
|
||||||
receiver_id VARCHAR(50),
|
|
||||||
account_id VARCHAR(50),
|
|
||||||
amount DECIMAL(10,2),
|
|
||||||
created_at DATETIME,
|
|
||||||
paid TINYINT DEFAULT 0,
|
|
||||||
declined TINYINT DEFAULT 0,
|
|
||||||
paid_at DATETIME
|
|
||||||
)
|
|
||||||
]])
|
|
||||||
|
|
||||||
|
if #tableExists > 0 then
|
||||||
|
-- Table exists, check if the declined column exists
|
||||||
|
local columnExists = MySQL.query.await("SHOW COLUMNS FROM billing_accounts LIKE 'declined'")
|
||||||
|
|
||||||
|
if #columnExists == 0 then
|
||||||
|
-- Add the declined column if it doesn't exist
|
||||||
|
MySQL.query.await("ALTER TABLE billing_accounts ADD COLUMN declined TINYINT DEFAULT 0")
|
||||||
|
print("^2[nordi_billing] Added 'declined' column to billing_accounts table^7")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Create the table with all required columns
|
||||||
|
MySQL.query.await([[
|
||||||
|
CREATE TABLE IF NOT EXISTS billing_accounts (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
bill_id INT,
|
||||||
|
bill_description VARCHAR(255),
|
||||||
|
sender_id VARCHAR(50),
|
||||||
|
receiver_id VARCHAR(50),
|
||||||
|
account_id VARCHAR(50),
|
||||||
|
amount DECIMAL(10,2),
|
||||||
|
created_at DATETIME,
|
||||||
|
paid TINYINT DEFAULT 0,
|
||||||
|
declined TINYINT DEFAULT 0,
|
||||||
|
paid_at DATETIME
|
||||||
|
)
|
||||||
|
]])
|
||||||
|
print("^2[nordi_billing] Created billing_accounts table^7")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create offline_payments table if it doesn't exist
|
||||||
MySQL.query.await([[
|
MySQL.query.await([[
|
||||||
CREATE TABLE IF NOT EXISTS offline_payments (
|
CREATE TABLE IF NOT EXISTS offline_payments (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
@ -342,7 +359,10 @@ MySQL.ready(function()
|
||||||
processed TINYINT DEFAULT 0
|
processed TINYINT DEFAULT 0
|
||||||
)
|
)
|
||||||
]])
|
]])
|
||||||
end)
|
print("^2[nordi_billing] Database tables initialized^7")
|
||||||
|
end) -- Added closing parenthesis here
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Handle offline payments when a player logs in
|
-- Handle offline payments when a player logs in
|
||||||
RegisterNetEvent('QBCore:Server:PlayerLoaded', function()
|
RegisterNetEvent('QBCore:Server:PlayerLoaded', function()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue