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
3d567523
authored
Dec 09, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
充值改为保留两位小数
parent
08f09e22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
controller/topup.go
+3
-2
model/topup.go
+7
-7
No files found.
controller/topup.go
View file @
3d567523
...
@@ -98,7 +98,7 @@ func RequestEpay(c *gin.Context) {
...
@@ -98,7 +98,7 @@ func RequestEpay(c *gin.Context) {
topUp
:=
&
model
.
TopUp
{
topUp
:=
&
model
.
TopUp
{
UserId
:
id
,
UserId
:
id
,
Amount
:
req
.
Amount
,
Amount
:
req
.
Amount
,
Money
:
int
(
amount
)
,
Money
:
payMoney
,
TradeNo
:
"A"
+
tradeNo
,
TradeNo
:
"A"
+
tradeNo
,
CreateTime
:
time
.
Now
()
.
Unix
(),
CreateTime
:
time
.
Now
()
.
Unix
(),
Status
:
"pending"
,
Status
:
"pending"
,
...
@@ -175,5 +175,6 @@ func RequestAmount(c *gin.Context) {
...
@@ -175,5 +175,6 @@ func RequestAmount(c *gin.Context) {
}
}
id
:=
c
.
GetInt
(
"id"
)
id
:=
c
.
GetInt
(
"id"
)
user
,
_
:=
model
.
GetUserById
(
id
,
false
)
user
,
_
:=
model
.
GetUserById
(
id
,
false
)
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"success"
,
"data"
:
GetAmount
(
float64
(
req
.
Amount
),
*
user
)})
payMoney
:=
GetAmount
(
float64
(
req
.
Amount
),
*
user
)
c
.
JSON
(
200
,
gin
.
H
{
"message"
:
"success"
,
"data"
:
strconv
.
FormatFloat
(
payMoney
,
'f'
,
2
,
64
)})
}
}
model/topup.go
View file @
3d567523
package
model
package
model
type
TopUp
struct
{
type
TopUp
struct
{
Id
int
`json:"id"`
Id
int
`json:"id"`
UserId
int
`json:"user_id" gorm:"index"`
UserId
int
`json:"user_id" gorm:"index"`
Amount
int
`json:"amount"`
Amount
int
`json:"amount"`
Money
int
`json:"money"`
Money
float64
`json:"money"`
TradeNo
string
`json:"trade_no"`
TradeNo
string
`json:"trade_no"`
CreateTime
int64
`json:"create_time"`
CreateTime
int64
`json:"create_time"`
Status
string
`json:"status"`
Status
string
`json:"status"`
}
}
func
(
topUp
*
TopUp
)
Insert
()
error
{
func
(
topUp
*
TopUp
)
Insert
()
error
{
...
...
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