fix(withdrawal): 恢复分销站点用户提现审核可见性
This commit is contained in:
@@ -17,9 +17,9 @@ import (
|
||||
// 管理员查询提现列表
|
||||
func (r *Repository) AdminList(ctx context.Context, query AdminListQuery) (*AdminPaginatedResult, error) {
|
||||
db := r.db.WithContext(ctx).Model(&model.WithdrawalRequest{})
|
||||
// distribution_site_id 只表示获客渠道,不能把同租户内分销站点用户的提现挡在财务审核列表外。
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
db = db.Where("tenant_id = ?", tenantID).
|
||||
Where("distribution_site_id = 0")
|
||||
db = db.Where("tenant_id = ?", tenantID)
|
||||
}
|
||||
|
||||
if query.Status != "" {
|
||||
|
||||
@@ -421,6 +421,13 @@ func TestWithdrawalRequestsAreScopedByTenant(t *testing.T) {
|
||||
if err := db.Create(&jieyouUser).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
site := model.DistributionSite{
|
||||
SiteCode: "tianyu_test", SiteName: "天域商行",
|
||||
Domain: "tianyu.example.com", Status: "active",
|
||||
}
|
||||
if err := db.Create(&site).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dachuiAccount := model.UserPaymentAccount{
|
||||
TenantID: 101, UserID: dachuiUser.ID, AccountType: "bank",
|
||||
AccountName: "张三", AccountNo: "encrypted", Status: "active",
|
||||
@@ -454,6 +461,21 @@ func TestWithdrawalRequestsAreScopedByTenant(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("create dachui withdrawal: %v", err)
|
||||
}
|
||||
siteWithdrawal := model.WithdrawalRequest{
|
||||
WithdrawNo: "WD-TENANT-SITE",
|
||||
TenantID: 101,
|
||||
UserID: dachuiUser.ID,
|
||||
DistributionSiteID: site.ID,
|
||||
AmountCent: 1500,
|
||||
ActualAmountCent: 1500,
|
||||
AccountType: "bank",
|
||||
AccountName: "张三",
|
||||
AccountNo: "****0000",
|
||||
Status: "pending",
|
||||
}
|
||||
if err := db.Create(&siteWithdrawal).Error; err != nil {
|
||||
t.Fatalf("create distribution site withdrawal: %v", err)
|
||||
}
|
||||
if _, err := repo.Create(jieyouCtx, jieyouUser.ID, CreateWithdrawalRequest{
|
||||
PaymentAccountID: jieyouAccount.ID,
|
||||
AmountCent: 2000,
|
||||
@@ -471,6 +493,25 @@ func TestWithdrawalRequestsAreScopedByTenant(t *testing.T) {
|
||||
if _, err := repo.FindByID(jieyouCtx, dachuiUser.ID, dachuiWithdrawal.ID); !errors.Is(err, ErrWithdrawalNotFound) {
|
||||
t.Fatalf("cross-tenant withdrawal lookup error = %v", err)
|
||||
}
|
||||
dachuiList, err := repo.AdminList(dachuiCtx, AdminListQuery{Page: 1, Size: 20})
|
||||
if err != nil {
|
||||
t.Fatalf("dachui withdrawal list: %v", err)
|
||||
}
|
||||
if dachuiList.Total != 2 || len(dachuiList.Items) != 2 {
|
||||
t.Fatalf("dachui withdrawal list = %+v, want 2 withdrawals", dachuiList)
|
||||
}
|
||||
foundSiteWithdrawal := false
|
||||
for _, item := range dachuiList.Items {
|
||||
if item.ID == siteWithdrawal.ID {
|
||||
foundSiteWithdrawal = true
|
||||
if item.DistributionSiteID != site.ID || item.DistributionSiteName != site.SiteName {
|
||||
t.Fatalf("distribution site withdrawal item = %+v", item)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !foundSiteWithdrawal {
|
||||
t.Fatal("dachui admin list hides distribution site withdrawal")
|
||||
}
|
||||
list, err := repo.AdminList(jieyouCtx, AdminListQuery{Page: 1, Size: 20})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user