修复超管无法回收资产的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m0s

This commit is contained in:
2026-02-27 11:03:44 +08:00
parent 4189dbe98f
commit f5000f2bfc
4 changed files with 28 additions and 33 deletions

View File

@@ -21,12 +21,12 @@ func GetSubordinateShopIDs(ctx context.Context) []uint {
}
// ApplyShopFilter 应用店铺数据权限过滤
// 平台用户/超管不添加条件SubordinateShopIDs 为 nil
// 平台用户/超管不添加条件SubordinateShopIDs 为 nil 或空数组
// 代理用户WHERE shop_id IN (subordinateShopIDs)
// 注意NULL shop_id 的记录对代理用户不可见
func ApplyShopFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
shopIDs := GetSubordinateShopIDs(ctx)
if shopIDs == nil {
if len(shopIDs) == 0 {
return query
}
return query.Where("shop_id IN ?", shopIDs)
@@ -50,11 +50,11 @@ func ApplyEnterpriseFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
// ApplyOwnerShopFilter 应用归属店铺数据权限过滤
// 用于 Enterprise 等使用 owner_shop_id 字段的表
// 平台用户/超管:不添加条件
// 平台用户/超管:不添加条件SubordinateShopIDs 为 nil 或空数组)
// 代理用户WHERE owner_shop_id IN (subordinateShopIDs)
func ApplyOwnerShopFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
shopIDs := GetSubordinateShopIDs(ctx)
if shopIDs == nil {
if len(shopIDs) == 0 {
return query
}
return query.Where("owner_shop_id IN ?", shopIDs)
@@ -68,11 +68,11 @@ func IsUnrestricted(ctx context.Context) bool {
// ApplySellerShopFilter 应用销售店铺数据权限过滤
// 用于 Order 等使用 seller_shop_id 字段的表
// 平台用户/超管:不添加条件
// 平台用户/超管:不添加条件SubordinateShopIDs 为 nil 或空数组)
// 代理用户WHERE seller_shop_id IN (subordinateShopIDs)
func ApplySellerShopFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
shopIDs := GetSubordinateShopIDs(ctx)
if shopIDs == nil {
if len(shopIDs) == 0 {
return query
}
return query.Where("seller_shop_id IN ?", shopIDs)
@@ -80,11 +80,11 @@ func ApplySellerShopFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
// ApplyShopTagFilter 应用店铺标签数据权限过滤
// 用于 CardWallet 等使用 shop_id_tag 字段的表
// 平台用户/超管:不添加条件
// 平台用户/超管:不添加条件SubordinateShopIDs 为 nil 或空数组)
// 代理用户WHERE shop_id_tag IN (subordinateShopIDs)
func ApplyShopTagFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
shopIDs := GetSubordinateShopIDs(ctx)
if shopIDs == nil {
if len(shopIDs) == 0 {
return query
}
return query.Where("shop_id_tag IN ?", shopIDs)
@@ -92,11 +92,11 @@ func ApplyShopTagFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
// ApplyShopIDFilter 应用店铺主键数据权限过滤
// 用于 Shop 表,根据 id 字段过滤
// 平台用户/超管:不添加条件
// 平台用户/超管:不添加条件SubordinateShopIDs 为 nil 或空数组)
// 代理用户WHERE id IN (subordinateShopIDs)
func ApplyShopIDFilter(ctx context.Context, query *gorm.DB) *gorm.DB {
shopIDs := GetSubordinateShopIDs(ctx)
if shopIDs == nil {
if len(shopIDs) == 0 {
return query
}
return query.Where("id IN ?", shopIDs)