fix: 平台账号可回收所有店铺的卡和设备
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m4s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m4s
之前平台用户回收时只能回收一级代理的资产,现在允许回收所有店铺的资产。 修改: - iot_card/service.go: isDirectSubordinate 对平台用户返回 true - device/service.go: RecallDevices 平台用户跳过直属下级验证 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user