fix(tenant): 收紧双站运营提号与录单边界
This commit is contained in:
@@ -3,16 +3,44 @@ package admindashboard
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"hfb_sys/backend/internal/database"
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/tenancy"
|
||||
"hfb_sys/backend/internal/timeutil"
|
||||
)
|
||||
|
||||
func dashboardTenantContext(tenantID uint64) context.Context {
|
||||
return tenancy.WithScope(context.Background(), tenancy.Scope{TenantID: tenantID})
|
||||
}
|
||||
|
||||
func TestManualEntryTodayScopesByTenant(t *testing.T) {
|
||||
db := database.NewTestDB()
|
||||
now := time.Date(2026, 11, 16, 12, 0, 0, 0, timeutil.ShanghaiLocation())
|
||||
entries := []model.CSManualEntry{
|
||||
{TenantID: 101, EntryNo: "MT-A", EntryGroup: "collect", AdminID: 1, AdminName: "A客服", CreatedAt: now},
|
||||
{TenantID: 202, EntryNo: "MT-B", EntryGroup: "sell", AdminID: 2, AdminName: "B客服", CreatedAt: now},
|
||||
}
|
||||
if err := db.Create(&entries).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
repo := NewRepository(db)
|
||||
itemsA, err := repo.manualEntryToday(dashboardTenantContext(101), now)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
itemsB, err := repo.manualEntryToday(dashboardTenantContext(202), now)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(itemsA) != 1 || itemsA[0].AdminName != "A客服" ||
|
||||
len(itemsB) != 1 || itemsB[0].AdminName != "B客服" {
|
||||
t.Fatalf("tenant manual entry stats A=%+v B=%+v", itemsA, itemsB)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSummaryScopesBuyerAndSourceMetricsByTenant(t *testing.T) {
|
||||
db := database.NewTestDB()
|
||||
tenants := []model.Tenant{
|
||||
|
||||
Reference in New Issue
Block a user