mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-17 16:06:38 +08:00
充值改为保留两位小数
This commit is contained in:
parent
5240971b4a
commit
79d7758617
@ -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) {
|
|||||||
}
|
}
|
||||||
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)})
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user