Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
20baae47
authored
Aug 04, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: epay
parent
95d2f80e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
controller/topup.go
+14
-6
No files found.
controller/topup.go
View file @
20baae47
...
@@ -41,12 +41,12 @@ func GetEpayClient() *epay.Client {
...
@@ -41,12 +41,12 @@ func GetEpayClient() *epay.Client {
return
withUrl
return
withUrl
}
}
func
getPayMoney
(
amount
float64
,
user
model
.
User
)
float64
{
func
getPayMoney
(
amount
float64
,
group
string
)
float64
{
if
!
common
.
DisplayInCurrencyEnabled
{
if
!
common
.
DisplayInCurrencyEnabled
{
amount
=
amount
/
common
.
QuotaPerUnit
amount
=
amount
/
common
.
QuotaPerUnit
}
}
// 别问为什么用float64,问就是这么点钱没必要
// 别问为什么用float64,问就是这么点钱没必要
topupGroupRatio
:=
common
.
GetTopupGroupRatio
(
user
.
G
roup
)
topupGroupRatio
:=
common
.
GetTopupGroupRatio
(
g
roup
)
if
topupGroupRatio
==
0
{
if
topupGroupRatio
==
0
{
topupGroupRatio
=
1
topupGroupRatio
=
1
}
}
...
@@ -75,8 +75,12 @@ func RequestEpay(c *gin.Context) {
...
@@ -75,8 +75,12 @@ func RequestEpay(c *gin.Context) {
}
}
id
:=
c
.
GetInt
(
"id"
)
id
:=
c
.
GetInt
(
"id"
)
user
,
_
:=
model
.
GetUserById
(
id
,
false
)
group
,
err
:=
model
.
CacheGetUserGroup
(
id
)
payMoney
:=
getPayMoney
(
float64
(
req
.
Amount
),
*
user
)
if
err
!=
nil
{
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"error"
,
"data"
:
"获取用户分组失败"
})
return
}
payMoney
:=
getPayMoney
(
float64
(
req
.
Amount
),
group
)
if
payMoney
<
0.01
{
if
payMoney
<
0.01
{
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"error"
,
"data"
:
"充值金额过低"
})
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"error"
,
"data"
:
"充值金额过低"
})
return
return
...
@@ -233,8 +237,12 @@ func RequestAmount(c *gin.Context) {
...
@@ -233,8 +237,12 @@ func RequestAmount(c *gin.Context) {
return
return
}
}
id
:=
c
.
GetInt
(
"id"
)
id
:=
c
.
GetInt
(
"id"
)
user
,
_
:=
model
.
GetUserById
(
id
,
false
)
group
,
err
:=
model
.
CacheGetUserGroup
(
id
)
payMoney
:=
getPayMoney
(
float64
(
req
.
Amount
),
*
user
)
if
err
!=
nil
{
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"error"
,
"data"
:
"获取用户分组失败"
})
return
}
payMoney
:=
getPayMoney
(
float64
(
req
.
Amount
),
group
)
if
payMoney
<=
0.01
{
if
payMoney
<=
0.01
{
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"error"
,
"data"
:
"充值金额过低"
})
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"error"
,
"data"
:
"充值金额过低"
})
return
return
...
...
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