Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
accounting
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
accounting
Commits
2ea882fc
Commit
2ea882fc
authored
Jun 01, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
88004fa2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
28 deletions
+68
-28
db.js
db.js
+35
-6
message.js
message.js
+26
-5
test.js
test.js
+6
-16
os.js
utils/os.js
+1
-1
No files found.
db.js
View file @
2ea882fc
...
...
@@ -7,15 +7,15 @@ const dbAddress = process.env.DEBUG === 'true' ? process.env.HOST_Local : proces
const
dbPassword
=
process
.
env
.
DEBUG
===
'
true
'
?
'
root
'
:
process
.
env
.
DB_PASS_SERVER
;
const
sequelize
=
new
Sequelize
(
'
accounting
'
,
'
root
'
,
dbPassword
,
{
const
sequelize
=
new
Sequelize
(
'
accounting
'
,
'
root
'
,
'
mahan7797
'
,
{
define
:
{
charset
:
'
utf8
'
,
charset
:
'
utf8
'
,
collate
:
'
utf8_general_ci
'
},
host
:
dbAddress
,
host
:
'
35.157.64.22
'
,
dialect
:
'
mysql
'
,
logging
:
fals
e
,
logging
:
tru
e
,
operatorsAliases
:
false
...
...
@@ -31,6 +31,7 @@ const User = sequelize.define('user', {
euro_balance
:
{
type
:
Sequelize
.
DOUBLE
,
allowNull
:
false
,
defaultValue
:
0
},
lir_balance
:
{
type
:
Sequelize
.
DOUBLE
,
allowNull
:
false
,
defaultValue
:
0
},
aed_balance
:
{
type
:
Sequelize
.
DOUBLE
,
allowNull
:
false
,
defaultValue
:
0
},
can_balance
:
{
type
:
Sequelize
.
DOUBLE
,
allowNull
:
false
,
defaultValue
:
0
},
});
...
...
@@ -104,6 +105,9 @@ function runCurrency(data, user) {
case
'
aed
'
:
user
.
aed_balance
=
user
.
aed_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
break
case
'
aed
'
:
user
.
can_balance
=
user
.
can_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
break
}
...
...
@@ -131,6 +135,9 @@ function runCurrency(data, user) {
case
'
aed
'
:
user
.
aed_balance
=
user
.
aed_balance
+
(
parseFloat
(
data
.
count
))
break
case
'
can
'
:
user
.
can_balance
=
user
.
can_balance
+
(
parseFloat
(
data
.
count
))
break
}
...
...
@@ -179,6 +186,14 @@ function runCurrency(data, user) {
}
else
if
(
data
.
vahed
===
'
can
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
can_balance
=
user
.
can_balance
+
parseFloat
(
data
.
count
)
else
user
.
can_balance
=
user
.
can_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
}
if
(
data
.
to
===
'
toman
'
)
{
if
(
data
.
action
===
'
buy
'
)
...
...
@@ -223,6 +238,16 @@ function runCurrency(data, user) {
user
.
aed_balance
=
user
.
aed_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
else
if
(
data
.
vahed
===
'
can
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
can_balance
=
user
.
can_balance
+
(
-
1
*
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
else
user
.
can_balance
=
user
.
can_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
return
user
...
...
@@ -238,7 +263,7 @@ async function getAllUsers() {
})
}
async
function
getRequestByDate
(
userId
,
d
ate
)
{
async
function
getRequestByDate
(
userId
,
startDate
,
endD
ate
)
{
return
await
Request
.
findAll
({
...
...
@@ -246,7 +271,8 @@ async function getRequestByDate(userId, date) {
where
:
{
user_request
:
userId
,
createdAt
:
{
[
Op
.
gte
]:
moment
().
subtract
(
date
,
'
days
'
).
toDate
()
[
Op
.
gte
]:
startDate
,
[
Op
.
lte
]:
endDate
}
}
...
...
@@ -273,7 +299,8 @@ async function updateBalance(user) {
dollar_balance
:
user
.
dollar_balance
,
euro_balance
:
user
.
euro_balance
,
lir_balance
:
user
.
lir_balance
,
aed_balance
:
user
.
aed_balance
aed_balance
:
user
.
aed_balance
,
can_balance
:
user
.
can_balance
},
...
...
@@ -313,6 +340,8 @@ async function findRequest(id) {
}
module
.
exports
=
{
getAllUsers
:
getAllUsers
,
...
...
message.js
View file @
2ea882fc
...
...
@@ -118,6 +118,9 @@ function userShowMessage(bot, msg, user) {
}
if
(
user
.
euro_balance
!==
0
)
{
text
+=
'
💶
'
text
+=
Math
.
abs
(
user
.
euro_balance
)
+
'
'
+
'
یورو
'
+
'
'
...
...
@@ -144,6 +147,16 @@ function userShowMessage(bot, msg, user) {
user
.
aed_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
}
if
(
user
.
can_balance
!==
0
)
{
text
+=
'
💵
'
text
+=
Math
.
abs
(
user
.
can_balance
)
+
'
'
+
'
دلار کانادا
'
+
'
'
text
+=
user
.
can_balance
===
0
?
''
:
user
.
can_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
text
+=
'
\n
'
text
+=
'
\n
'
}
bot
.
editMessageText
(
text
,
opts
)
}
...
...
@@ -192,6 +205,14 @@ async function showCurrencyMessage(bot, msg, user) {
callback_data
:
'
aed_
'
+
user
.
id
}
],
[
{
text
:
'
دلار کانادا
'
,
callback_data
:
'
can_
'
+
user
.
id
}
]
...
...
@@ -390,13 +411,13 @@ async function listRequest(bot, msg, reqs) {
let
text
=
''
text
+=
reqs
[
i
].
type
.
replace
(
"
variz
"
,
"
واریز
"
).
replace
(
"
daryaft
"
,
"
دریافت
"
).
replace
(
"
buy
"
,
"
خرید
"
).
replace
(
"
sell
"
,
"
فروش
"
)
+
"
"
text
+=
reqs
[
i
].
count
+
"
"
text
+=
reqs
[
i
].
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
+
"
"
text
+=
reqs
[
i
].
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
.
replace
(
'
can
'
,
'
دلار کانادا
'
)
+
"
"
if
(
reqs
[
i
].
type
!==
'
variz
'
&&
reqs
[
i
].
type
!==
'
daryaft
'
)
{
text
+=
'
با مبلغ
'
text
+=
'
'
text
+=
reqs
[
i
].
fee
text
+=
'
'
text
+=
reqs
[
i
].
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
text
+=
reqs
[
i
].
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
.
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
'
'
}
...
...
@@ -433,13 +454,13 @@ async function showRequest(bot, msg, req) {
text
+=
'
'
text
+=
req
.
count
text
+=
'
'
text
+=
req
.
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
text
+=
req
.
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
.
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
'
'
text
+=
'
با مبلغ
'
text
+=
'
'
text
+=
req
.
fee
text
+=
'
'
text
+=
req
.
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
text
+=
req
.
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
.
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
'
'
}
else
{
...
...
@@ -449,7 +470,7 @@ async function showRequest(bot, msg, req) {
text
+=
'
'
text
+=
req
.
count
text
+=
'
'
text
+=
req
.
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
text
+=
req
.
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
.
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
'
'
}
...
...
test.js
View file @
2ea882fc
let
d
=
Date
(
)
let
d
b
=
require
(
'
./db
'
)
console
.
log
(
d
.
bold
())
console
.
log
(
d
.
small
().
bold
())
console
.
log
(
"
Hii ali name of god
"
)
console
.
log
(
Date
())
console
.
log
(
Date
().
fixed
())
test
()
async
function
test
()
{
let
d
=
await
db
.
getRequestByDate
(
4
,
new
Date
(
'
2019-02-01
'
),
new
Date
(
'
2020-02-01
'
))
console
.
log
(
d
)
}
utils/os.js
View file @
2ea882fc
...
...
@@ -2,7 +2,7 @@
function
initOs
()
{
if
(
process
.
platform
===
'
darwin
'
||
process
.
platform
===
'
win32
'
)
process
.
env
.
DEBUG
=
'
tru
e
'
;
process
.
env
.
DEBUG
=
'
fals
e
'
;
else
process
.
env
.
DEBUG
=
'
false
'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment