新增状态筛选条件,同时修复价格未正常写入的情况
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m35s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m35s
This commit is contained in:
@@ -648,9 +648,9 @@ func parseGatewayTime(raw gateway.FlexString) *time.Time {
|
||||
return &t
|
||||
}
|
||||
|
||||
// GetPackages 获取资产的所有套餐列表(支持分页)
|
||||
// GetPackages 获取资产的所有套餐列表(支持分页和状态筛选)
|
||||
// page 默认 1,pageSize 默认 50,pageSize 最大 100
|
||||
func (s *Service) GetPackages(ctx context.Context, assetType string, id uint, page, pageSize int) (*dto.AssetPackagesResult, error) {
|
||||
func (s *Service) GetPackages(ctx context.Context, assetType string, id uint, page, pageSize int, status *int) (*dto.AssetPackagesResult, error) {
|
||||
// 分页参数边界处理
|
||||
if page < 1 {
|
||||
page = 1
|
||||
@@ -661,6 +661,9 @@ func (s *Service) GetPackages(ctx context.Context, assetType string, id uint, pa
|
||||
if pageSize > 100 {
|
||||
pageSize = 100
|
||||
}
|
||||
if status != nil && (*status < constants.PackageUsageStatusPending || *status > constants.PackageUsageStatusInvalidated) {
|
||||
return nil, errors.New(errors.CodeInvalidParam, "套餐状态非法")
|
||||
}
|
||||
|
||||
// assetType 对应 Store 中的 carrierType:card→iot_card, device→device
|
||||
carrierType := assetType
|
||||
@@ -668,7 +671,7 @@ func (s *Service) GetPackages(ctx context.Context, assetType string, id uint, pa
|
||||
carrierType = "iot_card"
|
||||
}
|
||||
|
||||
usages, err := s.packageUsageStore.ListByCarrier(ctx, carrierType, id)
|
||||
usages, err := s.packageUsageStore.ListByCarrier(ctx, carrierType, id, status)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeInternalError, err, "查询套餐使用记录失败")
|
||||
}
|
||||
@@ -706,7 +709,6 @@ func (s *Service) GetPackages(ctx context.Context, assetType string, id uint, pa
|
||||
pkgType = pkg.PackageType
|
||||
enableVirtualData = pkg.EnableVirtualData
|
||||
}
|
||||
|
||||
item := &dto.AssetPackageResponse{
|
||||
PackageUsageID: u.ID,
|
||||
PackageID: u.PackageID,
|
||||
@@ -784,7 +786,6 @@ func (s *Service) GetCurrentPackage(ctx context.Context, assetType string, id ui
|
||||
pkgType = pkg.PackageType
|
||||
enableVirtualData = pkg.EnableVirtualData
|
||||
}
|
||||
|
||||
return &dto.AssetPackageResponse{
|
||||
PackageUsageID: usage.ID,
|
||||
PackageID: usage.PackageID,
|
||||
|
||||
Reference in New Issue
Block a user