add auto comb cost price
This commit is contained in:
@@ -10,6 +10,7 @@ type PackageItemResponse struct {
|
||||
ProductName string `json:"product_name" comment:"子产品名称"`
|
||||
SortOrder int `json:"sort_order" comment:"排序"`
|
||||
Price float64 `json:"price" comment:"子产品价格"`
|
||||
CostPrice float64 `json:"cost_price" comment:"子产品成本价"`
|
||||
}
|
||||
|
||||
// ProductInfoResponse 产品详情响应
|
||||
|
||||
@@ -38,8 +38,8 @@ type ProductApplicationService interface {
|
||||
ReorderPackageItems(ctx context.Context, packageID string, cmd *commands.ReorderPackageItemsCommand) error
|
||||
UpdatePackageItems(ctx context.Context, packageID string, cmd *commands.UpdatePackageItemsCommand) error
|
||||
|
||||
// 可选子产品查询
|
||||
GetAvailableProducts(ctx context.Context, query *queries.GetAvailableProductsQuery) (*responses.ProductListResponse, error)
|
||||
// 可选子产品查询(管理员端,返回包含成本价的数据)
|
||||
GetAvailableProducts(ctx context.Context, query *queries.GetAvailableProductsQuery) (*responses.ProductAdminListResponse, error)
|
||||
|
||||
// API配置管理
|
||||
GetProductApiConfig(ctx context.Context, productID string) (*responses.ProductApiConfigResponse, error)
|
||||
|
||||
@@ -357,9 +357,9 @@ func (s *ProductApplicationServiceImpl) UpdatePackageItems(ctx context.Context,
|
||||
return s.productManagementService.UpdatePackageItemsBatch(ctx, packageID, cmd.Items)
|
||||
}
|
||||
|
||||
// GetAvailableProducts 获取可选子产品列表
|
||||
// 业务流程:1. 获取启用产品 2. 过滤可订阅产品 3. 构建响应数据
|
||||
func (s *ProductApplicationServiceImpl) GetAvailableProducts(ctx context.Context, query *appQueries.GetAvailableProductsQuery) (*responses.ProductListResponse, error) {
|
||||
// GetAvailableProducts 获取可选子产品列表(管理员端,返回包含成本价的数据)
|
||||
// 业务流程:1. 获取启用产品 2. 过滤可订阅产品 3. 构建管理员响应数据
|
||||
func (s *ProductApplicationServiceImpl) GetAvailableProducts(ctx context.Context, query *appQueries.GetAvailableProductsQuery) (*responses.ProductAdminListResponse, error) {
|
||||
// 构建筛选条件
|
||||
filters := make(map[string]interface{})
|
||||
filters["is_package"] = false // 只获取非组合包产品
|
||||
@@ -385,13 +385,13 @@ func (s *ProductApplicationServiceImpl) GetAvailableProducts(ctx context.Context
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 转换为响应对象
|
||||
items := make([]responses.ProductInfoResponse, len(products))
|
||||
// 转换为管理员响应对象(包含成本价,用于组合包配置)
|
||||
items := make([]responses.ProductAdminInfoResponse, len(products))
|
||||
for i := range products {
|
||||
items[i] = *s.convertToProductInfoResponse(products[i])
|
||||
items[i] = *s.convertToProductAdminInfoResponse(products[i])
|
||||
}
|
||||
|
||||
return &responses.ProductListResponse{
|
||||
return &responses.ProductAdminListResponse{
|
||||
Total: total,
|
||||
Page: options.Page,
|
||||
Size: options.PageSize,
|
||||
@@ -514,6 +514,7 @@ func (s *ProductApplicationServiceImpl) convertToProductInfoResponse(product *en
|
||||
ProductName: item.Product.Name,
|
||||
SortOrder: item.SortOrder,
|
||||
Price: item.Product.Price.InexactFloat64(),
|
||||
CostPrice: item.Product.CostPrice.InexactFloat64(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -560,6 +561,7 @@ func (s *ProductApplicationServiceImpl) convertToProductAdminInfoResponse(produc
|
||||
ProductName: item.Product.Name,
|
||||
SortOrder: item.SortOrder,
|
||||
Price: item.Product.Price.InexactFloat64(),
|
||||
CostPrice: item.Product.CostPrice.InexactFloat64(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user