diff --git a/backend/internal/api/handlers/cu_order_handler.go b/backend/internal/api/handlers/cu_order_handler.go index 7125c57..a91a7f7 100644 --- a/backend/internal/api/handlers/cu_order_handler.go +++ b/backend/internal/api/handlers/cu_order_handler.go @@ -53,14 +53,16 @@ func (h *CuOrderHandler) GetPackages(c *gin.Context) { result := make([]map[string]interface{}, len(packages)) for i, pkg := range packages { result[i] = map[string]interface{}{ - "id": pkg.ID, - "name": pkg.Name, - "type": pkg.Type, - "price": pkg.Price, - "max_devices": pkg.MaxDevices, - "description": pkg.Description, - "features": pkg.Features, - "details": pkg.Details, + "id": pkg.ID, + "name": pkg.Name, + "type": pkg.Type, + "price": pkg.Price, + "display_price": pkg.DisplayPrice, + "price_description": pkg.PriceDescription, + "max_devices": pkg.MaxDevices, + "description": pkg.Description, + "features": pkg.Features, + "details": pkg.Details, } } diff --git a/backend/internal/models/package.go b/backend/internal/models/package.go index bbf6748..7f5d96a 100644 --- a/backend/internal/models/package.go +++ b/backend/internal/models/package.go @@ -139,12 +139,14 @@ type PackageListResponse struct { // CuPackageResponse 用户端套餐响应(兼容原有结构) type CuPackageResponse struct { - ID string `json:"id"` - Name string `json:"name"` - Type string `json:"type"` - Price float64 `json:"price"` - MaxDevices int `json:"max_devices"` // 从features中解析 - Description string `json:"description"` - Features string `json:"features"` - Details string `json:"details"` + ID string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Price float64 `json:"price"` + DisplayPrice string `json:"display_price"` + PriceDescription string `json:"price_description"` + MaxDevices int `json:"max_devices"` // 从features中解析 + Description string `json:"description"` + Features string `json:"features"` + Details string `json:"details"` } diff --git a/backend/internal/service/package_service.go b/backend/internal/service/package_service.go index da7e457..bcb389e 100644 --- a/backend/internal/service/package_service.go +++ b/backend/internal/service/package_service.go @@ -207,14 +207,24 @@ func (s *packageService) toCuPackageResponse(pkg *models.Package) *models.CuPack details += fmt.Sprintf("%d个许可", maxDevices) } + // 计算 display_price + displayPrice := "" + if pkg.Price != 0 { + displayPrice = fmt.Sprintf("¥%g", pkg.Price) + } else { + displayPrice = pkg.PriceDescription + } + return &models.CuPackageResponse{ - ID: pkg.ID, - Name: pkg.Name, - Type: pkg.Type, - Price: pkg.Price, - MaxDevices: maxDevices, - Description: pkg.Description, - Features: pkg.Features, - Details: details, + ID: pkg.ID, + Name: pkg.Name, + Type: pkg.Type, + Price: pkg.Price, + DisplayPrice: displayPrice, + PriceDescription: pkg.PriceDescription, + MaxDevices: maxDevices, + Description: pkg.Description, + Features: pkg.Features, + Details: details, } }