feat: Implement customer order management, including package listing, price calculation, and order creation.

This commit is contained in:
wood911010 committed 2026-02-27 22:10:20 +08:00
1 parent 5fdbe4b023
commit b903af8402
3 files changed
+38 -24

No files matched your search

@@ -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,
}
}
+10 -8
View File
@@ -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"`
}
+18 -8
View File
@@ -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,
}
}