mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
bank cleanup
This commit is contained in:
1 parent
d0ed913d7c
commit
6ee401e3d5
1 file changed
+7
-14
@@ -1,30 +1,24 @@
|
|||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
import {ESX} from './server';
|
import {ESX} from './server';
|
||||||
import { getSource } from "./functions";
|
import {getSource, useIdentifier} from "./functions";
|
||||||
import {pool} from './db';
|
import {pool} from './db';
|
||||||
import { Transfer, Credentials } from '../../phone/src/common/interfaces/bank';
|
import {IBankCredentials, Transfer} from '../../phone/src/common/typings/bank';
|
||||||
import { useIdentifier } from './functions';
|
|
||||||
import { type } from 'os';
|
|
||||||
|
|
||||||
|
|
||||||
async function fetchAllTransactions(identifier: string): Promise<Transfer[]> {
|
async function fetchAllTransactions(identifier: string): Promise<Transfer[]> {
|
||||||
const query = "SELECT * FROM npwd_bank_transfers WHERE identifier = ? ORDER BY id DESC"
|
const query = "SELECT * FROM npwd_bank_transfers WHERE identifier = ? ORDER BY id DESC"
|
||||||
const [ results ] = await pool.query(query, [identifier])
|
const [ results ] = await pool.query(query, [identifier])
|
||||||
const transactions = <Transfer[]>results;
|
return <Transfer[]>results;
|
||||||
|
|
||||||
return transactions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchCredentials(): Credentials {
|
function fetchCredentials(): IBankCredentials {
|
||||||
const name = ESX.GetPlayerFromId(getSource()).getName();
|
const name = ESX.GetPlayerFromId(getSource()).getName();
|
||||||
const balance = ESX.GetPlayerFromId(getSource()).getAccount('bank').money
|
const balance = ESX.GetPlayerFromId(getSource()).getAccount('bank').money
|
||||||
|
|
||||||
const result = {
|
return {
|
||||||
name,
|
name,
|
||||||
balance
|
balance
|
||||||
}
|
};
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addTransfer(identifier: string, transfer: Transfer): Promise<any> {
|
async function addTransfer(identifier: string, transfer: Transfer): Promise<any> {
|
||||||
@@ -86,11 +80,10 @@ onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
|||||||
|
|
||||||
onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||||
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
||||||
const targetSource = xTarget.source;
|
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier()
|
const _identifier = await useIdentifier()
|
||||||
const transferNotify = await addTransfer(_identifier, transfer)
|
const transferNotify = await addTransfer(_identifier, transfer)
|
||||||
emitNet(events.BANK_TRANSACTION_NOTIFICATION, targetSource, transferNotify)
|
emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify)
|
||||||
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, getSource());
|
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, getSource());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false)
|
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false)
|
||||||
|
|||||||
Reference in new issue
Block a user