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
8ae6605a
Commit
8ae6605a
authored
Jun 27, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
c7a1f962
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
6 deletions
+64
-6
app.js
app.js
+10
-0
db.js
db.js
+26
-1
message.js
message.js
+28
-5
No files found.
app.js
View file @
8ae6605a
...
...
@@ -65,12 +65,14 @@ async function processCallback(msg) {
else
if
(
msg
.
data
.
startsWith
(
"
lir_
"
))
showCount
(
msg
,
'
lir
'
)
else
if
(
msg
.
data
.
startsWith
(
"
aed_
"
))
showCount
(
msg
,
'
aed
'
)
else
if
(
msg
.
data
.
startsWith
(
"
can_
"
))
showCount
(
msg
,
'
can
'
)
else
if
(
msg
.
data
.
startsWith
(
"
pon_
"
))
showCount
(
msg
,
'
pon
'
)
else
if
(
msg
.
data
.
startsWith
(
"
Rtoman_
"
))
commitRequest
(
msg
,
'
toman
'
)
else
if
(
msg
.
data
.
startsWith
(
"
Rdollar_
"
))
commitRequest
(
msg
,
'
dollar
'
)
else
if
(
msg
.
data
.
startsWith
(
"
Reuro_
"
))
commitRequest
(
msg
,
'
euro
'
)
else
if
(
msg
.
data
.
startsWith
(
"
Rlir_
"
))
commitRequest
(
msg
,
'
lir
'
)
else
if
(
msg
.
data
.
startsWith
(
"
Raed_
"
))
commitRequest
(
msg
,
'
aed
'
)
else
if
(
msg
.
data
.
startsWith
(
"
Rcan_
"
))
commitRequest
(
msg
,
'
can
'
)
else
if
(
msg
.
data
.
startsWith
(
"
Rpon_
"
))
commitRequest
(
msg
,
'
pon
'
)
else
if
(
msg
.
data
.
startsWith
(
"
yes_
"
))
yesNoDoc
(
msg
,
'
yes
'
)
else
if
(
msg
.
data
.
startsWith
(
"
no_
"
))
yesNoDoc
(
msg
,
'
no
'
)
...
...
@@ -151,6 +153,9 @@ async function showCount(msg, unit) {
case
'
can
'
:
msg
.
data
=
msg
.
data
.
replace
(
"
can_
"
,
""
)
break
case
'
pon
'
:
msg
.
data
=
msg
.
data
.
replace
(
"
pon_
"
,
""
)
break
}
...
...
@@ -324,6 +329,11 @@ async function canOrder(data, msg) {
generateText
(
user
.
can_balance
,
num
,
msg
)
}
if
(
data
.
to
===
'
pon
'
)
if
(
user
.
pon_balance
<=
0
||
num
>
user
.
pon_balance
)
{
generateText
(
user
.
pon_balance
,
num
,
msg
)
}
}
...
...
db.js
View file @
8ae6605a
...
...
@@ -32,6 +32,7 @@ const User = sequelize.define('user', {
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
},
pon_balance
:
{
type
:
Sequelize
.
DOUBLE
,
allowNull
:
false
,
defaultValue
:
0
},
});
...
...
@@ -108,6 +109,9 @@ function runCurrency(data, user) {
case
'
can
'
:
user
.
can_balance
=
user
.
can_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
break
case
'
pon
'
:
user
.
can_balance
=
user
.
pon_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
break
}
...
...
@@ -138,6 +142,9 @@ function runCurrency(data, user) {
case
'
can
'
:
user
.
can_balance
=
user
.
can_balance
+
(
parseFloat
(
data
.
count
))
break
case
'
pon
'
:
user
.
can_balance
=
user
.
pon_balance
+
(
parseFloat
(
data
.
count
))
break
}
...
...
@@ -194,6 +201,14 @@ function runCurrency(data, user) {
}
else
if
(
data
.
vahed
===
'
pon
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
pon_balance
=
user
.
pon_balance
+
parseFloat
(
data
.
count
)
else
user
.
pon_balance
=
user
.
pon_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
}
if
(
data
.
to
===
'
toman
'
)
{
if
(
data
.
action
===
'
buy
'
)
...
...
@@ -248,6 +263,15 @@ function runCurrency(data, user) {
user
.
can_balance
=
user
.
can_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
else
if
(
data
.
vahed
===
'
pon
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
pon_balance
=
user
.
pon_balance
+
(
-
1
*
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
else
user
.
pon_balance
=
user
.
pon_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
return
user
...
...
@@ -308,7 +332,8 @@ async function updateBalance(user) {
euro_balance
:
user
.
euro_balance
,
lir_balance
:
user
.
lir_balance
,
aed_balance
:
user
.
aed_balance
,
can_balance
:
user
.
can_balance
can_balance
:
user
.
can_balance
,
pon_balance
:
user
.
pon_balance
},
...
...
message.js
View file @
8ae6605a
...
...
@@ -158,6 +158,16 @@ function userShowMessage(bot, msg, user) {
text
+=
'
\n
'
}
if
(
user
.
pon_balance
!==
0
)
{
text
+=
'
💵
'
text
+=
numberize
(
Math
.
abs
(
user
.
pon_balance
))
+
'
'
+
'
پوند
'
+
'
'
text
+=
user
.
pon_balance
===
0
?
''
:
user
.
pon_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
text
+=
'
\n
'
text
+=
'
\n
'
}
bot
.
editMessageText
(
text
,
opts
)
}
...
...
@@ -214,6 +224,14 @@ async function showCurrencyMessage(bot, msg, user) {
callback_data
:
'
can_
'
+
user
.
id
}
],
[
{
text
:
'
پوند
'
,
callback_data
:
'
pon_
'
+
user
.
id
}
]
...
...
@@ -333,6 +351,11 @@ async function forwardCurrencyMessage(bot, msg, data) {
vahed
:
'
can
'
,
text
:
'
دلار کانادا
'
,
callback_data
:
'
Rcan_
'
+
data
.
user
},
{
vahed
:
'
pon
'
,
text
:
'
پوند
'
,
callback_data
:
'
Rpon_
'
+
data
.
user
}
...
...
@@ -417,13 +440,13 @@ async function listRequest(bot, msg, reqs) {
let
text
=
''
text
+=
reqs
[
i
].
type
.
replace
(
"
variz
"
,
"
واریز
"
).
replace
(
"
daryaft
"
,
"
دریافت
"
).
replace
(
"
buy
"
,
"
خرید
"
).
replace
(
"
sell
"
,
"
فروش
"
)
+
"
"
text
+=
numberize
(
reqs
[
i
].
count
)
+
"
"
text
+=
reqs
[
i
].
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
+
"
"
text
+=
reqs
[
i
].
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
.
replace
(
'
pon
'
,
'
پوند
'
)
+
"
"
if
(
reqs
[
i
].
type
!==
'
variz
'
&&
reqs
[
i
].
type
!==
'
daryaft
'
)
{
text
+=
'
با مبلغ
'
text
+=
'
'
text
+=
numberize
(
reqs
[
i
].
fee
)
text
+=
'
'
text
+=
reqs
[
i
].
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
reqs
[
i
].
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
.
replace
(
'
pon
'
,
'
پوند
'
)
text
+=
'
'
}
...
...
@@ -460,13 +483,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
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
req
.
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
.
replace
(
'
pon
'
,
'
پوند
'
)
text
+=
'
'
text
+=
'
با مبلغ
'
text
+=
'
'
text
+=
req
.
fee
text
+=
'
'
text
+=
req
.
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
req
.
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
.
replace
(
'
pon
'
,
'
پوند
'
)
text
+=
'
'
}
else
{
...
...
@@ -476,7 +499,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
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
req
.
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
.
replace
(
'
pon
'
,
'
پوند
'
)
text
+=
'
'
}
...
...
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