diff --git a/internal/service/device/service.go b/internal/service/device/service.go index 00429f2..31bfe6a 100644 --- a/internal/service/device/service.go +++ b/internal/service/device/service.go @@ -311,14 +311,16 @@ func (s *Service) RecallDevices(ctx context.Context, req *dto.RecallDevicesReque continue } - // 验证直属下级关系 - if err := s.validateDirectSubordinate(ctx, operatorShopID, *device.ShopID); err != nil { - failedItems = append(failedItems, dto.AllocationDeviceFailedItem{ - DeviceID: device.ID, - DeviceNo: device.DeviceNo, - Reason: "只能回收直属下级店铺的设备", - }) - continue + // 验证直属下级关系(平台用户可以回收所有店铺的设备) + if !isPlatform { + if err := s.validateDirectSubordinate(ctx, operatorShopID, *device.ShopID); err != nil { + failedItems = append(failedItems, dto.AllocationDeviceFailedItem{ + DeviceID: device.ID, + DeviceNo: device.DeviceNo, + Reason: "只能回收直属下级店铺的设备", + }) + continue + } } deviceIDs = append(deviceIDs, device.ID) diff --git a/internal/service/iot_card/service.go b/internal/service/iot_card/service.go index 8a3cee2..4e3f9b2 100644 --- a/internal/service/iot_card/service.go +++ b/internal/service/iot_card/service.go @@ -525,11 +525,12 @@ func (s *Service) RecallCards(ctx context.Context, req *dto.RecallStandaloneCard }, nil } -// isDirectSubordinate 检查店铺是否是操作者的直属下级 +// isDirectSubordinate 检查店铺是否是操作者的可回收范围 +// 平台用户可以回收所有店铺的卡,代理用户只能回收直属下级店铺的卡 func (s *Service) isDirectSubordinate(operatorShopID *uint, shop *model.Shop) bool { if operatorShopID == nil { - // 平台用户:直属下级是 parent_id 为空的店铺 - return shop.ParentID == nil + // 平台用户:可以回收所有店铺的卡 + return true } // 代理用户:直属下级是 parent_id 等于自己的店铺 return shop.ParentID != nil && *shop.ParentID == *operatorShopID