Files
36Wisdom/biz/service/redemption.go
T
2026-08-14 12:13:02 +08:00

30 lines
732 B
Go

package service
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
"36wisdom/biz/dao"
)
type redemption struct{}
var Redemption = &redemption{}
// ListByUser 孩子兑换记录(按创建时间倒序)。
func (s *redemption) ListByUser(ctx context.Context, userId int64) ([]gdb.Record, error) {
return dao.Redemption.Model().Ctx(ctx).Where("user_id", userId).Order("id DESC").All()
}
// Insert 创建兑换记录。
func (s *redemption) Insert(ctx context.Context, userId, prizeId int64, pointsCost int) (int64, error) {
return dao.Redemption.InsertAndReturnId(ctx, g.Map{
"user_id": userId,
"prize_id": prizeId,
"points_cost": pointsCost,
"status": 1,
})
}