Skip to content

Commit

Permalink
充值改为保留两位小数
Browse files Browse the repository at this point in the history
  • Loading branch information
Calcium-Ion committed Dec 9, 2023
1 parent 5240971 commit 79d7758
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions controller/topup.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func RequestEpay(c *gin.Context) {
topUp := &model.TopUp{
UserId: id,
Amount: req.Amount,
Money: int(amount),
Money: payMoney,
TradeNo: "A" + tradeNo,
CreateTime: time.Now().Unix(),
Status: "pending",
Expand Down Expand Up @@ -175,5 +175,6 @@ func RequestAmount(c *gin.Context) {
}
id := c.GetInt("id")
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)})
}
14 changes: 7 additions & 7 deletions model/topup.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package model

type TopUp struct {
Id int `json:"id"`
UserId int `json:"user_id" gorm:"index"`
Amount int `json:"amount"`
Money int `json:"money"`
TradeNo string `json:"trade_no"`
CreateTime int64 `json:"create_time"`
Status string `json:"status"`
Id int `json:"id"`
UserId int `json:"user_id" gorm:"index"`
Amount int `json:"amount"`
Money float64 `json:"money"`
TradeNo string `json:"trade_no"`
CreateTime int64 `json:"create_time"`
Status string `json:"status"`
}

func (topUp *TopUp) Insert() error {
Expand Down

0 comments on commit 79d7758

Please sign in to comment.