diff --git a/models/models.go b/models/models.go index ea550cb839fed..57c971c5edece 100644 --- a/models/models.go +++ b/models/models.go @@ -113,6 +113,7 @@ func init() { new(OAuth2AuthorizationCode), new(OAuth2Grant), new(Task), + new(Transfer), ) gonicNames := []string{"SSL", "UID"} diff --git a/models/transfer_point.go b/models/transfer_point.go index e8939699bb804..3916dbde0641d 100644 --- a/models/transfer_point.go +++ b/models/transfer_point.go @@ -26,9 +26,9 @@ func TransferPoint(FromID int64, Why string, ToID int64, Qty int) (err error) { return err } -// if _, err = sess.Insert(&Transfer{FromID: FromID, ToID: ToID, Why: Why, Qty: Qty}); err != nil { -// return err -// } + if _, err = sess.Insert(&Transfer{FromID: FromID, ToID: ToID, Why: Why, Qty: Qty}); err != nil { + return err + } if _, err = sess.Exec("UPDATE `user` SET point = point + ? WHERE id = ?", Qty, ToID); err != nil { return err diff --git a/routers/user/profile.go b/routers/user/profile.go index 62db36f668ae5..f3ebaa0351821 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -280,6 +280,11 @@ func TransferP(ctx *context.Context) { var err error Qty, err := strconv.Atoi(ctx.Query("qty")) if err != nil { + ctx.Flash.Error("请输入数字") + return + } + if ctx.User.Point < Qty { + ctx.Flash.Error("余额不足!") return } err = models.TransferPoint(ctx.User.ID,