fix(distribution): 统一分销订单租户管理口径
This commit is contained in:
@@ -120,10 +120,18 @@ func TestTenantOrderWithoutOwnConfigDoesNotUseOtherTenantDefault(t *testing.T) {
|
||||
|
||||
func TestRefundAndOrderPaymentsUsePaymentTenant(t *testing.T) {
|
||||
db := database.NewTestDB()
|
||||
site := model.DistributionSite{
|
||||
SiteCode: "payment_scope_dist", SiteName: "支付归属测试站",
|
||||
Domain: "payment-scope.example.com", Status: "active",
|
||||
}
|
||||
if err := db.Create(&site).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
order := model.RentalOrder{
|
||||
BuyerTenantID: 202, SourceTenantID: 101, PaymentTenantID: 202,
|
||||
OrderNo: "RO-CROSS-SITE-REFUND", RenterID: 1,
|
||||
RentAmountCent: 1000, DepositAmountCent: 500, Status: "renting",
|
||||
DistributionSiteID: &site.ID, DistributionMode: "two_party_distributor_receive",
|
||||
}
|
||||
if err := db.Create(&order).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -155,7 +163,20 @@ func TestRefundAndOrderPaymentsUsePaymentTenant(t *testing.T) {
|
||||
t.Fatalf("order payments = %+v", items)
|
||||
}
|
||||
|
||||
list, err := repo.AdminList(paymentTenantContext(202), AdminPaymentQuery{Page: 1, PageSize: 20})
|
||||
if err != nil {
|
||||
t.Fatalf("tenant payment list: %v", err)
|
||||
}
|
||||
if list.Total != 1 {
|
||||
t.Fatalf("tenant payment list total = %d, want 1; items=%+v", list.Total, list.Items)
|
||||
}
|
||||
|
||||
if _, err := repo.OrderPayments(paymentTenantContext(303), order.ID); !errors.Is(err, ErrPaymentNotFound) {
|
||||
t.Fatalf("unrelated tenant payment access error = %v", err)
|
||||
}
|
||||
if list, err := repo.AdminList(paymentTenantContext(303), AdminPaymentQuery{Page: 1, PageSize: 20}); err != nil {
|
||||
t.Fatalf("unrelated tenant payment list: %v", err)
|
||||
} else if list.Total != 0 {
|
||||
t.Fatalf("unrelated tenant payment list leaked %d rows", list.Total)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user