fix(tenant): 收紧双站运营提号与录单边界

This commit is contained in:
yml
2026-11-16 16:12:55 +08:00
parent 1108df195d
commit 1ce9f7aaf5
60 changed files with 1531 additions and 337 deletions
@@ -535,9 +535,6 @@ func (r *Repository) tradingDailyOverview(ctx context.Context, now time.Time, da
// 录单表是后来新增的功能表,若迁移尚未执行(表不存在)则降级为空统计,
// 避免连带整个仪表盘不可用。
func (r *Repository) manualEntryToday(ctx context.Context, now time.Time) ([]ManualEntryAgentStatsDTO, error) {
if tenancy.IDFromContext(ctx) > 0 {
return []ManualEntryAgentStatsDTO{}, nil
}
if r.db == nil || !r.db.Migrator().HasTable("cs_manual_entries") {
return []ManualEntryAgentStatsDTO{}, nil
}
@@ -551,7 +548,11 @@ func (r *Repository) manualEntryToday(ctx context.Context, now time.Time) ([]Man
Count int64
}
rows := make([]row, 0)
if err := r.db.WithContext(ctx).Table("cs_manual_entries").
query := r.db.WithContext(ctx).Table("cs_manual_entries")
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
query = query.Where("tenant_id = ?", tenantID)
}
if err := query.
Select("admin_id, MAX(admin_name) AS admin_name, COUNT(*) AS count").
Where("created_at >= ? AND created_at < ?", start, end).
Group("admin_id").