From 79d7758617764b5e4d9a0ad3cba099597852283d Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Sat, 9 Dec 2023 22:56:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC=E6=94=B9=E4=B8=BA=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E4=B8=A4=E4=BD=8D=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/topup.go | 5 +++-- model/topup.go | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/controller/topup.go b/controller/topup.go index d17cad438..35e6b971b 100644 --- a/controller/topup.go +++ b/controller/topup.go @@ -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", @@ -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)}) } diff --git a/model/topup.go b/model/topup.go index 876cd230b..dc1cbc561 100644 --- a/model/topup.go +++ b/model/topup.go @@ -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 {