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