From efe8a362aa7e871c806df2af94abb6cd1beb221b Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 25 Feb 2026 16:37:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B9=B3=E5=8F=B0=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E5=8F=AF=E5=9B=9E=E6=94=B6=E6=89=80=E6=9C=89=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E7=9A=84=E5=8D=A1=E5=92=8C=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前平台用户回收时只能回收一级代理的资产,现在允许回收所有店铺的资产。 修改: - iot_card/service.go: isDirectSubordinate 对平台用户返回 true - device/service.go: RecallDevices 平台用户跳过直属下级验证 Co-Authored-By: Claude Opus 4.5 --- internal/service/device/service.go | 18 ++++++++++-------- internal/service/iot_card/service.go | 7 ++++--- 2 files changed, 14 insertions(+), 11 deletions(-) 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