feat: update models
This commit is contained in:
@@ -41,17 +41,22 @@ func (ctl *orders) Refund(ctx fiber.Ctx, id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
user, err := model.UsersModel.GetByID(ctx.Context(), order.UserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
post, err := model.PostsModel.GetByID(ctx.Context(), order.PostID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if order.PaymentMethod == "balance" {
|
||||
if err := model.UsersModel.AddBalance(ctx.Context(), order.UserID, order.Meta.Data.CostBalance); err != nil {
|
||||
if err := user.AddBalance(ctx.Context(), order.Meta.Data.CostBalance); err != nil {
|
||||
return errors.Wrap(err, "add balance failed")
|
||||
}
|
||||
|
||||
if err := model.UsersModel.RevokePosts(ctx.Context(), order.UserID, order.PostID); err != nil {
|
||||
if err := user.RevokePosts(ctx.Context(), order.PostID); err != nil {
|
||||
return errors.Wrap(err, "revoke posts failed")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user