From 09a6749b5f4402ebad1f3e8783d29a253ced254c Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 4 Dec 2024 18:06:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E7=BB=99=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/user_wallet.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rule/user_wallet.go b/rule/user_wallet.go index 00179c9..852070a 100644 --- a/rule/user_wallet.go +++ b/rule/user_wallet.go @@ -36,6 +36,7 @@ func DealUserWallet(session *xorm.Session, req md.DealUserWalletReq) (err error) return err } amountValue := decimal.NewFromFloat(req.Amount).RoundFloor(4) + beforeAmountValue, _ := decimal.NewFromString(userAmount) var userWalletFlow model.UserWalletFlow userWalletFlow.Uid = req.Uid @@ -47,10 +48,10 @@ func DealUserWallet(session *xorm.Session, req md.DealUserWalletReq) (err error) if req.Direction == "add" { userWalletFlow.Direction = 1 - userWalletFlow.AfterAmount = amountValue.Add(amountValue).RoundFloor(8).String() + userWalletFlow.AfterAmount = beforeAmountValue.Add(amountValue).RoundFloor(8).String() } else if req.Direction == "sub" { userWalletFlow.Direction = 2 - userWalletFlow.AfterAmount = amountValue.Sub(amountValue).RoundFloor(8).String() + userWalletFlow.AfterAmount = beforeAmountValue.Sub(amountValue).RoundFloor(8).String() if zhios_order_relate_utils.StrToFloat64(userWalletFlow.AfterAmount) < 0 { return errors.New("用户钱包余额不足") }