feat(withdrawal): 开放售后提现审核权限
This commit is contained in:
@@ -560,6 +560,22 @@ func TestWithdrawalAdminAllTenantScopeIncludesLegacyDistribution(t *testing.T) {
|
||||
t.Fatalf("dachui admin legacy detail error = %v, want not found", err)
|
||||
}
|
||||
|
||||
dachuiFinanceCtx := tenancy.WithScope(context.Background(), tenancy.Scope{
|
||||
TenantID: 101, TenantCode: "dachui",
|
||||
})
|
||||
legacyList, err := repo.AdminList(dachuiFinanceCtx, AdminListQuery{Page: 1, Size: 20})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if legacyList.Total != 2 || len(legacyList.Items) != 2 {
|
||||
t.Fatalf("dachui withdrawal list with legacy records = %+v, want 2", legacyList)
|
||||
}
|
||||
if detail, err := repo.AdminFindByID(dachuiFinanceCtx, withdrawals[0].ID); err != nil {
|
||||
t.Fatalf("dachui legacy detail: %v", err)
|
||||
} else if detail.DistributionSiteID != site.ID {
|
||||
t.Fatalf("dachui legacy detail site = %d, want %d", detail.DistributionSiteID, site.ID)
|
||||
}
|
||||
|
||||
superCtx := tenancy.WithAdminAllTenantScope(dachuiCtx)
|
||||
superList, err := repo.AdminList(superCtx, AdminListQuery{Page: 1, Size: 20})
|
||||
if err != nil {
|
||||
@@ -576,7 +592,7 @@ func TestWithdrawalAdminAllTenantScopeIncludesLegacyDistribution(t *testing.T) {
|
||||
t.Fatalf("legacy withdrawal detail = %+v", detail)
|
||||
}
|
||||
approved := true
|
||||
reviewed, err := repo.Review(superCtx, 1, withdrawals[0].ID, ReviewWithdrawalRequest{Approved: &approved})
|
||||
reviewed, err := repo.Review(dachuiFinanceCtx, 1, withdrawals[0].ID, ReviewWithdrawalRequest{Approved: &approved})
|
||||
if err != nil {
|
||||
t.Fatalf("platform super admin legacy review: %v", err)
|
||||
}
|
||||
|
||||
@@ -86,11 +86,14 @@ func scopeAdminTenant(ctx context.Context, db *gorm.DB, column string) *gorm.DB
|
||||
if tenancy.HasAdminAllTenantScope(ctx) {
|
||||
return db
|
||||
}
|
||||
tenantID := tenancy.IDFromContext(ctx)
|
||||
if tenantID > 0 {
|
||||
return db.Where(column+" = ?", tenantID)
|
||||
scope, ok := tenancy.FromContext(ctx)
|
||||
if !ok {
|
||||
return db
|
||||
}
|
||||
return db
|
||||
if scope.TenantCode == "dachui" {
|
||||
return db.Where("("+column+" = ? OR "+column+" = 0)", scope.TenantID)
|
||||
}
|
||||
return db.Where(column+" = ?", scope.TenantID)
|
||||
}
|
||||
|
||||
func (r *Repository) withdrawalReviewSummary(ctx context.Context, userID, siteID uint64) (WithdrawalReviewSummaryDTO, error) {
|
||||
|
||||
Reference in New Issue
Block a user