Browse Source

处理给用户金额调整

master
huangjiajun 1 month ago
parent
commit
09a6749b5f
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      rule/user_wallet.go

+ 3
- 2
rule/user_wallet.go View File

@@ -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("用户钱包余额不足")
}


Loading…
Cancel
Save