fix: issues

This commit is contained in:
Rogee
2024-12-13 10:38:54 +08:00
parent 5a6b7bcdae
commit 19f445144d
13 changed files with 262 additions and 67 deletions

View File

@@ -413,3 +413,28 @@ func (svc *Service) SetTenantBindUserID(ctx context.Context, tenantID, adminUser
}
return nil
}
// GetBalanceHistory
func (svc *Service) GetBalanceHistory(ctx context.Context, tenantID, userID int64) ([]model.UserBalanceHistories, error) {
log := svc.log.WithField("method", "GetBalanceHistory")
tbl := table.UserBalanceHistories
stmt := tbl.
SELECT(
tbl.AllColumns,
).
WHERE(
tbl.TenantID.EQ(Int64(tenantID)).AND(tbl.UserID.EQ(Int64(userID))),
).
ORDER_BY(
tbl.CreatedAt.DESC(),
).
LIMIT(20)
log.Debug(stmt.DebugSql())
var items []model.UserBalanceHistories
if err := stmt.QueryContext(ctx, db.FromContext(ctx, svc.db), &items); err != nil {
return nil, errors.Wrap(err, "failed to query balance history")
}
return items, nil
}