fix: 修复分页字段/角色DTO/套餐详情/批量分配Bug,新增C端测试登录接口和Hurl价格验证测试
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled

- 修复B-2:27个分页DTO字段名统一(list→items, page_size→size,删除total_pages)
- 修复B-1:角色接口统一返回DTO(id小写,消除GORM大写字段名)
- 修复C-1:套餐详情接口(GET /packages/:id)补充代理佣金字段
- 修复C-2:批量分配已存在记录由500改为静默跳过
- 修复C-3:创建系列授权响应在事务提交后构建,packages数组不再为空
- 新增C端开发测试登录接口(POST /api/c/v1/auth/dev-login,仅logging.development=true时生效)
- 新增Hurl测试:card-price-verification-flow.hurl(导入卡→分配→C端价格验证)
- 新增测试Excel数据文件和dev.env测试变量
This commit is contained in:
2026-03-31 09:54:08 +08:00
parent 33e7f99fdc
commit 2ef8b8a705
54 changed files with 1697 additions and 260 deletions

View File

@@ -212,6 +212,12 @@ func (s *Service) Create(ctx context.Context, req *dto.CreateShopSeriesGrantRequ
return nil, errors.New(errors.CodeInvalidParam, "该系列未启用一次性佣金,无法创建授权")
}
// 1.5 校验目标店铺是否存在
_, err = s.shopStore.GetByID(ctx, req.ShopID)
if err != nil {
return nil, errors.New(errors.CodeNotFound, "目标店铺不存在")
}
// 2. 检查重复授权
exists, err := s.shopSeriesAllocationStore.ExistsByShopAndSeries(ctx, req.ShopID, req.SeriesID)
if err != nil {
@@ -300,7 +306,6 @@ func (s *Service) Create(ctx context.Context, req *dto.CreateShopSeriesGrantRequ
}
// 6. 事务中创建 ShopSeriesAllocation + N 条 ShopPackageAllocation
var result *dto.ShopSeriesGrantResponse
err = s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
txSeriesStore := postgres.NewShopSeriesAllocationStore(tx)
if createErr := txSeriesStore.Create(ctx, allocation); createErr != nil {
@@ -353,15 +358,14 @@ func (s *Service) Create(ctx context.Context, req *dto.CreateShopSeriesGrantRequ
}
}
var buildErr error
result, buildErr = s.buildGrantResponse(ctx, allocation, series, config)
return buildErr
return nil
})
if err != nil {
return nil, err
}
return result, nil
// 事务提交后构建完整响应(此时 packages 已可查询到)
return s.buildGrantResponse(ctx, allocation, series, config)
}
// Get 查询单条系列授权详情
@@ -494,17 +498,11 @@ func (s *Service) List(ctx context.Context, req *dto.ShopSeriesGrantListRequest)
items = append(items, item)
}
totalPages := int(total) / pageSize
if int(total)%pageSize != 0 {
totalPages++
}
return &dto.ShopSeriesGrantPageResult{
List: items,
Total: total,
Page: page,
PageSize: pageSize,
TotalPages: totalPages,
List: items,
Total: total,
Page: page,
PageSize: pageSize,
}, nil
}