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
+14

No files matched your search

@@ -57,6 +57,8 @@ func (h *CuOrderHandler) GetPackages(c *gin.Context) {
"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,
+2
View File
@@ -143,6 +143,8 @@ type CuPackageResponse struct {
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"`
@@ -207,11 +207,21 @@ 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,
DisplayPrice: displayPrice,
PriceDescription: pkg.PriceDescription,
MaxDevices: maxDevices,
Description: pkg.Description,
Features: pkg.Features,