fix(tenant): 收紧双站后台边界并补齐货架管理
This commit is contained in:
@@ -97,8 +97,64 @@ func TestOverviewAggregatesAllTenantsAndSites(t *testing.T) {
|
||||
if err := db.Create(&withdrawals).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
legacySite := model.DistributionSite{
|
||||
SiteCode: "legacy_platform_ops", SiteName: "历史分销测试站",
|
||||
Domain: "legacy-platform-ops.example.com", Status: "active",
|
||||
}
|
||||
if err := db.Create(&legacySite).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
legacyUser := model.User{
|
||||
TenantID: tenants[0].ID, Phone: "13100000999", Status: "active",
|
||||
DistributionSiteID: legacySite.ID,
|
||||
}
|
||||
if err := db.Create(&legacyUser).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
legacyAccount := model.GameAccount{
|
||||
SourceTenantID: tenants[0].ID, OwnerID: legacyUser.ID,
|
||||
GameName: "delta_force", ServerRegion: "国服", LoginPlatform: "QQ",
|
||||
Title: "历史分销商品", Status: "published",
|
||||
}
|
||||
if err := db.Create(&legacyAccount).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
legacyListing := model.RentalListing{
|
||||
SourceTenantID: tenants[0].ID, ListingNo: "OPS-LEGACY-DIST",
|
||||
AccountID: legacyAccount.ID, OwnerID: legacyUser.ID,
|
||||
Status: "published", ReviewStatus: "approved", PriceCent: 5000,
|
||||
DistributionSiteID: &legacySite.ID,
|
||||
}
|
||||
if err := db.Create(&legacyListing).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
legacyOrder := model.RentalOrder{
|
||||
OrderNo: "OPS-LEGACY-ORDER", BuyerTenantID: tenants[0].ID,
|
||||
SourceTenantID: tenants[0].ID, PaymentTenantID: tenants[0].ID,
|
||||
ListingID: legacyListing.ID, AccountID: legacyAccount.ID,
|
||||
OwnerID: legacyUser.ID, RenterID: legacyUser.ID,
|
||||
Status: "completed", RentAmountCent: 5000, SourceAmountCent: 4000,
|
||||
DistributionSiteID: &legacySite.ID,
|
||||
}
|
||||
if err := db.Create(&legacyOrder).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.Create(&model.WalletLedger{
|
||||
LedgerNo: "OPS-LEGACY-WL", TenantID: tenants[0].ID, UserID: legacyUser.ID,
|
||||
DistributionSiteID: legacySite.ID, Direction: "in", AmountCent: 5000,
|
||||
BalanceType: "available", BizType: "owner_income", BizNo: legacyOrder.OrderNo,
|
||||
}).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.Create(&model.WithdrawalRequest{
|
||||
WithdrawNo: "OPS-LEGACY-WD", TenantID: tenants[0].ID, UserID: legacyUser.ID,
|
||||
DistributionSiteID: legacySite.ID, AmountCent: 500, ActualAmountCent: 500,
|
||||
AccountType: "bank", AccountName: "历史站用户", AccountNo: "****9999", Status: "pending",
|
||||
}).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var userCount int64
|
||||
if err := db.Model(&model.User{}).Count(&userCount).Error; err != nil || userCount != 4 {
|
||||
if err := db.Model(&model.User{}).Count(&userCount).Error; err != nil || userCount != 5 {
|
||||
t.Fatalf("seeded users = %d, err=%v", userCount, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user