fix(wallet): 保留历史分销用户零租户归属

This commit is contained in:
yml
2026-11-26 22:39:39 +08:00
parent a6e7631a7d
commit fab8301569
2 changed files with 30 additions and 3 deletions
@@ -277,9 +277,10 @@ func resolveTenantID(db *gorm.DB, explicitTenantID uint64, userID uint64) uint64
return explicitTenantID
}
if userID > 0 {
var tenantID uint64
if err := db.Model(&model.User{}).Select("tenant_id").Where("id = ?", userID).Scan(&tenantID).Error; err == nil && tenantID > 0 {
return tenantID
var user model.User
if err := db.Select("tenant_id").Where("id = ?", userID).Take(&user).Error; err == nil {
// 历史分销用户明确属于 tenant_id=0,不能再用当前后台租户覆盖。
return user.TenantID
}
}
if tenantID := tenantIDFromDB(db); tenantID > 0 {