fix(distribution): 统一分销订单租户管理口径
This commit is contained in:
@@ -86,6 +86,13 @@ func TestSummaryScopesBuyerAndSourceMetricsByTenant(t *testing.T) {
|
||||
if err := db.Create(&listingB).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
site := model.DistributionSite{
|
||||
SiteCode: "dashboard_shared_dist", SiteName: "看板共享货源站",
|
||||
Domain: "dashboard-shared.example.com", Status: "active",
|
||||
}
|
||||
if err := db.Create(&site).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
orders := []model.RentalOrder{
|
||||
{
|
||||
OrderNo: "RO-DASHBOARD-A-BUY", ListingID: listingB.ID, AccountID: accountB.ID,
|
||||
@@ -99,10 +106,23 @@ func TestSummaryScopesBuyerAndSourceMetricsByTenant(t *testing.T) {
|
||||
SourceTenantID: 101, PaymentTenantID: 202, RentAmountCent: 3000,
|
||||
OwnerRentAmountCent: 1800, SourceAmountCent: 1800, Status: "completed",
|
||||
},
|
||||
{
|
||||
OrderNo: "RO-DASHBOARD-A-SHARED", ListingID: listingB.ID, AccountID: accountB.ID,
|
||||
OwnerID: users[2].ID, RenterID: users[0].ID, BuyerTenantID: 101,
|
||||
SourceTenantID: 202, PaymentTenantID: 101, RentAmountCent: 4000,
|
||||
OwnerRentAmountCent: 2600, SourceAmountCent: 2600, Status: "completed",
|
||||
DistributionSiteID: &site.ID, DistributionMode: "two_party_distributor_receive",
|
||||
},
|
||||
}
|
||||
if err := db.Create(&orders).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.Create(&model.Dispute{
|
||||
OrderID: orders[2].ID, InitiatorID: users[0].ID, InitiatorType: "user",
|
||||
TargetUserID: users[2].ID, Type: "cannot_login", Status: "open",
|
||||
}).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
summary, err := NewRepository(db).Summary(dashboardTenantContext(101))
|
||||
if err != nil {
|
||||
@@ -114,18 +134,22 @@ func TestSummaryScopesBuyerAndSourceMetricsByTenant(t *testing.T) {
|
||||
if summary.Metrics.TotalListings != 1 || summary.Metrics.PublishedListings != 1 {
|
||||
t.Fatalf("tenant listing metrics = %+v", summary.Metrics)
|
||||
}
|
||||
if summary.Metrics.TotalOrders != 2 {
|
||||
t.Fatalf("tenant relevant order count = %d, want 2", summary.Metrics.TotalOrders)
|
||||
if summary.Metrics.TotalOrders != 3 {
|
||||
t.Fatalf("tenant relevant order count = %d, want 3", summary.Metrics.TotalOrders)
|
||||
}
|
||||
if summary.Tenant == nil {
|
||||
t.Fatal("tenant statistics missing")
|
||||
}
|
||||
if summary.Tenant.BuyerOrderCount != 1 || summary.Tenant.BuyerGMVCent != 2500 {
|
||||
if summary.Tenant.BuyerOrderCount != 2 || summary.Tenant.BuyerGMVCent != 6500 {
|
||||
t.Fatalf("buyer tenant stats = %+v", summary.Tenant)
|
||||
}
|
||||
if summary.Tenant.SourceOrderCount != 1 || summary.Tenant.SourceAmountCent != 1800 {
|
||||
t.Fatalf("source tenant stats = %+v", summary.Tenant)
|
||||
}
|
||||
if summary.Pending.Disputes != 1 || len(summary.RecentDisputes) != 1 {
|
||||
t.Fatalf("distribution disputes missing from tenant dashboard: pending=%+v recent=%+v",
|
||||
summary.Pending, summary.RecentDisputes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSummaryPendingReviewsIncludeTenantDistributionSites(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user